GEPA.OptimizeAnything (GEPA v0.3.0)

Copy Markdown View Source

Optimize an arbitrary candidate with a user-supplied evaluator.

This is the Elixir port of upstream optimize_anything: it wraps a normal evaluator in a GEPA adapter, supports single-task and dataset modes, string candidates, seed generation, evaluator diagnostics, cache-aware evaluation, and the regular GEPA optimizer.

Summary

Functions

Build the seed-generation prompt used when seed_candidate is nil.

Return the default refiner prompt template.

Generate an initial seed candidate using an LM.

Return the process-local optimize-anything diagnostic log.

Append a diagnostic message to the process-local optimize-anything log.

Append a formatted diagnostic message to the process-local optimize-anything log.

Build a normalized hosted-provider LM client for optimize-anything helpers.

Optimize any candidate/evaluator pair.

Replace the process-local optimize-anything diagnostic log.

Return the internal key used to wrap string candidates.

Functions

build_seed_generation_prompt(opts)

@spec build_seed_generation_prompt(keyword() | map()) :: String.t()

Build the seed-generation prompt used when seed_candidate is nil.

default_refiner_prompt()

@spec default_refiner_prompt() :: String.t()

Return the default refiner prompt template.

generate_seed_candidate(lm, opts)

@spec generate_seed_candidate(term(), keyword() | map()) ::
  {:ok, map()} | {:error, term()}

Generate an initial seed candidate using an LM.

get_log_context()

@spec get_log_context() :: GEPA.OptimizeAnything.LogContext.Context.t()

Return the process-local optimize-anything diagnostic log.

log(message)

@spec log(term()) :: :ok

Append a diagnostic message to the process-local optimize-anything log.

log(parts, opts)

@spec log(
  term() | [term()],
  keyword()
) :: :ok

Append a formatted diagnostic message to the process-local optimize-anything log.

make_litellm_lm(model_name, opts \\ [])

@spec make_litellm_lm(
  String.t(),
  keyword()
) :: GEPA.LLM.Client.t()

Build a normalized hosted-provider LM client for optimize-anything helpers.

optimize_anything(config)

@spec optimize_anything(keyword() | map() | GEPA.OptimizeAnything.Config.t()) ::
  {:ok, GEPA.Result.t()} | {:error, term()}

Optimize any candidate/evaluator pair.

set_log_context(entries)

@spec set_log_context(GEPA.OptimizeAnything.LogContext.Context.t()) :: :ok

Replace the process-local optimize-anything diagnostic log.

str_candidate_key()

@spec str_candidate_key() :: String.t()

Return the internal key used to wrap string candidates.