Aludel.Execution (aludel v0.7.0)

Copy Markdown View Source

Shared execution boundary for native provider calls and host-app callbacks.

Summary

Functions

Executes one provider request through the configured execution mode.

Executes a provider request while retaining diagnostic artifacts on failure.

Types

request()

@type request() :: %{
  optional(:documents) => [Aludel.Evals.TestCaseDocument.t()],
  optional(:messages) => [map()],
  optional(:metadata) => map(),
  kind: :run | :suite,
  prompt_version: Aludel.Prompts.PromptVersion.t(),
  variables: map(),
  provider: Aludel.Providers.Provider.t()
}

result()

@type result() :: %{
  output: String.t(),
  input_tokens: non_neg_integer() | nil,
  output_tokens: non_neg_integer() | nil,
  latency_ms: non_neg_integer() | nil,
  cost_usd: float() | nil,
  metadata: map() | nil,
  artifacts: map()
}

Functions

execute(request)

@spec execute(request()) :: {:ok, result()} | {:error, term()}

Executes one provider request through the configured execution mode.

Native mode renders the prompt and calls the configured provider. Callback mode sends a sanitized input map to the host application's executor. Expected failures return {:error, reason}.

execute_with_artifacts(request)

@spec execute_with_artifacts(request()) :: {:ok, result()} | {:error, term(), map()}

Executes a provider request while retaining diagnostic artifacts on failure.

Documents are loaded concurrently before dispatch. Validation, storage, configuration, provider, and callback failures return {:error, reason, artifacts} so callers can persist the attempted input and failure context.