Fix package bug.
This commit is contained in:
parent
1ff154c682
commit
25ac948510
|
|
@ -2,7 +2,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
<OutputPath>..\..\..\packages</OutputPath>
|
<OutputPath>..\..\..\packages</OutputPath>
|
||||||
<BotSharpVersion>0.14.1</BotSharpVersion>
|
<BotSharpVersion>0.14.2</BotSharpVersion>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -75,19 +75,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Routing\Prompts\reasoning_functions.liquid" />
|
|
||||||
<None Remove="Routing\router_prompt.liquid" />
|
<None Remove="Routing\router_prompt.liquid" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Include="Routing\Prompts\reasoning_functions.liquid">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="Routing\Prompts\router_prompt.liquid">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\..\arts\Icon.png">
|
<None Include="..\..\..\arts\Icon.png">
|
||||||
<Pack>True</Pack>
|
<Pack>True</Pack>
|
||||||
|
|
|
||||||
72
src/Infrastructure/BotSharp.Core/Routing/PromptConst.cs
Normal file
72
src/Infrastructure/BotSharp.Core/Routing/PromptConst.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
namespace BotSharp.Core.Routing;
|
||||||
|
|
||||||
|
public class PromptConst
|
||||||
|
{
|
||||||
|
public const string ROUTER_PROMPT = @"
|
||||||
|
You're a Router with reasoning, you can dispatch request to different agent to complete the task.
|
||||||
|
|
||||||
|
### Agents:
|
||||||
|
{% for agent in routing_records %}
|
||||||
|
* {{ agent.name }}
|
||||||
|
{{ agent.description }}
|
||||||
|
{% if agent.required_fields != empty -%}Required information: {{ agent.required_fields }}.{%- endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
### Functions
|
||||||
|
{% if enable_reasoning == false -%}
|
||||||
|
* route_to_agent
|
||||||
|
Route request to appropriate agent.
|
||||||
|
Parameters:
|
||||||
|
1. agent_name: the name of the agent;
|
||||||
|
2. reason: why route to this agent;
|
||||||
|
3. args: parameters extracted from context;
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
* task_end
|
||||||
|
Call this function when current task is completed.
|
||||||
|
Parameters:
|
||||||
|
1. abandoned_arguments: the arguments next task can't reuse;
|
||||||
|
|
||||||
|
* conversation_end
|
||||||
|
Call this function when user wants to end this conversation or all tasks have been completed.
|
||||||
|
|
||||||
|
* transfer_to_csr
|
||||||
|
Reach out to a real customer representative to help.
|
||||||
|
|
||||||
|
{{ reasoning_functions }}
|
||||||
|
|
||||||
|
### Your response must meet below requirements strictly
|
||||||
|
{% if enable_reasoning == false %}
|
||||||
|
* If you can find an appropriate Agent, you must call function route_to_agent with required arguments.
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
### Conversation context:";
|
||||||
|
|
||||||
|
public const string REASONING_FUNCTIONS = @"
|
||||||
|
* retrieve_data_from_agent
|
||||||
|
Retrieve data from appropriate agent.
|
||||||
|
Parameters:
|
||||||
|
1. agent_name: the name of the agent;
|
||||||
|
2. question: the question you will ask the agent to get the necessary data;
|
||||||
|
3. reason: why retrieve data;
|
||||||
|
4. args: required parameters extracted from question and hand over to the next agent. The args should be in JSON format;
|
||||||
|
|
||||||
|
* continue_execute_task
|
||||||
|
Continue to execute user's request without further information retrival.
|
||||||
|
Parameters:
|
||||||
|
1. agent_name: the name of the agent;
|
||||||
|
2. args: required parameters extracted from question;
|
||||||
|
3. reason: why continue to execute current task;
|
||||||
|
|
||||||
|
* interrupt_task_execution
|
||||||
|
Can't continue user's request becauase the requirements are not met.
|
||||||
|
Parameters:
|
||||||
|
1. reason: the reason why the request is interrupted;
|
||||||
|
2. answer: the content response to user;
|
||||||
|
|
||||||
|
* response_to_user
|
||||||
|
You have already known the answer according the dialogs.
|
||||||
|
Parameters:
|
||||||
|
1. answer: the response of user's request;
|
||||||
|
2. reason: why response to user;";
|
||||||
|
}
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
* retrieve_data_from_agent
|
|
||||||
Retrieve data from appropriate agent.
|
|
||||||
Parameters:
|
|
||||||
1. agent_name: the name of the agent;
|
|
||||||
2. question: the question you will ask the agent to get the necessary data;
|
|
||||||
3. reason: why retrieve data;
|
|
||||||
4. args: required parameters extracted from question and hand over to the next agent. The args should be in JSON format;
|
|
||||||
|
|
||||||
* continue_execute_task
|
|
||||||
Continue to execute user's request without further information retrival.
|
|
||||||
Parameters:
|
|
||||||
1. agent_name: the name of the agent;
|
|
||||||
2. args: required parameters extracted from question;
|
|
||||||
3. reason: why continue to execute current task;
|
|
||||||
|
|
||||||
* interrupt_task_execution
|
|
||||||
Can't continue user's request becauase the requirements are not met.
|
|
||||||
Parameters:
|
|
||||||
1. reason: the reason why the request is interrupted;
|
|
||||||
2. answer: the content response to user;
|
|
||||||
|
|
||||||
* response_to_user
|
|
||||||
You have already known the answer according the dialogs.
|
|
||||||
Parameters:
|
|
||||||
1. answer: the response of user's request;
|
|
||||||
2. reason: why response to user;
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
You're a Router with reasoning, you can dispatch request to different agent to complete the task.
|
|
||||||
|
|
||||||
### Agents:
|
|
||||||
{% for agent in routing_records %}
|
|
||||||
* {{ agent.name }}
|
|
||||||
{{ agent.description }}
|
|
||||||
{% if agent.required_fields != empty -%}Required information: {{ agent.required_fields }}.{%- endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
### Functions
|
|
||||||
{% if enable_reasoning == false -%}
|
|
||||||
* route_to_agent
|
|
||||||
Route request to appropriate agent.
|
|
||||||
Parameters:
|
|
||||||
1. agent_name: the name of the agent;
|
|
||||||
2. reason: why route to this agent;
|
|
||||||
3. args: parameters extracted from context;
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
* task_end
|
|
||||||
Call this function when current task is completed.
|
|
||||||
Parameters:
|
|
||||||
1. abandoned_arguments: the arguments next task can't reuse;
|
|
||||||
|
|
||||||
* conversation_end
|
|
||||||
Call this function when user wants to end this conversation or all tasks have been completed.
|
|
||||||
|
|
||||||
* transfer_to_csr
|
|
||||||
Reach out to a real customer representative to help.
|
|
||||||
|
|
||||||
{{ reasoning_functions }}
|
|
||||||
|
|
||||||
### Your response must meet below requirements strictly
|
|
||||||
{% if enable_reasoning == false %}
|
|
||||||
* If you can find an appropriate Agent, you must call function route_to_agent with required arguments.
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
### Conversation context:
|
|
||||||
|
|
@ -224,17 +224,14 @@ public class RoutingService : IRoutingService
|
||||||
.ToArray()
|
.ToArray()
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
var dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Routing", "Prompts");
|
|
||||||
var template = File.ReadAllText(Path.Combine(dir, "router_prompt.liquid"));
|
|
||||||
|
|
||||||
dict["enable_reasoning"] = _settings.EnableReasoning;
|
dict["enable_reasoning"] = _settings.EnableReasoning;
|
||||||
if (_settings.EnableReasoning)
|
if (_settings.EnableReasoning)
|
||||||
{
|
{
|
||||||
dict["reasoning_functions"] = File.ReadAllText(Path.Combine(dir, "reasoning_functions.liquid"));
|
dict["reasoning_functions"] = PromptConst.REASONING_FUNCTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
var render = _services.GetRequiredService<ITemplateRender>();
|
var render = _services.GetRequiredService<ITemplateRender>();
|
||||||
router.Instruction = render.Render(template, dict);
|
router.Instruction = render.Render(PromptConst.ROUTER_PROMPT, dict);
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>$(LangVersion)</LangVersion>
|
<LangVersion>$(LangVersion)</LangVersion>
|
||||||
<VersionPrefix>$(PackageVersion)</VersionPrefix>
|
<VersionPrefix>$(BotSharpVersion)</VersionPrefix>
|
||||||
<GeneratePackageOnBuild>$(GeneratePackageOnBuild)</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>$(GeneratePackageOnBuild)</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,17 @@
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>$(LangVersion)</LangVersion>
|
<LangVersion>$(LangVersion)</LangVersion>
|
||||||
|
<VersionPrefix>$(BotSharpVersion)</VersionPrefix>
|
||||||
|
<GeneratePackageOnBuild>$(GeneratePackageOnBuild)</GeneratePackageOnBuild>
|
||||||
<OutputPath>..\..\packages</OutputPath>
|
<OutputPath>..\..\packages</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="$(SolutionName)==PizzaBot">
|
||||||
|
<PackageReference Include="BotSharp.Core" Version="$(BotSharpVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BotSharp.Core" Version="0.12.2" />
|
<ProjectReference Include="..\..\src\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
using BotSharp.Abstraction.Conversations.Models;
|
|
||||||
|
|
||||||
namespace BotSharp.Plugin.PizzaBot.Functions;
|
|
||||||
|
|
||||||
public class OrderFoundFn : IFunctionCallback
|
|
||||||
{
|
|
||||||
public string Name => "order_found";
|
|
||||||
|
|
||||||
public async Task<bool> Execute(RoleDialogModel message)
|
|
||||||
{
|
|
||||||
message.ExecutionResult = "The order number is P123-01";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -11,7 +11,6 @@ public class PizzaBotPlugin : IBotSharpPlugin
|
||||||
services.AddScoped<IFunctionCallback, GetPizzaTypesFn>();
|
services.AddScoped<IFunctionCallback, GetPizzaTypesFn>();
|
||||||
services.AddScoped<IFunctionCallback, GetPizzaPricesFn>();
|
services.AddScoped<IFunctionCallback, GetPizzaPricesFn>();
|
||||||
services.AddScoped<IFunctionCallback, PlaceOrderFn>();
|
services.AddScoped<IFunctionCallback, PlaceOrderFn>();
|
||||||
services.AddScoped<IFunctionCallback, OrderFoundFn>();
|
|
||||||
services.AddScoped<IFunctionCallback, GetOrderStatusFn>();
|
services.AddScoped<IFunctionCallback, GetOrderStatusFn>();
|
||||||
services.AddScoped<IFunctionCallback, MakePaymentFn>();
|
services.AddScoped<IFunctionCallback, MakePaymentFn>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue