nemoguardrails.rails.llm.options
Generation options give more control over the generation and the result.
For example, to run only the input rails:
To invoke only some specific input/output rails:
rails.generate(messages=messages, options={ “rails”: { “input”: [“check jailbreak”], “output”: [“output moderation v2”] } })
To provide additional parameters to the main LLM call:
rails.generate(messages=messages, options={ “llm_params”: { “temperature”: 0.5 } })
To return additional information from the generation (i.e., context variables):
This will include the relevant chunks in the returned response, as part
of the output_data field.
rails.generate(messages=messages, options={ “output_vars”: [“relevant_chunks”] })
To skip enforcing the rails, and only inform the user if they were triggered:
rails.generate(messages=messages, options={ “enforce”: False })
{…, log: {“triggered_rails”: {“type”: “input”, “name”: “check jailbreak”}}}
To get more details on the LLM calls that were executed, including the raw responses:
rails.generate(messages=messages, options={ “log”: { “llm_calls”: True } })
{…, log: {“llm_calls”: […]}}
Module Contents
Classes
Data
API
Bases: BaseModel
A rail that was activated during the generation.
Bases: BaseModel
Information about an action that was executed.
Bases: BaseModel
Contains additional logging information associated with a generation call.
Bases: BaseModel
Options for what should be included in the generation log.
Bases: BaseModel
A set of options that should be applied during a generation.
The GenerationOptions control various things such as what rails are enabled, additional parameters for the main LLM, whether the rails should be enforced or ran in parallel, what to be included in the generation log, etc.
Bases: BaseModel
Options for what rails should be used during the generation.
Bases: BaseModel
Bases: BaseModel
General stats about the generation.
Bases: enum.Enum
Bases: enum.Enum
Bases: BaseModel
Bases: BaseModel
One tool call or tool result a tool rail blocked, identified so a caller can act on it.
Cut a tool name to MAX_QUOTED_IDENTITY_LENGTH characters, since an undeclared one is model-made.
Store a non-string id or name as None, so a malformed message cannot break building its violation.
Bases: enum.Enum
What a blocked tool call or tool result violated; callers switch on this, never on the reason text.