package ocaml-ai-sdk

  1. Overview
  2. Docs
OCaml AI SDK - Provider abstraction for AI models

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ocaml-ai-sdk-0.6.1.tbz
sha256=cb3b82428abcda76c02ec92f8103a4db28edf3f42795794a37135e9a3c40af96
sha512=11be8889ee25bee67b2be00553c42a4692bc73e5ce23985e8bb87f8a07e9d8f556b5a63b219fe5fe30366c8b0d4edae494afa80ccfbfcb112f1fa1e458de55bf

doc/ocaml-ai-sdk.ai_provider/Ai_provider/Prompt/index.html

Module Ai_provider.PromptSource

Prompt messages with role-constrained content parts.

Each message role restricts which content parts are valid:

  • System: text only
  • User: text and files
  • Assistant: text, files, reasoning, and tool calls
  • Tool: tool results only
Sourcetype file_data =
  1. | Bytes of bytes
  2. | Base64 of string
  3. | Url of string

How file data is represented.

Sourcetype user_part =
  1. | Text of {
    1. text : string;
    2. provider_options : Provider_options.t;
    }
  2. | File of {
    1. data : file_data;
    2. media_type : string;
    3. filename : string option;
    4. provider_options : Provider_options.t;
    }

A single part in a user message.

Sourcetype assistant_part =
  1. | Text of {
    1. text : string;
    2. provider_options : Provider_options.t;
    }
  2. | File of {
    1. data : file_data;
    2. media_type : string;
    3. filename : string option;
    4. provider_options : Provider_options.t;
    }
  3. | Reasoning of {
    1. text : string;
    2. provider_options : Provider_options.t;
    }
  4. | Tool_call of {
    1. id : string;
    2. name : string;
    3. args : Yojson.Basic.t;
    4. provider_options : Provider_options.t;
    }

A single part in an assistant message.

Sourcetype tool_result_content =
  1. | Result_text of string
  2. | Result_image of {
    1. data : string;
    2. media_type : string;
    }

Content returned with a tool result.

Sourcetype tool_result = {
  1. tool_call_id : string;
  2. tool_name : string;
  3. result : Yojson.Basic.t;
  4. is_error : bool;
  5. content : tool_result_content list;
  6. provider_options : Provider_options.t;
}

A tool execution result.

Sourcetype message =
  1. | System of {
    1. content : string;
    2. provider_options : Provider_options.t;
    }
  2. | User of {
    1. content : user_part list;
    }
  3. | Assistant of {
    1. content : assistant_part list;
    }
  4. | Tool of {
    1. content : tool_result list;
    }

A prompt message. The role constrains valid content parts.