package chatoyant

Build not yet checked
  1. Overview
  2. Docs
OCaml-first LLM SDK with Melange-generated JavaScript

Install

dune-project
 Dependency

Authors

Maintainers

Sources

chatoyant-v0.19.0.tbz
sha256=64099f65cef748f611ab5157321a1537d9be74ccc82a3f7afa22e20747978304
sha512=2be8f10f1dfcc48aeaca1b9762dedf13f2f4929946153f73a135a82f8bf4170f308d2dbf3fff04aaf3ac729a2e0791c157affe700c981ab124aca9467f024c67

doc/chatoyant.schema/Chatoyant_schema/Codec/index.html

Module Chatoyant_schema.CodecSource

Typed JSON codecs that carry JSON Schema.

A codec is the small bridge Chatoyant needs for ergonomic tool definitions: one value knows how to describe JSON with schema, decode incoming JSON into an OCaml value, and encode an OCaml value back to JSON.

Sourcetype 'a t
Sourcetype ('record, 'value) field
Sourceval schema : 'a t -> Schema.field
Sourceval custom : schema:Schema.field -> encode:('a -> Chatoyant_runtime.Json.t) -> decode:(Chatoyant_runtime.Json.t -> ('a, string) result) -> 'a t

Build a codec from explicit schema/encoder/decoder pieces.

This is primarily the low-level hook used by generated code and custom integrations. Prefer the typed builders or chatoyant.ppx in application code.

Sourceval map_schema : (Schema.field -> Schema.field) -> 'a t -> 'a t

Return an equivalent codec with its schema transformed.

Sourceval to_json_schema : 'a t -> Chatoyant_runtime.Json.t
Sourceval encode : 'a t -> 'a -> Chatoyant_runtime.Json.t
Sourceval decode : 'a t -> Chatoyant_runtime.Json.t -> ('a, string) result
Sourceval decode_field : string -> 'a t -> Chatoyant_runtime.Json.t -> ('a, string) result

Decode a field from a JSON object, respecting optional codecs.

Sourceval json : ?description:string -> unit -> Chatoyant_runtime.Json.t t
Sourceval string : ?description:string -> unit -> string t
Sourceval float : ?description:string -> unit -> float t
Sourceval int : ?description:string -> unit -> int t
Sourceval bool : ?description:string -> unit -> bool t
Sourceval string_enum : ?description:string -> string list -> string t
Sourceval array : ?description:string -> 'a t -> 'a list t
Sourceval optional : 'a t -> 'a option t
Sourceval field : string -> 'value t -> get:('record -> 'value) -> ('record, 'value) field
Sourceval object1 : ?description:string -> ('record, 'a) field -> ('a -> 'record) -> 'record t
Sourceval object2 : ?description:string -> ('record, 'a) field -> ('record, 'b) field -> ('a -> 'b -> 'record) -> 'record t
Sourceval object3 : ?description:string -> ('record, 'a) field -> ('record, 'b) field -> ('record, 'c) field -> ('a -> 'b -> 'c -> 'record) -> 'record t
Sourceval object4 : ?description:string -> ('record, 'a) field -> ('record, 'b) field -> ('record, 'c) field -> ('record, 'd) field -> ('a -> 'b -> 'c -> 'd -> 'record) -> 'record t
Sourceval object5 : ?description:string -> ('record, 'a) field -> ('record, 'b) field -> ('record, 'c) field -> ('record, 'd) field -> ('record, 'e) field -> ('a -> 'b -> 'c -> 'd -> 'e -> 'record) -> 'record t