Skip to content

Commit 247afc4

Browse files
author
Jicheng Lu
committed
Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/merge-origin-agent
2 parents 24f9f30 + 2b1fc99 commit 247afc4

File tree

49 files changed

+768
-250
lines changed

Some content is hidden

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

49 files changed

+768
-250
lines changed

src/Infrastructure/BotSharp.Abstraction/Routing/Planning/IExecutor.cs renamed to src/Infrastructure/BotSharp.Abstraction/Planning/IExecutor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using BotSharp.Abstraction.Functions.Models;
2+
using BotSharp.Abstraction.Routing;
23

3-
namespace BotSharp.Abstraction.Routing.Planning;
4+
namespace BotSharp.Abstraction.Planning;
45

56
public interface IExecutor
67
{
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
using BotSharp.Abstraction.Functions.Models;
2+
13
namespace BotSharp.Abstraction.Planning;
24

35
/// <summary>
46
/// Planning process for Task Agent
7+
/// https://www.promptingguide.ai/techniques/cot
58
/// </summary>
6-
public class ITaskPlanner
9+
public interface ITaskPlanner
710
{
8-
11+
Task<FunctionCallFromLlm> GetNextInstruction(Agent router, string messageId, List<RoleDialogModel> dialogs);
12+
Task<bool> AgentExecuting(Agent router, FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs);
13+
Task<bool> AgentExecuted(Agent router, FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs);
14+
List<RoleDialogModel> BeforeHandleContext(FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs)
15+
=> dialogs;
16+
bool AfterHandleContext(List<RoleDialogModel> dialogs, List<RoleDialogModel> taskAgentDialogs)
17+
=> true;
18+
int MaxLoopCount => 5;
919
}

src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ public interface IBotSharpRepository : IHaveServiceProvider
3232
List<User> GetUserByIds(List<string> ids) => throw new NotImplementedException();
3333
List<User> GetUsersByAffiliateId(string affiliateId) => throw new NotImplementedException();
3434
User? GetUserByUserName(string userName) => throw new NotImplementedException();
35+
Dashboard? GetDashboard(string id = null) => throw new NotImplementedException();
3536
void CreateUser(User user) => throw new NotImplementedException();
3637
void UpdateExistUser(string userId, User user) => throw new NotImplementedException();
3738
void UpdateUserVerified(string userId) => throw new NotImplementedException();
39+
void AddDashboardConversation(string userId, string conversationId) => throw new NotImplementedException();
40+
void RemoveDashboardConversation(string userId, string conversationId) => throw new NotImplementedException();
41+
void UpdateDashboardConversation(string userId, DashboardConversation dashConv) => throw new NotImplementedException();
3842
void UpdateUserVerificationCode(string userId, string verficationCode) => throw new NotImplementedException();
3943
void UpdateUserPassword(string userId, string password) => throw new NotImplementedException();
4044
void UpdateUserEmail(string userId, string email) => throw new NotImplementedException();

src/Infrastructure/BotSharp.Abstraction/Routing/Enums/RuleType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public class RuleType
1212
/// </summary>
1313
public const string DataValidation = "data-validation";
1414

15+
/// <summary>
16+
/// The reasoning approach name for next step
17+
/// </summary>
18+
public const string Reasoner = "reasoner";
19+
1520
/// <summary>
1621
/// The planning approach name for next step
1722
/// </summary>

src/Infrastructure/BotSharp.Abstraction/Routing/Planning/IRoutingPlaner.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using BotSharp.Abstraction.Functions.Models;
2+
3+
namespace BotSharp.Abstraction.Routing.Reasoning;
4+
5+
/// <summary>
6+
/// Reasoning approaches for large language models (LLMs) help enhance their ability to solve complex problems,
7+
/// handle tasks requiring logic, and provide accurate and contextually appropriate responses.
8+
/// </summary>
9+
public interface IRoutingReasoner
10+
{
11+
string Name => "Unnamed Reasoner";
12+
string Description => "Each of these approaches leverages the capabilities of LLMs to reason more effectively, " +
13+
"ensuring better performance and more coherent outputs across various types of complex tasks.";
14+
15+
int MaxLoopCount => 5;
16+
17+
Task<FunctionCallFromLlm> GetNextInstruction(Agent router, string messageId, List<RoleDialogModel> dialogs);
18+
19+
Task<bool> AgentExecuting(Agent router, FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs)
20+
=> Task.FromResult(true);
21+
22+
Task<bool> AgentExecuted(Agent router, FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs)
23+
=> Task.FromResult(true);
24+
25+
List<RoleDialogModel> BeforeHandleContext(FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs)
26+
=> dialogs;
27+
28+
bool AfterHandleContext(List<RoleDialogModel> dialogs, List<RoleDialogModel> taskAgentDialogs)
29+
=> true;
30+
}

src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ public interface IUserService
2929
Task<bool> UpdatePassword(string newPassword, string verificationCode);
3030
Task<DateTime> GetUserTokenExpires();
3131
Task<bool> UpdateUsersIsDisable(List<string> userIds, bool isDisable);
32+
Task<bool> AddDashboardConversation(string userId, string conversationId);
33+
Task<bool> RemoveDashboardConversation(string userId, string conversationId);
34+
Task UpdateDashboardConversation(string userId, DashboardConversation dashConv);
35+
Task<Dashboard?> GetDashboard(string userId);
3236
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
namespace BotSharp.Abstraction.Users.Models;
3+
4+
public class Dashboard
5+
{
6+
public IList<DashboardConversation> ConversationList { get; set; } = [];
7+
}
8+
9+
public class DashboardComponent
10+
{
11+
public required string Id { get; set; }
12+
public string? Name { get; set; }
13+
}
14+
15+
public class DashboardConversation : DashboardComponent
16+
{
17+
public string? ConversationId { get; set; }
18+
public string? Instruction { get; set; } = "";
19+
}
20+

src/Infrastructure/BotSharp.Abstraction/Using.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
global using BotSharp.Abstraction.Infrastructures.Enums;
1313
global using BotSharp.Abstraction.Models;
1414
global using BotSharp.Abstraction.Routing.Models;
15-
global using BotSharp.Abstraction.Routing.Planning;
1615
global using BotSharp.Abstraction.Templating;
1716
global using BotSharp.Abstraction.Translation.Attributes;
1817
global using BotSharp.Abstraction.Messaging.Enums;

src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959

6060
<ItemGroup>
6161
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\database_knowledge.liquid" />
62+
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.hf.liquid" />
63+
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.naive.liquid" />
64+
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.one-step-forward.liquid" />
65+
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.sequential.get_remaining_task.liquid" />
66+
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.sequential.liquid" />
6267
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\agent.json" />
6368
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\instructions\instruction.liquid" />
6469
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\agent.json" />
@@ -73,10 +78,6 @@
7378
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\instructions\instruction.liquid" />
7479
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\.welcome.liquid" />
7580
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\conversation.summary.liquid" />
76-
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.hf.liquid" />
77-
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.naive.liquid" />
78-
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.sequential.get_remaining_task.liquid" />
79-
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.sequential.liquid" />
8081
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\response_with_function.liquid" />
8182
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\translation_prompt.liquid" />
8283
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\select_file_prompt.liquid" />
@@ -120,16 +121,19 @@
120121
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\database_knowledge.liquid">
121122
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
122123
</Content>
123-
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.sequential.get_remaining_task.liquid">
124+
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.sequential.get_remaining_task.liquid">
124125
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
125126
</Content>
126-
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.sequential.liquid">
127+
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.sequential.liquid">
127128
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
128129
</Content>
129-
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.hf.liquid">
130+
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.hf.liquid">
130131
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
131132
</Content>
132-
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\planner_prompt.naive.liquid">
133+
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.naive.liquid">
134+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
135+
</Content>
136+
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\reasoner.one-step-forward.liquid">
133137
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
134138
</Content>
135139
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\response_with_function.liquid">

0 commit comments

Comments
 (0)