Spectre.Prompt.Materializer (Spectre v0.3.0)

Copy Markdown View Source

Closed renderer for canonical prompt fragments.

Only declared scalar placeholders are resolved. The resulting typed Spectre.Prompt.Plan and Spectre.Prompt.Receipt are deterministic for the same Definition fragment and resolved evidence.

Summary

Functions

Renders one canonical fragment and produces its effective receipt.

Renders one canonical fragment without exposing arbitrary string protocols.

Functions

materialize(fragment, input, context, definition_ref, opts \\ [])

@spec materialize(Spectre.Prompt.Fragment.t(), term(), map(), String.t(), keyword()) ::
  {:ok, Spectre.Prompt.Plan.t(), Spectre.Prompt.Receipt.t()} | {:error, term()}

Renders one canonical fragment and produces its effective receipt.

render(fragment, input, context, opts \\ [])

@spec render(
  Spectre.Prompt.Fragment.t(),
  Spectre.Input.t() | term(),
  map(),
  keyword()
) ::
  {:ok, String.t(), map()} | {:error, term()}

Renders one canonical fragment without exposing arbitrary string protocols.