Activity agent
It's a type of agent designed to execute a simple task based on the user's input. It's simplicity makes it a great choice for a wide range of use cases, and it's the perfect choice for quick demos and prototypes.
Use cases
- Cooking Agent: Given a list of ingredients, the agent will provide a list of recipes that can be made with those ingredients.
- Sentiment Analysis Agent: Given a text, the agent will provide a sentiment analysis of the text.
- Translation Agent: Given a text and a language, the agent will provide the translation of the text to the specified language.
- Weather Information Agent: Given a location, the agent will provide the current weather conditions and forecast for that location.
- Math Solver Agent: Given a mathematical expression or equation, the agent will provide the solution or step-by-step explanation.
- Stock Price Checker Agent: Given a stock ticker symbol, the agent will provide the current price and other relevant financial data.
- Unit Conversion Agent: Given a value and its unit of measurement, the agent will convert it to a specified target unit.
- Dictionary Agent: Given a word, the agent will provide its definition, synonyms, and example sentences.
Should I use this agent?
✅ You need to execute a single task based on the user's input. The context is defined by the user's input on each interaction, and the agent will execute the task based on that input.
⛔ You need to keep track of conversations with previous messages. In those cases, you may want to use one of the following agents:
Creating an Activity Agent
To create an Activity Agent, follow this guide.
Streaming
Streaming delivers the agent's response incrementally, as it's generated, via Server-Sent Events (SSE) instead of waiting for the full result to be ready.
If your agent can take a while to respond (for example, when it runs skills or searches large knowledge bases), enable streaming so you receive the response incrementally and avoid request timeouts. To do so, add a stream parameter set to true to the key-value pairs in the request body, as shown in the examples below.
See Streaming for the full event format.
Usage examples
Let's say you have an Activity Agent that provides did-you-mean suggestions for user queries. You can use the following code snippets to execute the agent:
cURL
curl -X POST
-L "https://api.serenitystar.ai/api/agent/didyoumean/execute"
-H "Content-Type:application/json"
-H "X-API-KEY:<YOUR_API_KEY>"
-d '[
{
"Key": "input",
"Value": "How do I reset my passwrod?"
},
{
"Key": "language",
"Value": "en"
},
{
"Key": "stream",
"Value": true
}
]'
C#
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.serenitystar.ai/api/agent/didyoumean/execute"),
Headers =
{
{ "X-API-KEY", "<YOUR_API_KEY>" },
{ "Content-Type", "application/json" },
},
Content = new StringContent(@"[
{
""Key"": ""input"",
""Value"": ""How do I reset my passwrod?""
},
{
""Key"": ""language"",
""Value"": ""en""
},
{
""Key"": ""stream"",
""Value"": true
}
]", Encoding.UTF8, "application/json"),
};
var response = await client.SendAsync(request);
var responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
}
}
Python
import requests
import json
url = 'https://api.serenitystar.ai/api/agent/didyoumean/execute'
headers = {
'Content-Type': 'application/json',
'X-API-KEY': '<YOUR_API_KEY>'
}
payload = json.dumps([
{
"Key": "input",
"Value": "How do I reset my passwrod?"
},
{
"Key": "language",
"Value": "en"
},
{
"Key": "stream",
"Value": True
}
])
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)