...
Variables will adjust instructions on-the-fly, even when they are changed within a single mid-conversation. For example, the user can open one customer record and ask about the customer’s opportunity list. They can then proceed to open another customer and follow up with a simple “How about this customer?” The agent will then use both the conversation’s thread and the new customer details to provide the opportunity list for the new customer in view.
...
Click the “Insert Variable into Instructions” icon to add a specific variable into the instructions text area at the cursor. Variables are not passed along to the agent unless they are used in the instructions.
When deploying the agent, make sure to to replace the sample values with dynamic expressions.
Dynamic Content
Dynamic instruction content, including variables, is provided using Template Literal Notation and/or EJS SyntaxNotation. In addition to using previously defined variable names, dynamic content can include Node.js / JavaScript expressions that output dynamic content, execute code, or implement conditional and repeating content.
...
Template literal notation uses the dollar sign and curly braces to signify a variable or an expression. For example:
Code Block |
---|
The current customer number is: ${ |
...
customerNumber}. The customer name is: ${customerName.trim()}. |
EJS
...
Notation
EJS Syntax allows you to both control the instruction output and its flow. Use the <%- someOutput %> syntax to control the instruction output. Use the <% code %> to control the flow. Template literals can be used together with EJS syntax desired.
For example:
Code Block |
---|
The current customer number is: <%- customerNumber %>. The customer name is: ${customerName}<%- customerName %>. <% if (licensesopportunities.length > 0) { %> The following customeris a ownslist theof followingcustomer licensesopportunities: <% for (let licenseopportunity of licensesopportunities) { %> - <%- licenseopportunity.description %> <% } %> <% } %> |
Calling Routines
You can directly invoke Agent Routines from Agent Instructions by using the call()
API. This approach enables integration of server data into instructions, allowing database access, program calls, and consumption of Web Services.
Begin by creating the appropriate routine, and defining its input and output parameters. You can mark the routine private to ensure that the large language model doesn’t attempt to call it autonomously. Then, include the routine call in your instructions using EJS syntax. Here is an example:
Code Block |
---|
<% const { customerNumber, customerName } = await call("get session data", { sessionId }); %> The current customer number is: <%- customerNumber %>. The customer name is: <%- customerName %>. |
In this instance, customerNumber
and customerName
are retrieved from server-side data by calling the "get session data"
routine, while sessionId
is an Instruction Variable sourced from the browser. This method effectively marries server-side capabilities with client-side interactions, allowing for a seamless and secure use of your data.