Variables
Using variables in Agent Studio's prompts
Introduction
Agent Studio allows you to create dynamic and reusable prompts for your AI agents. You can now take them to the next level using variables.
Using variables
This feature enables you to build prompt templates that can be easily personalized and shared among team members or users. By defining placeholders within your prompts, you can inject specific values at runtime, making your interactions with the AI more flexible and adaptable.
A variable can be specified using braces in your prompt like this {this_is_a_variable}
.
You can name the variable whatever you want but it's better to name each variable for what they stand for.
Purpose
Why use variables? Here are the most important reasons why:
Prompt Reusability: Create generic prompts that can be tailored to various contexts without needing to rewrite them each time.
Personalization: Allow users to customize prompts with their own data, enhancing the relevance and effectiveness of the AI's responses.
Collaboration: Share prompt templates with colleagues, enabling consistent and efficient AI interactions across your team.
Automation: Integrate variable-driven prompts into automated workflows, dynamically adjusting the AI's behavior based on input data.
How to Use Prompt Variables
Variable Syntax:
Variables are defined using curly braces:
{variable_name}
.Variable names can include letters, numbers, and underscores.
Example: "Generate a report for
{customer_name}
"
Defining Variables:
When creating or editing a prompt in Agent Studio, you can insert variables directly into the prompt text.
Before submitting a prompt, you must specify the value of the variable in the side-bar, Agent Studio will recognize these variables.
Variable Input at Runtime:
Ensure that the values you provide are accurate and relevant to the prompt's context or the prompt will fail in doing what you expect it.
Example Scenario:
Prompt Template: "Write an email to {recipient_name} about the upcoming {event_name} on {event_date}."
Variable Input:
recipient_name
: "John Doe"event_name
: "Product Launch Webinar"event_date
: "November 15, 2023"
Resulting Prompt (Sent to AI): "Write an email to John Doe about the upcoming Product Launch Webinar on November 15, 2023."
Sharing Prompts with Variables:
When you share a prompt containing variables, other users will also be prompted to enter the variable values before execution.
This ensures that each user can personalize the prompt according to their specific needs.
Sharing can be accomplished via a shareable link, or by adding the prompt to a team library.
Best Practices
Descriptive Variable Names: Use clear and descriptive variable names that accurately reflect the data they represent.
Last updated