package ocaml-ai-sdk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

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.