nemoguardrails.rails.llm.options
Generation options give more control over the generation and the result.
For example, to run only the input rails::
Since everything is enabled by default, we disable explicitly the others
options = { “rails”: { “output”: False, “dialog”: False, “retrieval”: False } } messages = [{ “role”: “user”, “content”: “Am I allowed to say this?” }]
rails.generate(messages=messages, options=options)
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
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