Merge pull request #439 from hchen2020/master

Fallback Agent.
This commit is contained in:
C. Oceania 2024-05-07 12:21:42 -05:00 committed by GitHub
commit a67c4ab698
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 52 deletions

View file

@ -49,6 +49,8 @@
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\agent.json" />
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions.json" />
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\instruction.liquid" />
<None Remove="data\agents\01fcc3e5-0af7-49e6-ad7a-a760bd12dc4d\agent.json" />
<None Remove="data\agents\01fcc3e5-0af7-49e6-ad7a-a760bd12dc4d\instruction.liquid" />
<None Remove="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\agent.json" />
<None Remove="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\instruction.liquid" />
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\agent.json" />
@ -80,6 +82,12 @@
<Content Include="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\instruction.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\01fcc3e5-0af7-49e6-ad7a-a760bd12dc4d\agent.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\01fcc3e5-0af7-49e6-ad7a-a760bd12dc4d\instruction.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\agent.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View file

@ -1,46 +0,0 @@
using BotSharp.Abstraction.Routing.Settings;
namespace BotSharp.Core.Routing.Handlers;
public class ResponseToUserRoutingHandler : RoutingHandlerBase, IRoutingHandler
{
public string Name => "response_to_user";
public string Description => "When you can handle the conversation without asking specific agent.";
public List<ParameterPropertyDef> Parameters => new List<ParameterPropertyDef>
{
new ParameterPropertyDef("reason",
"why response to user directly without go to other agents."),
new ParameterPropertyDef("response",
"response content to user in courteous words with language English. If the user wants to end the conversation, you must set conversation_end to true and response politely."),
new ParameterPropertyDef("conversation_end",
"whether to end this conversation.",
type: "boolean"),
new ParameterPropertyDef("task_completed ",
"whether the user's task request has been completed.",
type: "boolean"),
new ParameterPropertyDef("language",
"User preferred language, considering the whole conversation. Language could be English, Spanish or Chinese.",
required: true)
};
public ResponseToUserRoutingHandler(IServiceProvider services, ILogger<ResponseToUserRoutingHandler> logger, RoutingSettings settings)
: base(services, logger, settings)
{
}
public async Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message, Func<RoleDialogModel, Task> onFunctionExecuting)
{
var response = new RoleDialogModel(AgentRole.Assistant, inst.Response)
{
CurrentAgentId = message.CurrentAgentId,
MessageId = message.MessageId,
StopCompletion = true
};
_dialogs.Add(response);
return true;
}
}

View file

@ -0,0 +1,11 @@
{
"id": "01fcc3e5-0af7-49e6-ad7a-a760bd12dc4d",
"name": "Fallback Agent",
"description": "Don't have sufficient confidence to trigger any of existing agent.",
"type": "task",
"createdDateTime": "2024-05-07T10:00:00Z",
"updatedDateTime": "2024-05-07T10:00:00Z",
"disabled": false,
"isPublic": true,
"profiles": [ "fallback" ]
}

View file

@ -0,0 +1 @@
You are a smart AI Assistant.

View file

@ -2,12 +2,10 @@ You're {{router.name}} ({{router.description}}).
You can understand messages sent by users in different languages.
Follow these steps to handle user request:
1. Read the [CONVERSATION] content.
2. Select a appropriate function from [FUNCTIONS].
3. Determine which agent is suitable to handle this conversation.
4. Re-think on whether the function you chose matches the reason.
5. For agent required arguments, think carefully, leave it as blank object if user doesn't provide specific arguments.
6. You must include all required args when using selected FUNCTIONS, but you must not make up any parameters when there is no exact value provided, those parameters must set value as null if not declared.
7. Response must be in JSON format.
2. Determine which agent is suitable to handle this conversation.
3. For agent required arguments, think carefully, leave it as blank object if user didn't provide the specific arguments.
4. You must include all required args for the selected agent, but you must not make up any parameters when there is no exact value provided, those parameters must set value as null if not declared.
5. Response must be in JSON format.
{% if routing_requirements and routing_requirements != empty %}
[REQUIREMENTS]