Prompts
How to use prompts from your Chatterfile
Accessing a prompt
Get Prompt
All prompts and attributes stored in Chatterfile can be accessed using the get_prompt
method.
This method takes a single argument, id
which is the prompt_id
of the prompt you want to access. You can
get the full prompt configuration by passing the prompt_id
to the get_prompt
method. Note, prompt templates are
converted to jinja2 syntax when they are returned.
It is returned as a dictionary so you can access the prompt’s attributes like so:
Render Prompt
Your prompts likely contain some variables that you want to replace with values from your code. This can be
done via the render_prompt
method. This method takes in the prompt_id of the prompt you would like to render
and then a dictionary of variables to replace in the prompt. The dictionary should be in the format of
{'VARIABLE_NAME': 'VARIABLE_VALUE'}
.
Run Prompt
Run prompts from Chatterfile using the run_prompt
method. Input the prompt_id
and variables to inject as variables
.
This method will call the LLM based on the configuration in the Chatterfile (though you can override these) and return
the response from the LLM. With simplified mode, you’ll get just the response text.