ExAthena.StructuredOutput (ExAthena v0.5.0)

Copy Markdown View Source

Strict structured-output helper. Requires provider :structured_output capability.

Unlike ExAthena.Structured, which falls back to fenced-block extraction and retries, this module sends the response_format straight through to the provider and decodes the JSON exactly once. Use it with providers that natively enforce a JSON schema (e.g. Ollama via req_llm's OpenAI adapter).

Returns {:error, :no_structured_output} when the provider (or a per-request :capabilities override) does not advertise structured_output: true.

Summary

Functions

request(prompt, schema, opts \\ [])

@spec request(String.t(), String.t() | atom() | map(), keyword()) ::
  {:ok, map()} | {:error, :no_structured_output | :invalid_json | term()}