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.5.tbz
sha256=9e3437d6ebf48ec9f5d9a8afd62eaeece124023f02dbd87e4b291205fd309b72
sha512=605c10ed62c0cbc31a151b7031cc80a284d5c94231c1ef423ae7439572e3fadddab4a45f52eaeeef83973a8e324839b9fda03f9082deef1b6781353f63975510

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.