GEPA.LLM.Adapters.ReqLLM (GEPA v0.3.0)

Copy Markdown View Source

GEPA LLM adapter backed by ReqLLM.

This adapter owns all ReqLLM-specific model specs, API-key wiring, response normalization, and test injection seams. GEPA optimizer/proposer code should only see GEPA.LLM.Client, GEPA.LLM.Request, and GEPA.LLM.Response.

Summary

Types

provider()

@type provider() :: :openai | :gemini | :anthropic

t()

@type t() :: %GEPA.LLM.Adapters.ReqLLM{
  api_key: String.t() | nil,
  env: (String.t() -> String.t() | nil),
  max_tokens: pos_integer() | nil,
  model: String.t(),
  provider: provider(),
  provider_opts: keyword(),
  req_llm_module: module(),
  req_options: keyword(),
  response_module: module(),
  temperature: float() | nil,
  timeout: pos_integer() | nil,
  top_p: float() | nil
}

Functions

build_state(opts)

@spec build_state(keyword()) :: {:ok, t()} | {:error, term()}

capabilities(client)

@spec capabilities(GEPA.LLM.Client.t()) :: MapSet.t(atom())

close(client)

@spec close(GEPA.LLM.Client.t()) :: :ok

complete(client, request)

@spec complete(GEPA.LLM.Client.t(), GEPA.LLM.Request.t()) ::
  {:ok, GEPA.LLM.Response.t()} | {:error, term()}

complete_legacy(state, prompt, opts \\ [])

@spec complete_legacy(t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

complete_structured_legacy(state, prompt, opts \\ [])

@spec complete_structured_legacy(t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

instruction_schema()

@spec instruction_schema() :: keyword()

new(opts \\ [])

@spec new(keyword()) :: {:ok, GEPA.LLM.Client.t()} | {:error, term()}

new!(opts \\ [])

@spec new!(keyword()) :: GEPA.LLM.Client.t()

stream(client, request)

@spec stream(GEPA.LLM.Client.t(), GEPA.LLM.Request.t()) :: {:error, term()}