diff --git a/docs/architecture/assets/diagram.drawio b/docs/architecture/assets/diagram.drawio
index 95fe5504..1170e476 100644
--- a/docs/architecture/assets/diagram.drawio
+++ b/docs/architecture/assets/diagram.drawio
@@ -1 +1,70 @@
-zZVdb4MgFIZ/jZdNFLraXbau3W72kXTLromcCimCo3Ta/frBxFq1TdZkSZcYA+85HOB5EQOc5NW9JgV7VBREgEJaBfguQCgaIxS4J6T7WomnYS1kmlOf1Aor/gVebNJ2nMK2k2iUEoYXXTFVUkJqOhrRWpXdtLUS3VkLksFAWKVEDNV3Tg2r1SmKW/0BeMaamaPJbR3JSZPsd7JlhKrySMKLACdaKVO38ioB4eA1XOpxyzPRw8I0SPObAZundLwc4dnHm6axmC03rxUa+SqfROz8hhNGjF+w2TcUtNpJCq5QFOB5ybiBVUFSFy2t71ZjJhc+7EuCNlCdXWt0IGCPDqgcjN7bFD8AjT20fa9fth5EDVh2xH/iNeJtzw6lWzK24eFcAAoNQL0wJeHqpMb/jhQekHp2nMK5JlxenRfu8cLxtXnFpz5BRypUa/uaZXZn2wE3S8B04WyNVhtIlFDaKtIdTjxfcyF6EhE8k7ab2rpg9bnjye2NN/OBnFPqpjnpRutX+DeGRLhnyPRmYMjkhB/4cj9st71uf2JHPy28+AY=
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/architecture/routing.md b/docs/architecture/routing.md
new file mode 100644
index 00000000..9cacce5a
--- /dev/null
+++ b/docs/architecture/routing.md
@@ -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.
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 4dc4cdbd..0c1f23f8 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -36,7 +36,7 @@ The main documentation for the site is organized into the following sections:
.. _get-started:
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
:caption: Get Started with BotSharp
quick-start/overview
@@ -45,7 +45,7 @@ The main documentation for the site is organized into the following sections:
.. _agent-docs:
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
:caption: Agent & Conversation
agent/intro
@@ -55,7 +55,7 @@ The main documentation for the site is organized into the following sections:
.. _integration-docs:
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
:caption: Interactive Channels
channels/intro
@@ -65,7 +65,7 @@ The main documentation for the site is organized into the following sections:
.. _knowledge-base:
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
:caption: Knowledge Base
knowledge-base/text-embedding
@@ -76,7 +76,7 @@ The main documentation for the site is organized into the following sections:
.. _llm:
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
:caption: Prompt Engineering
prompt/prompt
@@ -87,12 +87,13 @@ The main documentation for the site is organized into the following sections:
.. _architecture-docs:
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
:caption: Architecture:
architecture/authentication
architecture/plugin
architecture/hooks
+ architecture/routing
architecture/data-persistence
If you feel that this project is helpful to you, please Star us on the project, we will be very grateful.
diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs
index 80cd6984..48107244 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs
@@ -30,4 +30,6 @@ public interface IConversationService
List GetDialogHistory(string conversationId, int lastCount = 20);
Task CleanHistory(string agentId);
+
+ Task CallFunctions(RoleDialogModel msg);
}
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs
index 8f962a8c..657a85f9 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs
@@ -12,7 +12,7 @@ public partial class AgentService
var query = from a in db.Agent
join ua in db.UserAgent on a.Id equals ua.AgentId
join u in db.User on ua.UserId equals u.Id
- where u.Id == _user.Id || u.ExternalId == _user.Id
+ where ua.UserId == _user.Id || u.ExternalId == _user.Id || a.IsPublic
select a.ToAgent();
return query.ToList();
}
diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj
index 98079d96..4b2ed83c 100644
--- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj
+++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj
@@ -4,7 +4,7 @@
netstandard2.1
10.0
false
- 0.10.1
+ 0.10.4
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs
index fbd879ed..01b3444b 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs
@@ -4,7 +4,7 @@ namespace BotSharp.Core.Conversations.Services;
public partial class ConversationService
{
- private async Task CallFunctions(RoleDialogModel msg)
+ public async Task CallFunctions(RoleDialogModel msg)
{
var hooks = _services.GetServices()
.OrderBy(x => x.Priority).ToList();
diff --git a/src/Infrastructure/BotSharp.Core/Routing/Simulator.cs b/src/Infrastructure/BotSharp.Core/Routing/Simulator.cs
index 4b8123d5..6e88bc7d 100644
--- a/src/Infrastructure/BotSharp.Core/Routing/Simulator.cs
+++ b/src/Infrastructure/BotSharp.Core/Routing/Simulator.cs
@@ -115,8 +115,20 @@ public class Simulator
RoleDialogModel response = null;
await chatCompletion.GetChatCompletionsAsync(agent, wholeDialogs, async msg
- => response = msg, fn
- => Task.CompletedTask);
+ => response = msg, async fn
+ =>
+ {
+ // execute function
+ // Save states
+ SaveStateByArgs(JsonSerializer.Deserialize(fn.FunctionArgs));
+
+ var conversationService = _services.GetRequiredService();
+ // Call functions
+ await conversationService.CallFunctions(fn);
+
+ response = fn;
+ response.Content = fn.ExecutionResult;
+ });
return response;
}
diff --git a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/ChatCompletionProvider.cs
index 65ad123b..34905b56 100644
--- a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/ChatCompletionProvider.cs
+++ b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/ChatCompletionProvider.cs
@@ -92,6 +92,8 @@ public class ChatCompletionProvider : IChatCompletion
var choice = response.Value.Choices[0];
var message = choice.Message;
+ _logger.LogInformation($"Token Usage: {response.Value.Usage.PromptTokens} prompt + {response.Value.Usage.CompletionTokens} completion = {response.Value.Usage.TotalTokens} total");
+
if (choice.FinishReason == CompletionsFinishReason.FunctionCall)
{
_logger.LogInformation($"[{agent.Name}]: {message.FunctionCall.Name} => {message.FunctionCall.Arguments}");
diff --git a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj
index 82861f2e..d463bacb 100644
--- a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj
+++ b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj
@@ -4,7 +4,7 @@
netstandard2.1
enable
10
- 0.10.1
+ 0.10.2