Variables
Variables are defined by setting a property on the conv.state
object within a function. You can choose a name for your variable and update its value to anything you want like so:
These variables will retain their state between turns of the conversation and can be referenced in subsequent function calls like so:
Prompt templating
Variables can be used within function calls and injected dynamically into prompts shown to the LLM. To inject a variable’s value into your prompt, use the syntax $variable_name
. The system will replace this placeholder with the variable’s value wherever it matches.
Example:
In your start function, you can write:
…then in your prompting:
The current date is $current_date
.
…becomes:
The current date is September 06, 2024.
When using variable templating, ensure the stored value is readable by the LLM. Complex objects like dictionaries or datetime will be stringified automatically.
Environment configuration
You can use the conv.env
property to define environment-specific platform functions and activate test features in sandbox or pre-release environments.
For example:
Dynamic updates
The value templated into the prompt is always kept up to date, so any updates will be reflected in the next turn sent to the LLM.
Example:
After running this function, the resulting prompt would display:
The current date is March 22, 1995.
…in the next turn.
Deleting a variable
To delete a variable, remove it from the state within a function: