Spectre.ActionPlanner (Spectre v0.3.0)

Copy Markdown View Source

Provider-neutral facade over an optional action planner.

Spectre does not parse an action language, load a tool registry, or know which planning library is installed. A configured implementation of Spectre.Action.Planner returns Spectre.Action values; this facade gives them trusted route ownership and turns them into staged effects.

Summary

Functions

Removes planner syntax from a visible model reply.

Plans one explicit planner instruction without executing it.

Plans actions found in a model response.

Functions

clean_reply(text, opts \\ [])

@spec clean_reply(
  String.t(),
  keyword()
) :: String.t()

Removes planner syntax from a visible model reply.

A mounted planner with a clean_reply/3 callback owns the cleanup; otherwise Spectre.Reply.Sanitizer strips Spectre control tokens (sanitize_reply: false opts out).

clean_reply(text, ctx, opts)

@spec clean_reply(String.t(), Spectre.Context.t() | map(), keyword()) :: String.t()

plan(instruction, opts \\ [])

@spec plan(
  String.t(),
  keyword()
) :: {:ok, Spectre.Effect.t()} | {:error, term()}

Plans one explicit planner instruction without executing it.

plan(instruction, ctx, opts)

@spec plan(String.t(), Spectre.Context.t() | map(), keyword()) ::
  {:ok, Spectre.Effect.t()} | {:error, term()}

plan_response(text, opts \\ [])

@spec plan_response(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Plans actions found in a model response.

When no planner is mounted the reply passes through unchanged.

plan_response(text, ctx, opts)

@spec plan_response(String.t(), Spectre.Context.t() | map(), keyword()) ::
  {:ok, %{reply_text: String.t(), effects: [Spectre.Effect.t()]}}
  | {:error, term()}