nemoguardrails.guardrails.rail_action
nemoguardrails.guardrails.rail_action
Base class for IORails rail actions.
Defines the template-method pipeline: extract → prompt → respond → parse. Subclasses override individual steps. The base provides three concrete response helpers for the common call patterns (LLM, API, local).
Module Contents
Classes
Data
API
Base class for all IORails rail actions.
Subclasses implement the abstract _-prefixed hooks to customise each
stage of the pipeline. The public entry point is :meth:run.
Build the prompt / request payload from extracted data.
Returns whatever _get_response needs: a message list, a dict body, etc. May return None if the response step doesn’t need a prompt (e.g. API calls that build their own payload).
Extract the relevant fields from messages into a dict.
Returns a dict of extracted values that will be passed to _create_prompt.
Call an API endpoint via EngineRegistry and return the response dict.
Call an LLM via EngineRegistry and return the structured response.
Run a local/in-process check. Override in subclasses that need it.
Extract model from the flow’s $model= parameter, falling back to :attr:fallback_model.
Call the model/API/local engine and return the raw response.
Return the content of the last user message.
Convert the raw response into a RailResult.
Convert LLMTaskManager render output to role/content message format.
Verify the flow’s base name matches this action’s action_name.
Execute the full rail pipeline and return a safety result.