Dynamic Variables
Personalize EVI chats by leveraging dynamic variables in your system prompt.
Dynamic variables are placeholders you put in the system prompt, that you can fill with specific values at the beginning of the chat, and update to new values as the chat progresses. They are especially useful for giving EVI context that might change depending on the user or on the session - like the date, the user’s name role, or account balance, or any other dynamic or session-specific information.
Using variables in your prompt
To set up dynamic variables, first include placeholders for them in your system prompt. Use double curly braces ({{variable_name}}) to mark where each variable should appear in the text. This allows EVI to replace these placeholders dynamically with the specified values.
Visit our prompting guide for more details on adding dynamic variables to your prompt.
Assigning values in session settings
After adding placeholders for dynamic variables in your prompt, set their values by sending a Session Settings message over the WebSocket within an active Chat session. This message includes a variables parameter, with each key matching a placeholder in your prompt and each value specifying the text EVI will use.
Variable values can be strings, numbers, or booleans; however, each value is ultimately converted to a string when injected into your system prompt.
To ensure dynamic variables are recognized correctly, follow these guidelines:
- Only assign values to referenced variables: If a variable is given a value in the “variables” field but is not referenced in the system prompt, EVI will not use it in the conversation.
- Define all referenced variables: If a variable is referenced in the system prompt but lacks a value in the
variables
field, warningW0106
can be expected:"No values have been specified for the variables [variable_name], which can lead to incorrect text formatting. Please assign them values."
This warning is also expected if there are spelling inconsistencies between the variable names invariables
and those in the prompt.
Default dynamic variables
Hume provides built-in dynamic variables that are automatically populated and can be referenced in system prompts
without needing to set their values in SessionSettings
. The currently supported default variable is:
-
now: The current UTC datetime (e.g.,
"Nov 08, 2024 09:25 PM UTC"
)You can reference
now
in your system prompt to dynamically include the current UTC date and time, as shown below.Time-aware prompt example
If you set a custom value for a default variable in SessionSettings
, it will override the default value. For
example, specifying a value for now
in SessionSettings
will replace the automatic UTC datetime with your custom
value, offering flexibility when needed.