nemoguardrails.colang.v1_0.runtime.runtime
nemoguardrails.colang.v1_0.runtime.runtime
Module Contents
Classes
Data
API
Bases: Runtime
Runtime for executing the guardrails.
Compute the next steps based on the current flow.
Parameters:
The list of events.
The processing log so far. This will be mutated.
Returns: List[dict]
List[dict]: The list of computed next steps.
Interact with actions and get response from the action-server and system actions.
Parameters:
Metadata for the action.
The name of the action.
The action parameters.
Returns: Tuple[Dict[str, Any], str]
Tuple[Dict[str, Any], str]: The response and status.
Initialize the flow configurations.
Returns:
None
Helper to construct an action result for an internal error.
Parameters:
The error message.
Returns:
The action result.
Load a flow configuration.
Parameters:
The flow data.
Returns:
None
Start the specified action, wait for it to finish, and post back the result.
Parameters:
The list of events.
Returns: List[dict]
List[dict]: The list of next steps.
Start a flow.
Parameters:
The list of events.
The processing log so far. This will be mutated.
Returns: List[dict]
List[dict]: The list of next steps.
Run flows in parallel.
Running flows in parallel is done by triggering a separate event loop with a start_flow event for each flow, in the context of the current event loop.
Parameters:
The list of flow names to run in parallel.
The current events.
Events to be added before starting each flow.
Events to be added after finishing each flow.
Run the input rails in parallel.
Run the output rails in parallel.
Run the output rails in parallel for streaming chunks.
This is a streamlined version that avoids the full flow state management which can cause issues with hide_prev_turn logic during streaming.
Parameters:
Dictionary mapping flow_id to {“action_name”: str, “params”: dict}
The events list for context
Generates the next events based on the provided history.
This is a wrapper around the process_events method, that will keep
processing the events until the listen event is produced.
Parameters:
The list of events.
The processing log so far. This will be mutated.
Returns: List[dict]
List[dict]: The list of generated events.