Dsxir. Adapter behaviour
(dsxir v0.1.0)
Copy Markdown
Adapter behaviour: turn a signature + inputs + demos into LM messages, and parse the LM response back into a typed field map.
Two implementations ship in v0:
Dsxir.Adapter.Chat—[[ ## marker ## ]]text protocol, default.Dsxir.Adapter.Json— provider-native structured output, added later.
Summary
Types
@type adapter_error() :: Dsxir.Errors.Adapter.ParseError.t() | Dsxir.Errors.Adapter.ZoiValidation.t() | Dsxir.Errors.Adapter.FallbackExhausted.t()
@type lm_response() :: String.t()
@type messages() :: [Sycophant.Message.t()]
@type signature() :: module() | Dsxir.Signature.Compiled.t()
Callbacks
@callback format_and_call(signature(), map(), list(), keyword()) :: {:ok, map(), Dsxir.LM.usage(), term()} | {:fallback, Exception.t()}
@callback lm_mode() :: :text | :object
@callback parse(signature(), lm_response() | map(), keyword()) :: {:ok, map()} | {:error, adapter_error()}