GEPA.Adapter.Dispatch (GEPA v0.3.0)

Copy Markdown View Source

Adapter dispatch helpers used by the Elixir GEPA engine.

Python GEPA exposes one GEPAAdapter protocol. This Elixir port keeps a lightweight behaviour/duck-typing boundary, but centralizes all dispatch so the engine receives normalized EvaluationBatch values and consistent error tuples.

Summary

Functions

Evaluate a candidate through the configured adapter.

Read opaque adapter state for checkpointing.

Whether an adapter provides its own official-style proposal hook.

Build a reflective dataset through the adapter.

Return the module that should receive adapter callbacks, when any.

Ask an adapter to propose replacement text, when it owns custom proposal logic.

Restore opaque adapter state after loading a checkpoint.

Types

adapter()

@type adapter() :: module() | struct() | map()

candidate()

@type candidate() :: %{required(String.t()) => String.t()}

Functions

evaluate(adapter, batch, candidate, capture_traces)

@spec evaluate(adapter(), [term()], candidate(), boolean()) ::
  {:ok, GEPA.EvaluationBatch.t()} | {:error, term()}

Evaluate a candidate through the configured adapter.

get_adapter_state(adapter)

@spec get_adapter_state(adapter()) :: map()

Read opaque adapter state for checkpointing.

has_propose_new_texts?(adapter)

@spec has_propose_new_texts?(adapter()) :: boolean()

Whether an adapter provides its own official-style proposal hook.

make_reflective_dataset(adapter, candidate, eval_batch, components)

@spec make_reflective_dataset(adapter(), candidate(), GEPA.EvaluationBatch.t(), [
  String.t()
]) ::
  {:ok, map()} | {:error, term()}

Build a reflective dataset through the adapter.

module_for(module)

@spec module_for(adapter()) :: module() | nil

Return the module that should receive adapter callbacks, when any.

propose_new_texts(adapter, candidate, reflective_dataset, components)

@spec propose_new_texts(adapter(), candidate(), map(), [String.t()]) ::
  {:ok, map(), map(), map()} | {:error, term()} | :missing

Ask an adapter to propose replacement text, when it owns custom proposal logic.

set_adapter_state(adapter, state)

@spec set_adapter_state(adapter(), map()) :: :ok | {:ok, term()} | term()

Restore opaque adapter state after loading a checkpoint.