nemoguardrails.rails.llm.utils

View as Markdown

Module Contents

Functions

NameDescription
get_action_details_from_flow_idGet the action name and parameters from the flow id.
get_history_cache_keyCompute the cache key for a sequence of messages.

API

nemoguardrails.rails.llm.utils.get_action_details_from_flow_id(
flow_id: str,
flows: typing.List[typing.Union[typing.Dict, typing.Any]]
) -> typing.Tuple[str, typing.Any]

Get the action name and parameters from the flow id.

First, try to find an exact match. If not found, then if the provided flow_id starts with one of the special prefixes, return the first flow whose id starts with that same prefix.

nemoguardrails.rails.llm.utils.get_history_cache_key(
messages: typing.List[dict]
) -> str

Compute the cache key for a sequence of messages.

Parameters:

messages
List[dict]

The list of messages.

Returns: str

A unique string that can be used as a key for the provided sequence of messages.