nemoguardrails.llm.prompts

View as Markdown

Prompts for the various steps in the interaction.

Module Contents

Functions

NameDescription
_get_promptReturn the prompt for the given task.
_load_promptsLoad the predefined prompts from the prompts directory.
get_promptReturn the prompt for the given task.
get_task_modelReturn the model for the given task in the current config.

Data

CURRENT_DIR

_prompts

API

nemoguardrails.llm.prompts._get_prompt(
task_name: str,
model: str,
prompting_mode: str,
prompts: typing.List
) -> nemoguardrails.rails.llm.config.TaskPrompt

Return the prompt for the given task.

We intentionally update the matching model at equal score, to take the last one, basically allowing to override a prompt for a specific model.

nemoguardrails.llm.prompts._load_prompts() -> typing.List[nemoguardrails.rails.llm.config.TaskPrompt]

Load the predefined prompts from the prompts directory.

nemoguardrails.llm.prompts.get_prompt(
config: nemoguardrails.rails.llm.config.RailsConfig,
task: typing.Union[str, nemoguardrails.llm.types.Task]
) -> nemoguardrails.rails.llm.config.TaskPrompt

Return the prompt for the given task.

nemoguardrails.llm.prompts.get_task_model(
config: nemoguardrails.rails.llm.config.RailsConfig,
task: typing.Union[str, nemoguardrails.llm.types.Task]
) -> typing.Optional[nemoguardrails.rails.llm.config.Model]

Return the model for the given task in the current config.

nemoguardrails.llm.prompts.CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
nemoguardrails.llm.prompts._prompts = _load_prompts()