Module Chatoyant_native.ChatSource

Sourcetype t

Eio-native stateful chat wrapper.

This hides provider/clock functor instantiation while preserving the same OCaml-owned session/tool-loop implementation underneath. Methods mutate the wrapped session and return t, so pipeline style remains natural.

Sourceval with_provider : ?model:string -> ?defaults:Chatoyant_core.Options.t -> clock:_ Eio.Time.clock -> (module Chatoyant_provider.Provider.CHAT) -> t

Build a chat from any first-class Chatoyant provider.

Sourceval openai : ?https:Http.https -> ?max_response_size:int -> ?base_url:string -> ?timeout_ms:int -> ?model:string -> ?defaults:Chatoyant_core.Options.t -> < net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > -> ?api_key:string -> unit -> t

OpenAI chat. When api_key is omitted, OPENAI_API_KEY is read from the process environment and missing keys are reported as Chatoyant provider errors on generation.

Sourceval anthropic : ?https:Http.https -> ?max_response_size:int -> ?base_url:string -> ?timeout_ms:int -> ?beta_headers:string list -> ?model:string -> ?defaults:Chatoyant_core.Options.t -> < net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > -> ?api_key:string -> unit -> t
Sourceval xai : ?https:Http.https -> ?max_response_size:int -> ?base_url:string -> ?timeout_ms:int -> ?model:string -> ?defaults:Chatoyant_core.Options.t -> < net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > -> ?api_key:string -> unit -> t
Sourceval openrouter : ?https:Http.https -> ?max_response_size:int -> ?timeout_ms:int -> ?http_referer:string -> ?title:string -> ?headers:(string * string) list -> ?model:string -> ?defaults:Chatoyant_core.Options.t -> < net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > -> ?api_key:string -> unit -> t
Sourceval local : ?https:Http.https -> ?max_response_size:int -> ?api_key:string -> ?timeout_ms:int -> ?headers:(string * string) list -> ?model:string -> ?defaults:Chatoyant_core.Options.t -> < net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > -> base_url:string -> unit -> t

Provider backing this chat. Useful for diagnostics and shortcut behavior.

Sourceval model : t -> string
Sourceval set_model : string -> t -> t
Sourceval messages : t -> Chatoyant_core.Message.t list
Sourceval tools : t -> Chatoyant_core.Tool.t list
Sourceval last_result : t -> Chatoyant_core.Result.generation option
Sourceval system : string -> t -> t
Sourceval user : string -> t -> t
Sourceval assistant : string -> t -> t
Sourceval add_message : Chatoyant_core.Message.t -> t -> t
Sourceval add_messages : Chatoyant_core.Message.t list -> t -> t
Sourceval clear_messages : t -> t
Sourceval add_tool : Chatoyant_core.Tool.t -> t -> t
Sourceval add_tools : Chatoyant_core.Tool.t list -> t -> t
Sourceval with_tool : Chatoyant_core.Tool.t -> t -> t
Sourceval with_tools : Chatoyant_core.Tool.t list -> t -> t
Sourceval clear_tools : t -> t
Sourceval generate_with_result : ?options:Chatoyant_core.Options.t -> ?timeout_ms:int -> ?temperature:float -> ?max_tokens:int -> ?extra:Chatoyant_runtime.Json.t -> t -> (Chatoyant_core.Result.generation, Chatoyant_provider.Provider.error) result
Sourceval generate : ?options:Chatoyant_core.Options.t -> ?timeout_ms:int -> ?temperature:float -> ?max_tokens:int -> ?extra:Chatoyant_runtime.Json.t -> t -> (string, Chatoyant_provider.Provider.error) result
Sourceval ask : ?system:string -> ?tools:Chatoyant_core.Tool.t list -> ?options:Chatoyant_core.Options.t -> ?timeout_ms:int -> ?temperature:float -> ?max_tokens:int -> ?extra:Chatoyant_runtime.Json.t -> string -> t -> (Chatoyant_core.Result.generation, Chatoyant_provider.Provider.error) result

Append an optional system prompt, optional tools, the user prompt, then generate a full result. This is the compact app-facing path for one-turn interactions while preserving the stateful Chat API underneath.

Sourceval ask_text : ?system:string -> ?tools:Chatoyant_core.Tool.t list -> ?options:Chatoyant_core.Options.t -> ?timeout_ms:int -> ?temperature:float -> ?max_tokens:int -> ?extra:Chatoyant_runtime.Json.t -> string -> t -> (string, Chatoyant_provider.Provider.error) result

Like ask, but returns only assistant text.

Sourceval stringify : ?pretty:bool -> t -> string
Sourceval load_json : Chatoyant_runtime.Json.t -> t -> (t, string) result
Sourceval clone : t -> t
Sourceval fork : t -> t