Dsxir.Optimizer.SIMBA.Proposer.OfferFeedback (dsxir v0.5.0)

Copy Markdown

Internal signature and trace helpers for the SIMBA AppendRule strategy. Given a better-vs-worse trajectory pair for the same input, the reflective LM produces per-module advice that gets appended to each predictor's instruction. Not a user-facing signature.

Summary

Functions

Unique predictor names from the trace, in first-seen order, as strings.

Turn the LM's advice output (a list of %{module, advice} maps) into a %{module_name => advice} map. Tolerates string or atom keys. Malformed or empty input yields %{} and never raises.

Recursively replace non-JSON-serializable terms with a placeholder string, leaving maps, lists, tuples, and serializable scalars intact. Mirrors DSPy's recursive_mask, used to safely render arbitrary input/metadata values.

Render a captured trace into a per-module trajectory string.

The internal OfferFeedback signature run by the AppendRule strategy.

Functions

module_names(trace)

@spec module_names([Dsxir.Trace.Entry.t()]) :: [String.t()]

Unique predictor names from the trace, in first-seen order, as strings.

parse(advice)

@spec parse(term()) :: %{optional(String.t()) => String.t()}

Turn the LM's advice output (a list of %{module, advice} maps) into a %{module_name => advice} map. Tolerates string or atom keys. Malformed or empty input yields %{} and never raises.

recursive_mask(term)

@spec recursive_mask(term()) :: term()

Recursively replace non-JSON-serializable terms with a placeholder string, leaving maps, lists, tuples, and serializable scalars intact. Mirrors DSPy's recursive_mask, used to safely render arbitrary input/metadata values.

render_trajectory(trace)

@spec render_trajectory([Dsxir.Trace.Entry.t()]) :: String.t()

Render a captured trace into a per-module trajectory string.

signature()

@spec signature() :: Dsxir.Signature.Compiled.t()

The internal OfferFeedback signature run by the AppendRule strategy.