AshAi.Actions.Prompt.Adapter behaviour (ash_ai v0.2.2)

View Source

Behavior for prompt-backed-action adapters.

These adapters allow for different methodologies of handling prompt-based actions. For example, OpenAI supports "structured outputs", which will guarantee a response matching a requested JSON Schema. Other services however can still be used with prompt-based actions by providing them a tool that should be called when the action is complete.

Built in Adapters

See the adapter's documentation for more.

Custom Adapters & Adapter Options

If you want to provide a custom adapter, or customize the options for an adapter, you can specify the adapter option in your prompt/2 call.


run prompt(%{...}, adapter: {AshAi.Actions.Prompt.Adapter.CompletionTool, max_runs: 5})

Summary

Callbacks

Execute a prompt request with the given data and adapter options.

Callbacks

run(data, opts)

@callback run(data :: AshAi.Actions.Prompt.Adapter.Data.t(), opts :: Keyword.t()) ::
  {:ok, term()} | {:error, term()}

Execute a prompt request with the given data and adapter options.

Parameters

  • data - An AshAi.Actions.Prompt.Data struct containing all the prompt information
  • opts - Adapter-specific options

Returns

  • {:ok, result} - On successful completion
  • {:error, reason} - On failure