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.6.1.tbz
sha256=cb3b82428abcda76c02ec92f8103a4db28edf3f42795794a37135e9a3c40af96
sha512=11be8889ee25bee67b2be00553c42a4692bc73e5ce23985e8bb87f8a07e9d8f556b5a63b219fe5fe30366c8b0d4edae494afa80ccfbfcb112f1fa1e458de55bf
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 {}| A_redacted_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)"
>