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.

Sample prompt with dynamic variables
1Address the user by their name, {{name}}.
2If relevant, reference their age: {{age}}.
3It is {{is_philosopher}} that this user is a philosopher.

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.

Session settings
1{
2 "type": "session_settings",
3 "variables": {
4 "name": "David Hume",
5 "age": 65,
6 "is_philosopher": true
7 }
8}

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, warning W0106 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 in variables 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
    1The current datetime is {{now}}. Mention this time at the start of
    2the call, or if the user asks what time it is. Convert this UTC
    3datetime to other time zones if requested.

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.


Built with