Add pizza bot router.
This commit is contained in:
parent
2445cb31e0
commit
2b6c2353b6
|
|
@ -103,6 +103,7 @@ BotSharp uses component design, the kernel is kept to a minimum, and business fu
|
|||
|
||||
#### Tools
|
||||
- BotSharp.Plugin.RoutingSpeeder
|
||||
- BotSharp.Plugin.WebDriver
|
||||
- BotSharp.Plugin.PizzaBot
|
||||
|
||||
#### UIs
|
||||
|
|
|
|||
BIN
docs/static/screenshots/agent-builder-agents.png
vendored
BIN
docs/static/screenshots/agent-builder-agents.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 107 KiB |
|
|
@ -62,9 +62,6 @@ public class Agent
|
|||
|
||||
public bool IsPublic { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsHost { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public PluginDef Plugin { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,20 +13,12 @@ public partial class AgentService
|
|||
{
|
||||
var agents = _db.GetAgents(filter);
|
||||
|
||||
// Set IsRouter
|
||||
var routeSetting = _services.GetRequiredService<RoutingSettings>();
|
||||
foreach (var agent in agents)
|
||||
{
|
||||
agent.Plugin = GetPlugin(agent.Id);
|
||||
}
|
||||
|
||||
// Set IsHost
|
||||
var agentSetting = _services.GetRequiredService<AgentSettings>();
|
||||
foreach (var agent in agents)
|
||||
{
|
||||
agent.IsHost = agentSetting.HostAgentId == agent.Id;
|
||||
}
|
||||
|
||||
agents = agents.Where(x => x.Installed).ToList();
|
||||
var pager = filter?.Pager ?? new Pagination();
|
||||
return new PagedItems<Agent>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
|
|
@ -55,6 +55,10 @@
|
|||
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.sequential.liquid" />
|
||||
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\response_with_function.liquid" />
|
||||
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\welcome.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\agent.json" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\instruction.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.executor.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.reviewer.liquid" />
|
||||
<None Remove="data\plugins\config.json" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
@ -86,6 +90,18 @@
|
|||
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\welcome.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\agent.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\instruction.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.executor.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.reviewer.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\plugins\config.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
"type": "task",
|
||||
"createdDateTime": "2024-01-15T10:39:32Z",
|
||||
"updatedDateTime": "2024-01-15T14:39:32Z",
|
||||
"iconUrl": "/images/users/bot.png",
|
||||
"iconUrl": "/images/logo.png",
|
||||
"disabled": false,
|
||||
"isPublic": true,
|
||||
"profiles": [ "standalone" ]
|
||||
"isPublic": true
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"id": "dfd9b46d-d00c-40af-8a75-3fbdc2b89869",
|
||||
"name": "Evaluator",
|
||||
"description": "Evaluate the performance of the LLM agents",
|
||||
"createdDateTime": "2023-08-18T00:00:00Z",
|
||||
"updatedDateTime": "2023-08-18T00:00:00Z",
|
||||
"disabled": true,
|
||||
"llmConfig": {
|
||||
"model": "gpt-35-turbo-instruct"
|
||||
}
|
||||
}
|
||||
|
|
@ -25,23 +25,37 @@ public class AgentController : ControllerBase
|
|||
[HttpGet("/agent/{id}")]
|
||||
public async Task<AgentViewModel> GetAgent([FromRoute] string id)
|
||||
{
|
||||
var agent = await _agentService.GetAgent(id);
|
||||
return AgentViewModel.FromAgent(agent);
|
||||
var agents = await GetAgents(new AgentFilter
|
||||
{
|
||||
AgentIds = new List<string> { id }
|
||||
});
|
||||
return agents.Items.First();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("/agents")]
|
||||
public async Task<PagedItems<AgentViewModel>> GetAgents([FromQuery] AgentFilter filter)
|
||||
{
|
||||
var agentSetting = _services.GetRequiredService<AgentSettings>();
|
||||
var pagedAgents = await _agentService.GetAgents(filter);
|
||||
|
||||
// prerender agent
|
||||
var items = new List<Agent>();
|
||||
foreach (var agent in pagedAgents.Items)
|
||||
{
|
||||
var renderedAgent = await _agentService.LoadAgent(agent.Id);
|
||||
items.Add(renderedAgent);
|
||||
}
|
||||
|
||||
// Set IsHost
|
||||
var agents = items.Select(x => AgentViewModel.FromAgent(x)).ToList();
|
||||
foreach(var agent in agents)
|
||||
{
|
||||
agent.IsHost = agentSetting.HostAgentId == agent.Id;
|
||||
}
|
||||
|
||||
return new PagedItems<AgentViewModel>
|
||||
{
|
||||
Items = items.Select(x => AgentViewModel.FromAgent(x)).ToList(),
|
||||
Items = agents,
|
||||
Count = pagedAgents.Count
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class ConversationController : ControllerBase
|
|||
var conversations = await service.GetConversations(filter);
|
||||
|
||||
var userService = _services.GetRequiredService<IUserService>();
|
||||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
var list = conversations.Items
|
||||
.Select(x => ConversationViewModel.FromSession(x))
|
||||
.ToList();
|
||||
|
|
@ -45,6 +46,9 @@ public class ConversationController : ControllerBase
|
|||
{
|
||||
var user = await userService.GetUser(item.User.Id);
|
||||
item.User = UserViewModel.FromUser(user);
|
||||
|
||||
var agent = await agentService.GetAgent(item.AgentId);
|
||||
item.AgentName = agent.Name;
|
||||
}
|
||||
|
||||
return new PagedItems<ConversationViewModel>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ public class AgentViewModel
|
|||
Responses = agent.Responses,
|
||||
Samples = agent.Samples,
|
||||
IsPublic= agent.IsPublic,
|
||||
IsHost = agent.IsHost,
|
||||
Disabled = agent.Disabled,
|
||||
IconUrl = agent.IconUrl,
|
||||
Profiles = agent.Profiles ?? new List<string>(),
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ public class ConversationViewModel
|
|||
[JsonPropertyName("agent_id")]
|
||||
public string AgentId { get; set; }
|
||||
|
||||
[JsonPropertyName("agent_name")]
|
||||
public string AgentName { get; set; }
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public UserViewModel User { get; set; } = new UserViewModel();
|
||||
|
||||
[JsonPropertyName("unread_msg_count")]
|
||||
public int UnreadMsgCount { get; set; }
|
||||
|
||||
public string Event { get; set; }
|
||||
|
||||
public string Channel { get; set; } = ConversationChannel.OpenAPI;
|
||||
|
|
|
|||
|
|
@ -9,5 +9,11 @@
|
|||
"profiles": [ "default" ],
|
||||
"llmConfig": {
|
||||
"max_recursion_depth": 10
|
||||
}
|
||||
},
|
||||
"routingRules": [
|
||||
{
|
||||
"type": "fallback",
|
||||
"redirectTo": "01e2fc5c-2c89-4ec7-8470-7688608b496c"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -20,6 +20,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\agent.json" />
|
||||
<None Remove="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\templates\task.place_pizza_order.liquid" />
|
||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\agent.json" />
|
||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\functions.json" />
|
||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\instruction.liquid" />
|
||||
|
|
@ -27,11 +29,6 @@
|
|||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions.json" />
|
||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\instruction.liquid" />
|
||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\responses\func.get_pizza_price.0.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\agent.json" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\instruction.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.executor.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.reviewer.liquid" />
|
||||
<None Remove="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\task.place_pizza_order.liquid" />
|
||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\agent.json" />
|
||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\functions.json" />
|
||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\instruction.liquid" />
|
||||
|
|
@ -42,6 +39,12 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\agent.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\templates\task.place_pizza_order.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\agent.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
@ -63,21 +66,6 @@
|
|||
<Content Include="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\responses\func.get_pizza_price.0.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\agent.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\instruction.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.executor.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\instruction.reviewer.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\dfd9b46d-d00c-40af-8a75-3fbdc2b89869\templates\task.place_pizza_order.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\agent.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
@ -105,8 +93,4 @@
|
|||
<ProjectReference Include="..\..\src\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="data\agents\NewFolder\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class PizzaBotPlugin : IBotSharpPlugin
|
|||
public string IconUrl => "https://cdn-icons-png.flaticon.com/512/6978/6978255.png";
|
||||
public string[] AgentIds => new[]
|
||||
{
|
||||
"8970b1e5-d260-4e2c-90b1-f1415a257c18",
|
||||
"b284db86-e9c2-4c25-a59e-4649797dd130",
|
||||
"c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd",
|
||||
"dfd9b46d-d00c-40af-8a75-3fbdc2b89869",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"id": "8970b1e5-d260-4e2c-90b1-f1415a257c18",
|
||||
"name": "Pizza Bot",
|
||||
"description": "AI assistant that can help customer place pizza order.",
|
||||
"type": "routing",
|
||||
"createdDateTime": "2023-08-18T10:39:32.2349685Z",
|
||||
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
|
||||
"iconUrl": "https://cdn-icons-png.flaticon.com/512/6978/6978255.png",
|
||||
"disabled": true,
|
||||
"isPublic": true,
|
||||
"profiles": [ "pizza" ],
|
||||
"routingRules": [
|
||||
{
|
||||
"type": "planner",
|
||||
"field": "NaviePlanner"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
"createdDateTime": "2023-08-18T14:39:32.2349685Z",
|
||||
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
|
||||
"id": "b284db86-e9c2-4c25-a59e-4649797dd130",
|
||||
"allowRouting": true,
|
||||
"disabled": true,
|
||||
"isPublic": true,
|
||||
"profiles": [ "pizza" ],
|
||||
"routingRules": [
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"createdDateTime": "2023-07-26T02:29:25.123224Z",
|
||||
"updatedDateTime": "2023-07-26T02:29:25.123274Z",
|
||||
"id": "c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd",
|
||||
"allowRouting": true,
|
||||
"disabled": true,
|
||||
"isPublic": true,
|
||||
"profiles": [ "pizza" ]
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "EvaluationAgent",
|
||||
"description": "Evaluate the performance of the LLM agents",
|
||||
"createdDateTime": "2023-08-18T00:00:00Z",
|
||||
"updatedDateTime": "2023-08-18T00:00:00Z",
|
||||
"id": "dfd9b46d-d00c-40af-8a75-3fbdc2b89869",
|
||||
"llmConfig": {
|
||||
"model": "gpt-35-turbo-instruct"
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,9 @@
|
|||
"createdDateTime": "2023-07-26T02:29:25.123224Z",
|
||||
"updatedDateTime": "2023-07-26T02:29:25.123274Z",
|
||||
"id": "fe8c60aa-b114-4ef3-93cb-a8efeac80f75",
|
||||
"allowRouting": true,
|
||||
"disabled": true,
|
||||
"isPublic": true,
|
||||
"profiles": [ "pizza" ],
|
||||
"routingRules": [
|
||||
{
|
||||
"field": "order_number",
|
||||
|
|
|
|||
Loading…
Reference in a new issue