Skip to content

Commit 083f2ce

Browse files
author
jason
committed
Merge remote-tracking branch 'origin/master' into jason_dev
2 parents f4a1765 + 92994da commit 083f2ce

File tree

181 files changed

+2673
-645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+2673
-645
lines changed

BotSharp.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Core.SideCar", "sr
121121
EndProject
122122
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.VertexAI", "src\Plugins\BotSharp.Plugin.LangChain\BotSharp.Plugin.VertexAI.csproj", "{7DA2DCD0-551B-432E-AA5C-22DDD3ED459B}"
123123
EndProject
124+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Crontab", "src\Infrastructure\BotSharp.Core.Crontab\BotSharp.Core.Crontab.csproj", "{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}"
125+
EndProject
124126
Global
125127
GlobalSection(SolutionConfigurationPlatforms) = preSolution
126128
Debug|Any CPU = Debug|Any CPU
@@ -489,6 +491,14 @@ Global
489491
{7DA2DCD0-551B-432E-AA5C-22DDD3ED459B}.Release|Any CPU.Build.0 = Release|Any CPU
490492
{7DA2DCD0-551B-432E-AA5C-22DDD3ED459B}.Release|x64.ActiveCfg = Release|Any CPU
491493
{7DA2DCD0-551B-432E-AA5C-22DDD3ED459B}.Release|x64.Build.0 = Release|Any CPU
494+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
495+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Debug|Any CPU.Build.0 = Debug|Any CPU
496+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Debug|x64.ActiveCfg = Debug|Any CPU
497+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Debug|x64.Build.0 = Debug|Any CPU
498+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Release|Any CPU.ActiveCfg = Release|Any CPU
499+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Release|Any CPU.Build.0 = Release|Any CPU
500+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Release|x64.ActiveCfg = Release|Any CPU
501+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F}.Release|x64.Build.0 = Release|Any CPU
492502
EndGlobalSection
493503
GlobalSection(SolutionProperties) = preSolution
494504
HideSolutionNode = FALSE
@@ -547,6 +557,7 @@ Global
547557
{F57F4862-F8D4-44A1-AC12-5C131B5C9785} = {51AFE054-AE99-497D-A593-69BAEFB5106F}
548558
{6D3A54F9-4792-41DB-BE7D-4F7B1D918EAE} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
549559
{7DA2DCD0-551B-432E-AA5C-22DDD3ED459B} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
560+
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
550561
EndGlobalSection
551562
GlobalSection(ExtensibilityGlobals) = postSolution
552563
SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19}

docs/architecture/agent-utility.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This document aims to introduce the agent utility concept and provide an instruction on adding custom agent utilities in AI project “BotSharp”. We will start by explaining the mechanism of agent utility in [Section 2](#agent-utility). Then, we illustrate the custom agent utility setup and integration in [Section 3](#agent-utility-setup) and [Section 4](#agent-utility-integration), respectively. A use case will be demonstrated in [Section 5](#use-case-demo). We wrap up the document with a short summary.
55

66
## Agent Utility
7-
The agent utility is a unique feature that can be integrated into agent to enhance its capability. Its core principle is that it can dynamically and seamlessly add extra prompts and add task-oriented functions (or tools) during conversation, without disrupting the agent’s primary purpose. In other words, the agent utility can perform extra tasks based on the context of conversation. Typical examples of agent utility include reading images/pdf, generating image, and sending http requests. [Fig 2.1.1](#agent-utility-example) demonstrates an example of these utilities. In this example, “Chatbot” is a simple agent to answer user questions and the utilities extend its capability to explain image content, generate requested image, and send a specific http request.
7+
The agent utility is a unique feature that can be integrated into agent to enhance its capability. Its core principle is that it can dynamically and seamlessly add extra prompts and add task-oriented functions (or tools) during conversation, without disrupting the agent’s primary purpose. In other words, the agent utility can perform extra tasks based on the context of conversation. Typical examples of agent utility include reading images/pdf, generating image, and sending http requests. [Fig 2.1.1](#agent-utility-example) demonstrates an example of these utilities. In this example, “Chatbot” is a simple agent to answer user questions, and the utilities extend its capability to explain image content, generate requested image, and send a specific http request.
88

99
<div id="agent-utility-example">
1010
<img src="assets/agent-utility/agent-utility-example.png" style="display: block; margin: auto;" />
@@ -15,15 +15,15 @@ The agent utility is a unique feature that can be integrated into agent to enhan
1515
In this section, we outline the steps to set up a custom agent utility. We start with the basic code structure and then add essential utility data, such as prompts and functions. The utility hooks are used to incorporate the utility into the agent. Finally, we give a brief overview of the utility implementation.
1616

1717
### Basic Code Structure
18-
The basic code structure of a typical agent utility includes prompt/function data, hooks, and function implementation. We can add specific utility prompts and functions in different projects. Note that the agent “6745151e-6d46-4a02-8de4-1c4f21c7da95” is considered as a dedicated utility assistant, and every prompt and function can be optionally used as a utility. [Fig 3.1.1](#agent-utility-code-structure) presents the structure of prompt, function, hooks, and implementation of an http utility.
18+
The basic code structure of a typical agent utility includes prompt/function data, hooks, and function implementation. We can add specific utility prompts and functions in different projects. Note that the agent **“6745151e-6d46-4a02-8de4-1c4f21c7da95”** is considered as a dedicated utility assistant, and every prompt and function can be optionally used as a utility. [Fig 3.1.1](#agent-utility-code-structure) presents the structure of prompt, function, hooks, and implementation of an http utility.
1919

2020
<div id="agent-utility-code-structure">
2121
<img src="assets/agent-utility/agent-utility-code-structure.png" style="display: block; margin: auto;" />
2222
</div>
2323
<br />
2424

2525
### Utility Data
26-
For a typical agent utility, it is essential to add at least a prompt and a function. The prompt is added under the “templates” folder and its recommended name is [function name].fn.liquid”, while the function is added under the “functions” folder and its recommended name is [function name].json”. Once we compile the project, we can find the aggregated utility assistant folder at location: “\BotSharp\src\WebStarter\bin\Debug\net8.0\data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95”.
26+
For a typical agent utility, it is essential to add at least one prompt and one function. The utility name is formatted as **[plugin name].[utility name]**, such as “http.http-handler”. The prompt is added under the “templates” folder and its recommended name is **“util-[plugin name]-[function name].fn.liquid”**, while the function is added under the “functions” folder and its recommended name is **“util-[plugin name]-[function name].json”**. Once we compile the project, we can find the aggregated utility assistant folder at location: **“\BotSharp\src\WebStarter\bin\Debug\net8.0\data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95”**.
2727

2828
### Utility Hooks
2929
The utility hooks are used to connect the agent utility to the agent system. The code snippet below demonstrates an implementation of the http utility hook, where we define the utility name, prompts and functions. Note that each utility can be used across different agents.
@@ -50,7 +50,7 @@ public class HttpHandlerPlugin : IBotSharpPlugin
5050
}
5151
```
5252

53-
The agent hook is used to append the utility prompt and function during the conversation. Note that the utility data is only allowed to be included in the context of conversation. The utility mechanism is implemented in the “OnAgentUtilityLoaded” hook, and it is invoked when we load any agent.
53+
The agent hook is used to append the utility prompt and function during the conversation. **Note that the utility data is only allowed to be included in the context of conversation**. The utility mechanism is implemented in the **“OnAgentUtilityLoaded”** hook, and it is invoked when we load any agent.
5454

5555
```csharp
5656
public async Task<Agent> LoadAgent(string id)
@@ -128,7 +128,7 @@ Here we introduce a simple utility function implementation. The actual content d
128128
```csharp
129129
public class HandleHttpRequestFn : IFunctionCallback
130130
{
131-
public string Name => "handle_http_request";
131+
public string Name => "util-http-handle_http_request";
132132
public string Indication => "Handling http request";
133133

134134
private readonly IServiceProvider _services;
@@ -344,12 +344,12 @@ Here we introduce the agent setup with utilities and inheritance. As we introduc
344344
"profiles": [ "pizza" ],
345345
"utilities": [
346346
{
347-
"name": "http_handler",
347+
"name": "http.http-handler",
348348
"functions": [
349-
{ "name": "handle_http_request" }
349+
{ "name": "util-http-handle_http_request" }
350350
],
351351
"templates": [
352-
{ "name": "handle_http_request.fn" }
352+
{ "name": "util-http-handle_http_request.fn" }
353353
]
354354
}
355355
],
-1.06 KB
Loading
-5.72 KB
Loading
-2.12 KB
Loading

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public enum AgentField
1717
Response,
1818
Sample,
1919
LlmConfig,
20-
Utility
20+
Utility,
21+
KnowledgeBase,
22+
MaxMessageCount
2123
}
2224

2325
public enum AgentTaskField

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentRole.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ public class AgentRole
66
public const string Assistant = "assistant";
77
public const string User = "user";
88
public const string Function = "function";
9+
public const string Model = "model";
910
}

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class AgentType
1010
/// <summary>
1111
/// Planning agent
1212
/// </summary>
13-
public const string Planning = "plan";
13+
public const string Planning = "planning";
1414

1515
public const string Evaluating = "evaluation";
1616

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/BuiltInAgentId.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public class BuiltInAgentId
3232
/// </summary>
3333
public const string Learner = "01acc3e5-0af7-49e6-ad7a-a760bd12dc40";
3434

35-
/// <summary>
36-
/// Plan feasible implementation steps for complex problems
37-
/// </summary>
38-
public const string Planner = "282a7128-69a1-44b0-878c-a9159b88f3b9";
39-
4035
/// <summary>
4136
/// SQL statement generation
4237
/// </summary>

src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IAgentService
1818
/// </summary>
1919
/// <param name="id"></param>
2020
/// <returns></returns>
21-
Task<Agent> LoadAgent(string id);
21+
Task<Agent> LoadAgent(string id, bool loadUtility = true);
2222

2323
/// <summary>
2424
/// Inherit from an agent

0 commit comments

Comments
 (0)