Fix reasoner function call.

This commit is contained in:
Haiping Chen 2023-09-03 21:45:31 -05:00
parent bf51213a5a
commit 147aa944da
8 changed files with 99 additions and 12 deletions

View file

@ -1 +1,70 @@
<mxfile host="app.diagrams.net" modified="2023-08-15T02:10:02.985Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" version="20.6.0" etag="WycAnBgN-yxZpTCzoOFG" type="device"><diagram id="6jfvZ688tm8pOZHgqSFM" name="Page-1">zZVdb4MgFIZ/jZdNFLraXbau3W72kXTLromcCimCo3Ta/frBxFq1TdZkSZcYA+85HOB5EQOc5NW9JgV7VBREgEJaBfguQCgaIxS4J6T7WomnYS1kmlOf1Aor/gVebNJ2nMK2k2iUEoYXXTFVUkJqOhrRWpXdtLUS3VkLksFAWKVEDNV3Tg2r1SmKW/0BeMaamaPJbR3JSZPsd7JlhKrySMKLACdaKVO38ioB4eA1XOpxyzPRw8I0SPObAZundLwc4dnHm6axmC03rxUa+SqfROz8hhNGjF+w2TcUtNpJCq5QFOB5ybiBVUFSFy2t71ZjJhc+7EuCNlCdXWt0IGCPDqgcjN7bFD8AjT20fa9fth5EDVh2xH/iNeJtzw6lWzK24eFcAAoNQL0wJeHqpMb/jhQekHp2nMK5JlxenRfu8cLxtXnFpz5BRypUa/uaZXZn2wE3S8B04WyNVhtIlFDaKtIdTjxfcyF6EhE8k7ab2rpg9bnjye2NN/OBnFPqpjnpRutX+DeGRLhnyPRmYMjkhB/4cj9st71uf2JHPy28+AY=</diagram></mxfile> <mxfile host="Electron" modified="2023-09-04T01:23:28.461Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.8 Chrome/114.0.5735.289 Electron/25.5.0 Safari/537.36" etag="A6frJLpTHNKz4FBL38kf" version="21.6.8" type="device">
<diagram id="6jfvZ688tm8pOZHgqSFM" name="Page-1">
<mxGraphModel dx="1434" dy="836" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="kNc4F-3AqUrd7lAFkTx2-3" value="BotSharp&lt;br&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Agent&lt;br&gt;Conversation&lt;br&gt;Routing&lt;/span&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;fontStyle=1" parent="1" vertex="1">
<mxGeometry x="345.71" y="340" width="214.29" height="60" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-7" value="&lt;b&gt;Phone&amp;nbsp;Voice&lt;/b&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="240" y="240" width="90" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-8" value="&lt;b&gt;Web Chat&lt;/b&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="360" y="240" width="90" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-9" value="&lt;b&gt;Message&lt;/b&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="474" y="240" width="90" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-10" value="&lt;b&gt;Open API&lt;/b&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="590" y="240" width="90" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-11" value="&lt;h1&gt;BotSharp AI Orchestration&lt;/h1&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" vertex="1" parent="1">
<mxGeometry x="50" y="50" width="310" height="120" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-12" value="&lt;b&gt;Knowlege Base&lt;/b&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#eeeeee;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="270" y="670" width="60" height="80" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-13" value="&lt;b&gt;Knowledge&lt;/b&gt;&lt;br&gt;RAG" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="240" y="565" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-14" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;labelPosition=left;verticalLabelPosition=middle;align=right;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry x="150" y="260" width="20" height="450" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-15" value="&lt;b&gt;&lt;br&gt;&lt;br&gt;Agent&lt;/b&gt;" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="345.71" y="450" width="42.86" height="50" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-16" value="&lt;b&gt;&lt;br&gt;&lt;br&gt;Agent&lt;/b&gt;" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="431.43" y="450" width="42.86" height="50" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-17" value="&lt;b&gt;&lt;br&gt;&lt;br&gt;Agent&lt;/b&gt;" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="517.14" y="450" width="42.86" height="50" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-18" value="&lt;b&gt;Meta Messenger&lt;/b&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="381.43" y="565" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-19" value="&lt;b&gt;Data Storage&lt;/b&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="520" y="565" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-20" value="&lt;b&gt;Storage&lt;/b&gt;" style="shape=datastore;whiteSpace=wrap;html=1;fillColor=#eeeeee;strokeColor=#36393d;" vertex="1" parent="1">
<mxGeometry x="550" y="680" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-22" value="&lt;b&gt;UI/ UX&lt;/b&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="60" y="250" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-25" value="&lt;b&gt;Kernel&lt;/b&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="60" y="355" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-26" value="&lt;b&gt;Agent&lt;/b&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="60" y="460" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-27" value="&lt;b&gt;Plugin&lt;/b&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="60" y="565" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="9DShFkwYbzccSmdIPQ0x-28" value="&lt;b&gt;Data Storage&lt;/b&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="60" y="680" width="60" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View file

@ -0,0 +1,3 @@
# Routing
Routing is an important function that allows multiple Agents to work together to complete enterprise-level tasks. When you apply LLM to your business system, it is inevitable to develop agents with different functions. How to effectively manage so many agents with different responsibilities is a challenging task. From an engineering perspective, each Different teams are responsible for the development of different Agents, and the teams will face the problem of mutual isolation between Agents. The ideal situation is that they can be developed independently but cooperate with each other.

View file

@ -36,7 +36,7 @@ The main documentation for the site is organized into the following sections:
.. _get-started: .. _get-started:
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 2
:caption: Get Started with BotSharp :caption: Get Started with BotSharp
quick-start/overview quick-start/overview
@ -45,7 +45,7 @@ The main documentation for the site is organized into the following sections:
.. _agent-docs: .. _agent-docs:
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 2
:caption: Agent & Conversation :caption: Agent & Conversation
agent/intro agent/intro
@ -55,7 +55,7 @@ The main documentation for the site is organized into the following sections:
.. _integration-docs: .. _integration-docs:
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 2
:caption: Interactive Channels :caption: Interactive Channels
channels/intro channels/intro
@ -65,7 +65,7 @@ The main documentation for the site is organized into the following sections:
.. _knowledge-base: .. _knowledge-base:
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 2
:caption: Knowledge Base :caption: Knowledge Base
knowledge-base/text-embedding knowledge-base/text-embedding
@ -76,7 +76,7 @@ The main documentation for the site is organized into the following sections:
.. _llm: .. _llm:
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 2
:caption: Prompt Engineering :caption: Prompt Engineering
prompt/prompt prompt/prompt
@ -87,12 +87,13 @@ The main documentation for the site is organized into the following sections:
.. _architecture-docs: .. _architecture-docs:
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 2
:caption: Architecture: :caption: Architecture:
architecture/authentication architecture/authentication
architecture/plugin architecture/plugin
architecture/hooks architecture/hooks
architecture/routing
architecture/data-persistence architecture/data-persistence
If you feel that this project is helpful to you, please Star us on the project, we will be very grateful. If you feel that this project is helpful to you, please Star us on the project, we will be very grateful.

View file

@ -30,4 +30,6 @@ public interface IConversationService
List<RoleDialogModel> GetDialogHistory(string conversationId, int lastCount = 20); List<RoleDialogModel> GetDialogHistory(string conversationId, int lastCount = 20);
Task CleanHistory(string agentId); Task CleanHistory(string agentId);
Task CallFunctions(RoleDialogModel msg);
} }

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<VersionPrefix>0.10.1</VersionPrefix> <VersionPrefix>0.10.3</VersionPrefix>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">

View file

@ -4,7 +4,7 @@ namespace BotSharp.Core.Conversations.Services;
public partial class ConversationService public partial class ConversationService
{ {
private async Task CallFunctions(RoleDialogModel msg) public async Task CallFunctions(RoleDialogModel msg)
{ {
var hooks = _services.GetServices<IConversationHook>() var hooks = _services.GetServices<IConversationHook>()
.OrderBy(x => x.Priority).ToList(); .OrderBy(x => x.Priority).ToList();

View file

@ -115,8 +115,20 @@ public class Simulator
RoleDialogModel response = null; RoleDialogModel response = null;
await chatCompletion.GetChatCompletionsAsync(agent, wholeDialogs, async msg await chatCompletion.GetChatCompletionsAsync(agent, wholeDialogs, async msg
=> response = msg, fn => response = msg, async fn
=> Task.CompletedTask); =>
{
// execute function
// Save states
SaveStateByArgs(JsonSerializer.Deserialize<JsonDocument>(fn.FunctionArgs));
var conversationService = _services.GetRequiredService<IConversationService>();
// Call functions
await conversationService.CallFunctions(fn);
response = fn;
response.Content = fn.ExecutionResult;
});
return response; return response;
} }

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<VersionPrefix>0.10.1</VersionPrefix> <VersionPrefix>0.10.2</VersionPrefix>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>