GEPA.LLM.Tracking (GEPA v0.3.0)

Copy Markdown View Source

Wraps arbitrary callable LLMs with lightweight token/cost accounting.

Elixir values are immutable, so counters are kept in an Agent owned by the wrapper. GEPA.StopCondition.MaxReflectionCost can read the live cost via total_cost/1.

Summary

Types

counters()

@type counters() :: %{
  total_cost: float(),
  total_tokens_in: non_neg_integer(),
  total_tokens_out: non_neg_integer(),
  calls: non_neg_integer()
}

t()

@type t() :: %GEPA.LLM.Tracking{callable: function(), counter: pid()}

Functions

calls(tracking)

@spec calls(t()) :: non_neg_integer()

complete(tracking, prompt, opts \\ [])

@spec complete(t(), GEPA.LLM.prompt(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

counters(tracking)

@spec counters(t()) :: counters()

new(callable)

@spec new(function()) :: t()

total_cost(tracking)

@spec total_cost(t()) :: float()

total_tokens_in(tracking)

@spec total_tokens_in(t()) :: non_neg_integer()

total_tokens_out(tracking)

@spec total_tokens_out(t()) :: non_neg_integer()