package deepseek
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=816187f01c004f7b1b554512a45ce9df
sha512=4dd13eea0977d1064bd580c366673e819f8f06874fd6e3b83bf9a585c283ffa9ff9fee0ff671127a5f60320a22bf1c84f526855916564da6de72e1c335c86e63
doc/deepseek.dsml/Dsml/Codec/index.html
Module Dsml.CodecSource
Codec
A bidirectional combinator codec for the DSML tool-call grammar, in the style of Json.Codec: one description both decodes a tool-call block to OCaml values and encodes them back.
type edit = { path : string; line : int }
let edit_codec =
let open Dsml.Codec in
Invoke.map "edit" (fun path line -> { path; line })
|> Invoke.param ~enc:(fun e -> e.path) "path" string
|> Invoke.param ~enc:(fun e -> e.line) "line" int
|> Invoke.seal
let block =
Dsml.Codec.encode edit_codec [ { path = "/tmp/x.c"; line = 42 } ]
let calls = Dsml.Codec.decode edit_codec blockA codec for one parameter value.
map_value ~dec ~enc v adapts the value codec v to another type.
A codec for one tool invocation, producing a value of type 'a.
dynamic decodes/encodes any tool, mapping parameters to JSON arguments.
map ~dec ~enc c adapts an invoke codec to another type.
schema c is the JSON Schema for c's parameters object, with one property per Invoke.param and a required list. Pass it to Tool.v to advertise the tool to the model.
decode_arguments c arguments decodes one tool call's JSON-object arguments string (as carried by tool_call) through c, returning the typed value or an error message.
case ~inject ~project c makes invoke codec c a case of a sum type 'b: inject lifts a decoded value in, project selects it for encoding.
choice ?default cases dispatches an invocation on its tool name to the matching case; default handles unmatched names (e.g. dynamic).
decode c s decodes the tool-call block found in s with c.