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.3.tbz
sha256=636d458cb1564ed88ca8c0250c432e91c2f822fd49ad2b923819e762bda10be6
sha512=361e476423ebc0f9cf561cc28ccd4531cf08e424e95eea43a67d6b8dbb457a49a25b418625ffa99f6327fc5df14e540e502d1aa8ed606111c5c010fe498eec2a

doc/ocaml-ai-sdk.ai_provider_openai/Ai_provider_openai/Convert_prompt/index.html

Module Ai_provider_openai.Convert_promptSource

Convert SDK prompt messages to OpenAI Chat Completions format.

Sourcetype openai_content_part =
  1. | O_text of {
    1. text : string;
    }
  2. | O_image_url of {
    1. url : string;
    }
Sourcetype openai_function_call = {
  1. name : string;
  2. arguments : string;
}
Sourcetype openai_tool_call = {
  1. id : string;
  2. type_ : string;
  3. function_ : openai_function_call;
}
Sourcetype openai_message =
  1. | System_msg of {
    1. content : string;
    }
  2. | Developer_msg of {
    1. content : string;
    }
  3. | User_msg of {
    1. content : openai_content_part list;
    }
  4. | Assistant_msg of {
    1. content : string option;
    2. tool_calls : openai_tool_call list;
    }
  5. | Tool_msg of {
    1. tool_call_id : string;
    2. content : string;
    }
Sourceval convert_messages : system_message_mode:Model_catalog.system_message_mode -> Ai_provider.Prompt.message list -> openai_message list * Ai_provider.Warning.t list

Convert SDK messages to OpenAI format. Returns converted messages and any warnings generated.

Sourceval openai_message_to_json : openai_message -> Yojson.Basic.t

Serialize an OpenAI message to JSON.