Skip to content

Commit 82b169a

Browse files
authored
Merge pull request #978 from iceljc/master
refine instruction and mcp
2 parents 1ddbc33 + adfb8f4 commit 82b169a

File tree

47 files changed

+487
-355
lines changed

Some content is hidden

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

47 files changed

+487
-355
lines changed

BotSharp.sln

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Rules", "src\
127127
EndProject
128128
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.DeepSeekAI", "src\Plugins\BotSharp.Plugin.DeepSeekAI\BotSharp.Plugin.DeepSeekAI.csproj", "{AF329442-B48E-4B48-A18A-1C869D1BA6F5}"
129129
EndProject
130-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.MCP", "src\Infrastructure\BotSharp.MCP\BotSharp.MCP.csproj", "{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}"
131-
EndProject
132130
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Realtime", "src\Infrastructure\BotSharp.Core.Realtime\BotSharp.Core.Realtime.csproj", "{781F1465-365C-0F22-1775-25025DAFA4C7}"
133131
EndProject
134132
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.PizzaBot.MCPServer", "tests\BotSharp.PizzaBot.MCPServer\BotSharp.PizzaBot.MCPServer.csproj", "{8D2AD45F-836A-516F-DE6A-71443CEBB18A}"
135133
EndProject
134+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.MCP", "src\Infrastructure\BotSharp.Core.MCP\BotSharp.Core.MCP.csproj", "{534D1DD5-9D62-115C-F230-47080D76CE52}"
135+
EndProject
136136
Global
137137
GlobalSection(SolutionConfigurationPlatforms) = preSolution
138138
Debug|Any CPU = Debug|Any CPU
@@ -525,14 +525,6 @@ Global
525525
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|Any CPU.Build.0 = Release|Any CPU
526526
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|x64.ActiveCfg = Release|Any CPU
527527
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|x64.Build.0 = Release|Any CPU
528-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
529-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
530-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Debug|x64.ActiveCfg = Debug|Any CPU
531-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Debug|x64.Build.0 = Debug|Any CPU
532-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
533-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Release|Any CPU.Build.0 = Release|Any CPU
534-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Release|x64.ActiveCfg = Release|Any CPU
535-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C}.Release|x64.Build.0 = Release|Any CPU
536528
{781F1465-365C-0F22-1775-25025DAFA4C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
537529
{781F1465-365C-0F22-1775-25025DAFA4C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
538530
{781F1465-365C-0F22-1775-25025DAFA4C7}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -549,6 +541,14 @@ Global
549541
{8D2AD45F-836A-516F-DE6A-71443CEBB18A}.Release|Any CPU.Build.0 = Release|Any CPU
550542
{8D2AD45F-836A-516F-DE6A-71443CEBB18A}.Release|x64.ActiveCfg = Release|Any CPU
551543
{8D2AD45F-836A-516F-DE6A-71443CEBB18A}.Release|x64.Build.0 = Release|Any CPU
544+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
545+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|Any CPU.Build.0 = Debug|Any CPU
546+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|x64.ActiveCfg = Debug|Any CPU
547+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|x64.Build.0 = Debug|Any CPU
548+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|Any CPU.ActiveCfg = Release|Any CPU
549+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|Any CPU.Build.0 = Release|Any CPU
550+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|x64.ActiveCfg = Release|Any CPU
551+
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|x64.Build.0 = Release|Any CPU
552552
EndGlobalSection
553553
GlobalSection(SolutionProperties) = preSolution
554554
HideSolutionNode = FALSE
@@ -610,9 +610,9 @@ Global
610610
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
611611
{AFD64412-4D6A-452E-82A2-79E5D8842E29} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
612612
{AF329442-B48E-4B48-A18A-1C869D1BA6F5} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
613-
{684781D5-3DD4-6A0B-B53F-0A362CD6BB0C} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
614613
{781F1465-365C-0F22-1775-25025DAFA4C7} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
615614
{8D2AD45F-836A-516F-DE6A-71443CEBB18A} = {32FAFFFE-A4CB-4FEE-BF7C-84518BBC6DCC}
615+
{534D1DD5-9D62-115C-F230-47080D76CE52} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
616616
EndGlobalSection
617617
GlobalSection(ExtensibilityGlobals) = postSolution
618618
SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public virtual void OnAgentUtilityLoaded(Agent agent)
6060

6161
}
6262

63-
public virtual void OnAgentMCPToolLoaded(Agent agent)
63+
public virtual void OnAgentMcpToolLoaded(Agent agent)
6464
{
6565

6666
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface IAgentHook
2727

2828
void OnAgentUtilityLoaded(Agent agent);
2929

30-
void OnAgentMCPToolLoaded(Agent agent);
30+
void OnAgentMcpToolLoaded(Agent agent);
3131

3232
/// <summary>
3333
/// Triggered when agent is loaded completely.

src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class Agent
107107
/// <summary>
108108
/// Agent MCP Tools
109109
/// </summary>
110-
public List<MCPTool> McpTools { get; set; } = new();
110+
public List<McpTool> McpTools { get; set; } = new();
111111

112112
/// <summary>
113113
/// Agent rules
@@ -305,7 +305,7 @@ public Agent SetLlmConfig(AgentLlmConfig? llmConfig)
305305
return this;
306306
}
307307

308-
public Agent SetMcps(List<MCPTool> mcps)
308+
public Agent SetMcpTools(List<McpTool>? mcps)
309309
{
310310
McpTools = mcps ?? [];
311311
return this;
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
namespace BotSharp.Abstraction.Agents.Models;
22

3-
public class MCPTool
3+
public class McpTool
44
{
5+
public string Name { get; set; }
56
public string ServerId { get; set; }
6-
77
public bool Disabled { get; set; }
8+
public IEnumerable<McpFunction> Functions { get; set; } = [];
89

9-
public IEnumerable<MCPFunction> Functions { get; set; } = [];
10-
11-
public MCPTool()
10+
public McpTool()
1211
{
1312

1413
}
1514

16-
public MCPTool(
17-
IEnumerable<MCPFunction>? functions = null)
15+
public McpTool(
16+
string name,
17+
string serverId,
18+
bool disabled = false,
19+
IEnumerable<McpFunction>? functions = null)
1820
{
21+
Name = name;
22+
ServerId = serverId;
23+
Disabled = disabled;
1924
Functions = functions ?? [];
2025
}
2126

@@ -26,12 +31,12 @@ public override string ToString()
2631
}
2732

2833

29-
public class MCPFunction
34+
public class McpFunction
3035
{
3136
public string Name { get; set; }
3237

33-
public MCPFunction(string name)
38+
public McpFunction(string name)
3439
{
35-
this.Name = name;
40+
Name = name;
3641
}
3742
}

src/Infrastructure/BotSharp.Abstraction/Files/IFileInstructService.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
using BotSharp.Abstraction.Instructs.Models;
2+
13
namespace BotSharp.Abstraction.Files;
24

35
public interface IFileInstructService
46
{
57
#region Image
6-
Task<string> ReadImages(string? provider, string? model, string text, IEnumerable<InstructFileModel> images, string? agentId = null);
7-
Task<RoleDialogModel> GenerateImage(string? provider, string? model, string text, string? agentId = null);
8-
Task<RoleDialogModel> VaryImage(string? provider, string? model, InstructFileModel image, string? agentId = null);
9-
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, InstructFileModel image, string? agentId = null);
10-
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, InstructFileModel image, InstructFileModel mask, string? agentId = null);
8+
Task<string> ReadImages(string text, IEnumerable<InstructFileModel> images, InstructOptions? options = null);
9+
Task<RoleDialogModel> GenerateImage(string text, InstructOptions? options = null);
10+
Task<RoleDialogModel> VaryImage(InstructFileModel image, InstructOptions? options = null);
11+
Task<RoleDialogModel> EditImage(string text, InstructFileModel image, InstructOptions? options = null);
12+
Task<RoleDialogModel> EditImage(string text, InstructFileModel image, InstructFileModel mask, InstructOptions? options = null);
1113
#endregion
1214

1315
#region Pdf
@@ -17,11 +19,11 @@ public interface IFileInstructService
1719
/// <param name="prompt"></param>
1820
/// <param name="files">Pdf files</param>
1921
/// <returns></returns>
20-
Task<string> ReadPdf(string? provider, string? model, string? modelId, string prompt, List<InstructFileModel> files, string? agentId = null);
22+
Task<string> ReadPdf(string text, List<InstructFileModel> files, InstructOptions? options = null);
2123
#endregion
2224

2325
#region Audio
24-
Task<string> SpeechToText(string? provider, string? model, InstructFileModel audio, string? text = null);
26+
Task<string> SpeechToText(InstructFileModel audio, string? text = null, InstructOptions? options = null);
2527
#endregion
2628

2729
#region Select file

src/Infrastructure/BotSharp.Abstraction/Instructs/IInstructService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public interface IInstructService
1212
/// <param name="templateName">Template name</param>
1313
/// <param name="instruction">System prompt</param>
1414
/// <returns></returns>
15-
Task<InstructResult> Execute(string agentId, RoleDialogModel message, string? templateName = null, string? instruction = null);
15+
Task<InstructResult> Execute(string agentId, RoleDialogModel message,
16+
string? templateName = null, string? instruction = null, IEnumerable<InstructFileModel>? files = null);
1617

1718
/// <summary>
1819
/// A generic way to execute completion by using specified instruction or template
@@ -22,5 +23,5 @@ public interface IInstructService
2223
/// <param name="agentId">Agent id</param>
2324
/// <param name="options">Llm Provider, model, message, prompt data</param>
2425
/// <returns></returns>
25-
Task<T?> Instruct<T>(string instruction, string agentId, InstructOptions options) where T : class;
26+
Task<T?> Instruct<T>(string text, InstructOptions? options = null) where T : class;
2627
}

src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructOptions.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ public class InstructOptions
55
/// <summary>
66
/// Llm provider
77
/// </summary>
8-
public string Provider { get; set; } = null!;
8+
public string? Provider { get; set; }
99

1010
/// <summary>
1111
/// Llm model
1212
/// </summary>
13-
public string Model { get; set; } = null!;
13+
public string? Model { get; set; }
1414

1515
/// <summary>
16-
/// Conversation id. When this field is not null, it will get dialogs from conversation.
16+
/// Agent
1717
/// </summary>
18-
public string? ConversationId { get; set; }
18+
public string? AgentId { get; set; }
1919

2020
/// <summary>
21-
/// The single message. It can be append to the whole dialogs or sent alone.
21+
/// Agent template name
2222
/// </summary>
23-
public string? Message { get; set; }
23+
public string? TemplateName { get; set; }
24+
25+
/// <summary>
26+
/// Conversation id. When this field is not null, it will get dialogs from conversation.
27+
/// </summary>
28+
public string? ConversationId { get; set; }
2429

2530
/// <summary>
2631
/// Data to fill in prompt

src/Infrastructure/BotSharp.Abstraction/Plugins/PluginLoaderSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ namespace BotSharp.Abstraction.Plugins;
33
public class PluginSettings
44
{
55
public string[] Assemblies { get; set; } = new string[0];
6+
7+
public string[] ExcludedFunctions { get; set; } = new string[0];
68
}

0 commit comments

Comments
 (0)