nemoguardrails.actions.llm.generation
A set of actions for generating various types of completions using an LLMs.
Module Contents
Classes
Functions
Data
API
A container objects for multiple related actions.
Heuristic to extract user message examples from a flow.
Helper to extract the general instruction.
Helper to extract only the two turns from the sample conversation.
This is needed to be included to “seed” the conversation so that the model can follow the format more easily.
Initializes the index of bot messages.
Initializes the index of flows.
Initializes the index of user messages.
Process the provided flows to extract the user utterance examples.
Render a string using the provided context information.
Parameters:
The string template to render.
The context for rendering.
Returns: str
The rendered string.
Search the index of flows.
Generate a bot message based on the desired bot intent.
Generate all three main Guardrails phases with a single LLM call. The three phases are: user canonical from (user intent), next flow steps (i.e. bot canonical form) and bot message.
Generate the next step in the current conversation flow.
Currently, only generates a next step after a user intent.
Generate the canonical form for what the user said i.e. user intent.
Generate a value in the context of the conversation.
:param instructions: The instructions to generate the value.
:param events: The full stream of events so far.
:param var_name: The name of the variable to generate. If not specified, it will use
the action_result_key as the name of the variable.
:param llm: Custom llm model to generate_value
Clean an utterance by performing the following operations:
- replacing “\n” with ” ”.
Args: utterance (str): The utterance to clean.
Returns: str: The cleaned utterance.