GEPA.CodeExecution (GEPA v0.3.0)

Copy Markdown View Source

Utilities for evaluating Elixir code snippets with captured outputs.

The module keeps the original execute/2 map-returning API while adding the upstream-style execute_code/2 API with timeout support, captured stdout and stderr, code hashes, variable capture, and optional entry-point invocation.

Summary

Functions

Execute Elixir code and return the legacy map result.

Execute Elixir code and return a rich structured result.

Return a deterministic hash for normalized source code.

Convert side-info values into serializable values suitable for prompts.

Types

mode()

@type mode() :: :in_process | :subprocess

result()

@type result() :: %{
  :ok => boolean(),
  optional(:result) => term(),
  optional(:stdout) => String.t(),
  optional(:stderr) => String.t(),
  optional(:error) => term(),
  optional(:bindings) => keyword()
}

Functions

execute(code, opts \\ [])

@spec execute(
  String.t(),
  keyword()
) :: result()

Execute Elixir code and return the legacy map result.

execute_code(code, opts \\ [])

@spec execute_code(
  String.t(),
  keyword()
) :: GEPA.CodeExecution.Result.t()

Execute Elixir code and return a rich structured result.

get_code_hash(code, length \\ 8)

@spec get_code_hash(String.t(), pos_integer()) :: String.t()

Return a deterministic hash for normalized source code.

side_info_to_data(image)

@spec side_info_to_data(term()) :: term()

Convert side-info values into serializable values suitable for prompts.