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.1.tbz
sha256=467ed85a42617ce399d0032d81f27f8dd2e8ca9b0753daeb2cbd84bf46761370
sha512=f5e96feea16c6ffdb45f49ee3e84e9cdb5426245c1ac32acc6434c15b949cc576c1007ed463bf1362dce507d10700eb96acf5a42fa7eed4e8e491ae0214a2e4a

doc/ocaml-ai-sdk.ai_provider_anthropic/Ai_provider_anthropic/Convert_prompt/index.html

Module Ai_provider_anthropic.Convert_promptSource

Convert SDK prompts to Anthropic Messages API format.

Anthropic message content types.

Sourcetype image_source =
  1. | Base64_image of {
    1. media_type : string;
    2. data : string;
    }
  2. | Url_image of {
    1. url : string;
    }
Sourcetype document_source =
  1. | Base64_document of {
    1. media_type : string;
    2. data : string;
    }
Sourcetype anthropic_tool_result_content =
  1. | Tool_text of string
  2. | Tool_image of {
    1. source : image_source;
    }
Sourcetype anthropic_content =
  1. | A_text of {
    1. text : string;
    2. cache_control : Cache_control.t option;
    }
  2. | A_image of {
    1. source : image_source;
    2. cache_control : Cache_control.t option;
    }
  3. | A_document of {
    1. source : document_source;
    2. cache_control : Cache_control.t option;
    }
  4. | A_tool_use of {
    1. id : string;
    2. name : string;
    3. input : Yojson.Basic.t;
    }
  5. | A_tool_result of {
    1. tool_use_id : string;
    2. content : anthropic_tool_result_content list;
    3. is_error : bool;
    }
  6. | A_thinking of {
    1. thinking : string;
    2. signature : string;
    }
Sourcetype anthropic_message = {
  1. role : [ `User | `Assistant ];
  2. content : anthropic_content list;
}
Sourceval extract_system : Ai_provider.Prompt.message list -> string option * Ai_provider.Prompt.message list

Extract system messages (concatenated) and return remaining messages.

Sourceval convert_messages : Ai_provider.Prompt.message list -> anthropic_message list

Convert SDK messages to Anthropic format with message grouping for alternating user/assistant roles.

Sourceval anthropic_content_to_json : anthropic_content -> Yojson.Basic.t

Serialize a content block to JSON.

Sourceval anthropic_message_to_json : anthropic_message -> Yojson.Basic.t

Serialize a message to JSON.