Dsxir.Predictor behaviour (dsxir v0.1.0)

Copy Markdown

Predictor behaviour. A predictor is a stateless module that turns inputs into a %Dsxir.Prediction{} by routing through an adapter and the active LM.

Augmented outputs

Some predictors synthesize extra output fields at runtime that are not declared on the underlying signature module (e.g. :reasoning from Dsxir.Predictor.ChainOfThought, :trajectory from Dsxir.Predictor.ReAct). Impls report these via the optional augmented_outputs/1 callback so that Dsxir.Artifact allows them through the demo field validation on save/load. The callback is optional; impls that do not augment their signature can omit it.

Summary

Callbacks

Output field names synthesized by the predictor at runtime, in addition to the declared outputs of signature. Optional. Defaults to [] for impls that do not implement it.

Functions

Resolve the augmented output names for impl against signature, or return [] when the impl does not implement augmented_outputs/1.

Types

signature()

@type signature() :: module() | Dsxir.Signature.Compiled.t()

Callbacks

augmented_outputs(signature)

(optional)
@callback augmented_outputs(signature()) :: [atom()]

Output field names synthesized by the predictor at runtime, in addition to the declared outputs of signature. Optional. Defaults to [] for impls that do not implement it.

forward(state, signature, inputs, opts)

@callback forward(
  state :: Dsxir.Program.State.t(),
  signature :: signature(),
  inputs :: map(),
  opts :: keyword()
) :: {Dsxir.Program.State.t(), Dsxir.Prediction.t()}

Functions

augmented_outputs(impl, signature)

@spec augmented_outputs(module(), signature()) :: [atom()]

Resolve the augmented output names for impl against signature, or return [] when the impl does not implement augmented_outputs/1.