OpenAI.Agents.Guardrail behaviour (openai_agents v0.1.2)
Defines the behavior for guardrails that validate agent inputs and outputs.
Guardrails can halt agent execution if they detect problematic content.
Example
defmodule MyApp.Guardrails.ContentFilter do
use OpenAI.Agents.Guardrail
@impl true
def validate_input(input, context) do
if contains_prohibited_content?(input) do
{:error, "Prohibited content detected", %{reason: "content_policy"}}
else
:ok
end
end
@impl true
def validate_output(output, context) do
:ok
end
end
Summary
Functions
Runs input guardrails on the given input.
Runs output guardrails on the given output.
Validates a guardrail module has the correct structure.
Types
Callbacks
@callback validate_input(input(), context()) :: validation_result()
@callback validate_output(output(), context()) :: validation_result()
Functions
Runs input guardrails on the given input.
Runs output guardrails on the given output.
Validates a guardrail module has the correct structure.