GEPA.Callbacks (GEPA v0.3.0)

Copy Markdown View Source

Synchronous observational callbacks for GEPA optimization runs.

This module accepts both Elixir-native event names (:iteration_end) and the upstream Python-style callback methods (on_iteration_end/1). Callback entries may be functions, modules, or structs:

  • two-arity function: fn event_name, event -> ... end
  • one-arity function: fn event -> ... end
  • module exporting event_name/1 or on_event_name/1
  • struct whose module exports event_name/2 or on_event_name/2

Callback failures are logged and do not prevent later callbacks from receiving the same event, matching the upstream GEPA callback contract.

Summary

Functions

Return the upstream-style on_* method atom for an event name.

Notify each callback of an event.

Types

callback()

@type callback() :: function() | module() | struct()

event()

@type event() :: map()

event_name()

@type event_name() :: atom() | String.t()

Functions

method_name(event_name)

@spec method_name(event_name()) :: atom()

Return the upstream-style on_* method atom for an event name.

notify(callbacks, event_name, event)

@spec notify([callback()] | callback() | nil, event_name(), event()) :: :ok

Notify each callback of an event.