Update agent management features and refine configuration

Renamed methods and namespaces for clarity in `AgentsFeature` and extensions. Enhanced functionality of SEO Specialist and added new role for social media in sample app settings. Re-enabled persistence and API usage in Elsa server configuration.
This commit is contained in:
Sipke Schoorstra 2024-09-01 18:50:28 +02:00
parent 1940938021
commit 3acb1fd055
5 changed files with 48 additions and 25 deletions

View file

@ -136,30 +136,57 @@
}
},
{
"Name": "SeoSpecialist",
"Description": "A persona that optimizes text for search engines by extracting relevant keywords and creating a meta description, optimized for search engines.",
"Name": "SEO Specialist",
"Description": "A persona that extracts relevant keywords and creates a meta description, optimized for search engines.",
"Services": [
"ChatCompletion"
],
"FunctionName": "OptimizeSEO",
"PromptTemplate": "You are an SEO Specialist. Please extract relevant keywords from the following text and create a meta description that is optimized for search engines. Text: {{$Content}}",
"FunctionName": "ExtractKeywordsAndMetaDescription",
"PromptTemplate": "You are an SEO Specialist. Extract relevant keywords and create a meta description that is optimized for search engines from the following text: {{$Content}}. Your response must be using the following JSON format: { \"keywords\": [\"keyword1\", \"keyword2\"], \"description\": \"The meta description\" }.",
"InputVariables": [
{
"Name": "Content",
"Description": "The content to optimize.",
"Type": "String"
"Description": "The content to extract from.",
"Type": "string"
}
],
"OutputVariable": {
"Name": "SeoResult",
"Description": "The SEO optimization results.",
"Type": "String"
"Description": "The description and keywords.",
"Type": "object"
},
"ExecutionSettings": {
"Temperature": 0.5,
"TopP": 0.9,
"PresencePenalty": 0.0,
"FrequencyPenalty": 0.0
"PresencePenalty": 0.5,
"FrequencyPenalty": 0.5
}
},
{
"Name": "Social Media Specialist",
"Description": "A persona that specializes in writing catchy social media posts based on a given piece of content.",
"Services": [
"ChatCompletion"
],
"FunctionName": "WriteSocialMediaPost",
"PromptTemplate": "You are a Social Media Specialist. Write a catchy social media post based on the following text: {{$Content}}. The post should be optimized for social media platforms such as X (formerly Twitter) , Facebook, LinkedIn, and Instagram. Your response must be in JSON format and contain a single field named 'post' with the text of the social media post. Example: { \"post\": \"Some catchy social media post.\" }",
"InputVariables": [
{
"Name": "Content",
"Description": "The content to write a social media post for.",
"Type": "string"
}
],
"OutputVariable": {
"Name": "Post",
"Description": "The generated social media post.",
"Type": "object"
},
"ExecutionSettings": {
"Temperature": 0.9,
"TopP": 0.9,
"PresencePenalty": 0.7,
"FrequencyPenalty": 0.7
}
},
{
@ -257,7 +284,7 @@
"ChatCompletion"
],
"FunctionName": "Translate",
"PromptTemplate": "You are a Translator. Translate the provided text to the target language using the specified culture code. Do not change the content or meaning of the text. The text will be provided in the form of a JSON object, where each field contains text to be translated. Your response will be in the exact same JSON format, but with the original text values replaced with the translation for each field. The JSON containing the fields to translate: {{$Content}}. The target language culture code: {{$CultureCode}}",
"PromptTemplate": "You are a Translator. Translate the provided text to the target language using the specified language or culture code. Do not change the content or meaning of the text. The text will be provided in the form of a JSON object, where each field contains text to be translated. Your response will be in the exact same JSON format, but with the original text values replaced with the translation for each field. The JSON containing the fields to translate: {{$Content}}. The target language culture code: {{Language}}",
"InputVariables": [
{
"Name": "Content",
@ -265,7 +292,7 @@
"Type": "string"
},
{
"Name": "CultureCode",
"Name": "Language",
"Description": "The culture code of the target language to translate the content to.",
"Type": "string"
}
@ -285,14 +312,14 @@
}
},
{
"Name": "GraphicDesigner",
"Name": "Artist",
"Description": "A persona that creates an image that visualizes the essence of a given text.",
"Services": [
"ChatCompletion",
"TextToImage"
],
"FunctionName": "DesignGraphics",
"PromptTemplate": "You are a Graphic Designer that generates an image by interpreting the essence of the following text: {{$Content}}. Your response will be JSON in the following format: {\"imageUrl\": \"https://dalle.com/the-image.png\"}.",
"PromptTemplate": "You are an Artist that generates an image by interpreting the essence of the following text: {{$Content}}. Your response will be JSON in the following format: {\"imageUrl\": \"https://dalle.com/the-image.png\"}.",
"InputVariables": [
{
"Name": "Content",
@ -389,8 +416,8 @@
"MaxTokens": null,
"Temperature": 0.5,
"TopP": 0.9,
"PresencePenalty": 0.0,
"FrequencyPenalty": 0.0,
"PresencePenalty": 0.7,
"FrequencyPenalty": 0.7,
"ResponseFormat": "json_object"
}
},

View file

@ -3,11 +3,7 @@
<ItemGroup>
<ProjectReference Include="..\..\modules\Elsa.Agents.Activities\Elsa.Agents.Activities.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Agents.Api\Elsa.Agents.Api.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Agents.Core\Elsa.Agents.Core.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Agents.Models\Elsa.Agents.Models.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Agents.Persistence.EntityFrameworkCore.Sqlite\Elsa.Agents.Persistence.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Agents.Persistence.EntityFrameworkCore\Elsa.Agents.Persistence.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Agents.Persistence\Elsa.Agents.Persistence.csproj" />
<ProjectReference Include="..\..\modules\Elsa.AzureServiceBus\Elsa.AzureServiceBus.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Caching.Distributed.MassTransit\Elsa.Caching.Distributed.MassTransit.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Caching.Distributed.ProtoActor\Elsa.Caching.Distributed.ProtoActor.csproj" />

View file

@ -422,9 +422,9 @@ services
if (useAgents)
{
elsa
//.UseAgentPersistence(persistence => persistence.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
.UseAgentActivities()
//.UseAgentsApi()
.UseAgentPersistence(persistence => persistence.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
.UseAgentsApi()
;
services.Configure<AgentsOptions>(options => builder.Configuration.GetSection("Agents").Bind(options));
@ -452,7 +452,7 @@ services
ConfigureForTest?.Invoke(elsa);
});
services.Configure<CachingOptions>(options => options.CacheDuration = TimeSpan.FromDays(1));
//services.Configure<CachingOptions>(options => options.CacheDuration = TimeSpan.FromDays(1));
services.AddHealthChecks();
services.AddControllers();
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("*")));

View file

@ -19,7 +19,7 @@ public class AgentsFeature(IModule module) : FeatureBase(module)
}
/// <inheritdoc />
public override void Configure()
public override void Apply()
{
Services.AddOptions<AgentsOptions>();

View file

@ -3,7 +3,7 @@ using Elsa.Agents.Persistence.Features;
using JetBrains.Annotations;
// ReSharper disable once CheckNamespace
namespace Elsa.Agents.Persistence;
namespace Elsa.Agents;
/// Provides extensions to the <see cref="AgentPersistenceFeature"/> feature.
[PublicAPI]