GEPA.Proposer.InstructionProposal (GEPA v0.3.0)

Copy Markdown View Source

LLM-based instruction proposal with configurable templates.

This module generates improved instruction texts by prompting an LLM with the current instruction and feedback from execution traces. It supports the upstream <curr_param> / <side_info> template contract and Elixir's legacy {component_name} / {current_instruction} / {reflective_dataset} form.

Reflective dataset records may include %GEPA.Image{} values. Images are rendered as [IMAGE-N] markers in the text and sent as multimodal content parts to compatible reflection LLMs.

Summary

Functions

Returns the default template string.

Create a new instruction proposal configuration.

Propose new instruction text for one component.

Propose new texts for multiple components.

Propose new text for multiple components and retain prompt/raw-output metadata.

Propose new instruction text and retain rendered prompt plus raw LLM output.

Types

prompt()

@type prompt() :: String.t() | [map()]

t()

@type t() :: %GEPA.Proposer.InstructionProposal{
  extract_fn: (String.t() -> String.t()) | nil,
  format_fn:
    ([map()] -> String.t() | {String.t(), [GEPA.Image.t()]} | prompt()) | nil,
  llm: GEPA.LLM.t(),
  structured_output: boolean(),
  template: String.t() | %{required(String.t()) => String.t()}
}

Functions

default_template()

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

Returns the default template string.

new(opts)

@spec new(keyword()) :: t()

Create a new instruction proposal configuration.

propose(config, component_name, current_instruction, dataset)

@spec propose(t(), String.t(), String.t(), [map()]) ::
  {:ok, String.t()} | {:error, term()}

Propose new instruction text for one component.

propose_batch(config, candidate, reflective_dataset, components)

@spec propose_batch(t(), map(), map(), [String.t()]) ::
  {:ok, map()} | {:error, term()}

Propose new texts for multiple components.

propose_batch_with_metadata(config, candidate, reflective_dataset, components)

@spec propose_batch_with_metadata(t(), map(), map(), [String.t()]) ::
  {:ok, map(), map(), map()} | {:error, term()}

Propose new text for multiple components and retain prompt/raw-output metadata.

propose_with_metadata(config, component_name, current_instruction, dataset)

@spec propose_with_metadata(t(), String.t(), String.t(), [map()]) ::
  {:ok, String.t(), prompt(), String.t()} | {:error, term()}

Propose new instruction text and retain rendered prompt plus raw LLM output.