package ocaml-ai-sdk
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
OCaml AI SDK - Provider abstraction for AI models
Install
dune-project
Dependency
Authors
Maintainers
Sources
ocaml-ai-sdk-0.4.tbz
sha256=4f3f22ae61d360b994cd75323bcb6b6bf915f6755fd1e7bab6844ca8a240c1e7
sha512=3c52b17096da818f5d3bcf9fe16826c3bec4533d6a1681e8ba0f957f37ee4f425696017cb78f1a24732f8851010d436cf446f873b72b6a4f5004d6b492072abf
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.
Source
type anthropic_tool_result_content = | Tool_text of string| Tool_image of {source : image_source;
}
Source
type anthropic_content = | A_text of {text : string;cache_control : Cache_control.t option;
}| A_image of {source : image_source;cache_control : Cache_control.t option;
}| A_document of {source : document_source;cache_control : Cache_control.t option;
}| A_tool_use of {id : string;name : string;input : Yojson.Basic.t;
}| A_tool_result of {tool_use_id : string;content : anthropic_tool_result_content list;is_error : bool;cache_control : Cache_control.t option;
}| A_thinking of {}
Source
val extract_system :
Ai_provider.Prompt.message list ->
(string * Ai_provider.Provider_options.t) list
* Ai_provider.Prompt.message listExtract system messages with their per-message provider_options and return remaining messages. The order matches the input.
Source
val system_to_json :
?validator:Ai_provider_anthropic__.Cache_control_validator.t ->
(string * Ai_provider.Provider_options.t) list ->
Yojson.Basic.t optionBuild the wire JSON for the system field on the Anthropic request. Returns None when no system messages are present. Always emits the array-of-blocks form (one text block per system message), matching upstream @ai-sdk/anthropic's convertToAnthropicPrompt.
Source
val convert_messages :
?validator:Ai_provider_anthropic__.Cache_control_validator.t ->
Ai_provider.Prompt.message list ->
anthropic_message listConvert SDK messages to Anthropic format with message grouping for alternating user/assistant roles. Pass ~validator to share the 4-breakpoint budget with system_to_json and the tools conversion.
Serialize a content block to JSON.
Serialize a message to JSON.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>