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.2.tbz
sha256=17063971a74ccd72619a43ecfcb29d28cdf08f90d406a960bd475f65fee1a0d9
sha512=1f3f2d1d7fa4f53843cc1b303cbf9d6dcc85780e7c768ced723f3de83ea897748fa231b48e729216abcc069dee818edc6751a45271541e8a007369bf6e9d23e3

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.