aiflows.prompt_template package

Submodules

aiflows.prompt_template.jinja2_prompts module

class aiflows.prompt_template.jinja2_prompts.JinjaPrompt(**kwargs)

Bases: object

This class can be used to generate prompts from jinja templates

Parameters:

**kwargs – See below:

Keyword Arguments:
  • input_variables (List[str]) –

    A list of variables that are required to render the template

  • partial_variables (Dict[str, Any]) –

    A dictionary of variables and their values that are required to render the template (useful when one has some variables before others)

  • template (str) –

    The jinja template to render

format(**kwargs)

format the template with the given input variables

Parameters:

**kwargs – The input variables to render the template (should be a subset of the input variables)

Returns:

The rendered template

Return type:

str

partial(**kwargs)

Returns a new JinjaPrompt object, given some input variables (moves the given input variables from the input variables to the partial variables) This method is useful when one has some variables before others

Parameters:

**kwargs – The input variables to render the template (should be a subset of the input variables)

Returns:

A new JinjaPrompt object

Return type:

JinjaPrompt

Module contents