diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs index bbcc51ab5..1bb221d3f 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs @@ -17,7 +17,7 @@ public enum AgentField Response, Sample, LlmConfig, - Tool + Utility } public enum AgentTaskField diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentTool.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs similarity index 86% rename from src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentTool.cs rename to src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs index 0ffe91f66..3168a7768 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentTool.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs @@ -1,6 +1,6 @@ namespace BotSharp.Abstraction.Agents.Enums; -public class AgentTool +public class AgentUtility { public const string FileAnalyzer = "file-analyzer"; public const string ImageGenerator = "image-generator"; diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs index c2368cd26..8405d9b53 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs @@ -52,5 +52,5 @@ public interface IAgentService PluginDef GetPlugin(string agentId); - IEnumerable GetAgentTools(); + IEnumerable GetAgentUtilities(); } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentToolHook.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentToolHook.cs deleted file mode 100644 index d7bb7b889..000000000 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentToolHook.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BotSharp.Abstraction.Agents; - -public interface IAgentToolHook -{ - void AddTools(List tools); -} diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentUtilityHook.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentUtilityHook.cs new file mode 100644 index 000000000..9d5667b8c --- /dev/null +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentUtilityHook.cs @@ -0,0 +1,6 @@ +namespace BotSharp.Abstraction.Agents; + +public interface IAgentUtilityHook +{ + void AddUtilities(List utilities); +} diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs index c1f82e7bd..01ec2acbd 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs @@ -91,9 +91,9 @@ public class Agent = new List(); /// - /// Useful tools + /// Agent utilities /// - public List Tools { get; set; } + public List Utilities { get; set; } = new List(); /// @@ -127,7 +127,7 @@ public static Agent Clone(Agent agent) Functions = agent.Functions, Responses = agent.Responses, Samples = agent.Samples, - Tools = agent.Tools, + Utilities = agent.Utilities, Knowledges = agent.Knowledges, IsPublic = agent.IsPublic, Disabled = agent.Disabled, @@ -169,9 +169,9 @@ public Agent SetSamples(List samples) return this; } - public Agent SetTools(List tools) + public Agent SetUtilities(List utilities) { - Tools = tools ?? new List(); + Utilities = utilities ?? new List(); return this; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Settings/AgentSettings.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Settings/AgentSettings.cs index fefda2409..232e7b60f 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Settings/AgentSettings.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Settings/AgentSettings.cs @@ -6,7 +6,6 @@ public class AgentSettings public string TemplateFormat { get; set; } = "liquid"; public string HostAgentId { get; set; } = string.Empty; public bool EnableTranslator { get; set; } = false; - public bool EnableHttpHandler { get; set; } = false; /// /// This is the default LLM config for agent diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs index ecf2ecfae..6fd0f85ec 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs @@ -32,7 +32,7 @@ public async Task UpdateAgent(Agent agent, AgentField updateField) record.Templates = agent.Templates ?? new List(); record.Responses = agent.Responses ?? new List(); record.Samples = agent.Samples ?? new List(); - record.Tools = agent.Tools ?? new List(); + record.Utilities = agent.Utilities ?? new List(); if (agent.LlmConfig != null && !agent.LlmConfig.IsInherit) { record.LlmConfig = agent.LlmConfig; @@ -94,7 +94,7 @@ public async Task UpdateAgentFromFile(string id) .SetFunctions(foundAgent.Functions) .SetResponses(foundAgent.Responses) .SetSamples(foundAgent.Samples) - .SetTools(foundAgent.Tools) + .SetUtilities(foundAgent.Utilities) .SetLlmConfig(foundAgent.LlmConfig); _db.UpdateAgent(clonedAgent, AgentField.All); diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs index 12b0512bd..40b80e507 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs @@ -55,15 +55,14 @@ public List GetAgentsByUser(string userId) return agents; } - public IEnumerable GetAgentTools() + public IEnumerable GetAgentUtilities() { - var tools = new List(); - - var hooks = _services.GetServices(); + var utilities = new List(); + var hooks = _services.GetServices(); foreach (var hook in hooks) { - hook.AddTools(tools); + hook.AddUtilities(utilities); } - return tools.Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().OrderBy(x => x).ToList(); + return utilities.Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().OrderBy(x => x).ToList(); } } diff --git a/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs b/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs index d6c08b723..6bed7e2af 100644 --- a/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs +++ b/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs @@ -18,6 +18,6 @@ public void RegisterDI(IServiceCollection services, IConfiguration config) services.AddScoped(); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs b/src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs index ca0e24bfa..67701575e 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs @@ -12,7 +12,7 @@ public class LoadAttachmentFn : IFunctionCallback private readonly ILogger _logger; private readonly IEnumerable _imageTypes = new List { "image", "images", "png", "jpg", "jpeg" }; private readonly IEnumerable _pdfTypes = new List { "pdf" }; - private static string TOOL_ASSISTANT = Guid.Empty.ToString(); + private static string UTILITY_ASSISTANT = Guid.Empty.ToString(); public LoadAttachmentFn( IServiceProvider services, @@ -31,7 +31,7 @@ public async Task Execute(RoleDialogModel message) var wholeDialogs = conv.GetDialogHistory(); var fileTypes = args?.FileTypes?.Split(",", StringSplitOptions.RemoveEmptyEntries)?.ToList() ?? new List(); var dialogs = await AssembleFiles(conv.ConversationId, wholeDialogs, fileTypes); - var agent = await agentService.LoadAgent(TOOL_ASSISTANT); + var agent = await agentService.LoadAgent(UTILITY_ASSISTANT); var fileAgent = new Agent { Id = agent?.Id ?? Guid.Empty.ToString(), diff --git a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs index 24c9b4f5c..87c90cf6f 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs @@ -2,7 +2,7 @@ namespace BotSharp.Core.Files.Hooks; public class FileAnalyzerHook : AgentHookBase { - private static string TOOL_ASSISTANT = Guid.Empty.ToString(); + private static string UTILITY_ASSISTANT = Guid.Empty.ToString(); public override string SelfId => string.Empty; @@ -15,7 +15,7 @@ public override void OnAgentLoaded(Agent agent) { var conv = _services.GetRequiredService(); var isConvMode = conv.IsConversationMode(); - var isEnabled = !agent.Tools.IsNullOrEmpty() && agent.Tools.Contains(AgentTool.FileAnalyzer); + var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileAnalyzer); if (isConvMode && isEnabled) { @@ -45,7 +45,7 @@ public override void OnAgentLoaded(Agent agent) { var fn = "load_attachment"; var db = _services.GetRequiredService(); - var agent = db.GetAgent(TOOL_ASSISTANT); + var agent = db.GetAgent(UTILITY_ASSISTANT); var prompt = agent?.Templates?.FirstOrDefault(x => x.Name.IsEqualTo($"{fn}.fn"))?.Content ?? string.Empty; var loadAttachmentFn = agent?.Functions?.FirstOrDefault(x => x.Name.IsEqualTo(fn)); return (prompt, loadAttachmentFn); diff --git a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerToolHook.cs b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerToolHook.cs deleted file mode 100644 index c97c7dea8..000000000 --- a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerToolHook.cs +++ /dev/null @@ -1,10 +0,0 @@ - -namespace BotSharp.Core.Files.Hooks; - -public class FileAnalyzerToolHook : IAgentToolHook -{ - public void AddTools(List tools) - { - tools.Add(AgentTool.FileAnalyzer); - } -} diff --git a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerUtilityHook.cs b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerUtilityHook.cs new file mode 100644 index 000000000..3a807e385 --- /dev/null +++ b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerUtilityHook.cs @@ -0,0 +1,9 @@ +namespace BotSharp.Core.Files.Hooks; + +public class FileAnalyzerUtilityHook : IAgentUtilityHook +{ + public void AddUtilities(List utilities) + { + utilities.Add(AgentUtility.FileAnalyzer); + } +} diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs index 2c464c32b..c0c59142e 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs @@ -54,8 +54,8 @@ public void UpdateAgent(Agent agent, AgentField field) case AgentField.LlmConfig: UpdateAgentLlmConfig(agent.Id, agent.LlmConfig); break; - case AgentField.Tool: - UpdateAgentTools(agent.Id, agent.Tools); + case AgentField.Utility: + UpdateAgentUtilities(agent.Id, agent.Utilities); break; case AgentField.All: UpdateAgentAllFields(agent); @@ -149,14 +149,14 @@ private void UpdateAgentProfiles(string agentId, List profiles) File.WriteAllText(agentFile, json); } - private void UpdateAgentTools(string agentId, List tools) + private void UpdateAgentUtilities(string agentId, List utilities) { - if (tools == null) return; + if (utilities == null) return; var (agent, agentFile) = GetAgentFromFile(agentId); if (agent == null) return; - agent.Tools = tools; + agent.Utilities = utilities; agent.UpdatedDateTime = DateTime.UtcNow; var json = JsonSerializer.Serialize(agent, _options); File.WriteAllText(agentFile, json); @@ -301,7 +301,7 @@ private void UpdateAgentAllFields(Agent inputAgent) agent.Disabled = inputAgent.Disabled; agent.Type = inputAgent.Type; agent.Profiles = inputAgent.Profiles; - agent.Tools = inputAgent.Tools; + agent.Utilities = inputAgent.Utilities; agent.RoutingRules = inputAgent.RoutingRules; agent.LlmConfig = inputAgent.LlmConfig; agent.UpdatedDateTime = DateTime.UtcNow; diff --git a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/agent.json b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/agent.json index ef0ce2228..c44219c1c 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/agent.json +++ b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/agent.json @@ -1,7 +1,7 @@ { "id": "00000000-0000-0000-0000-000000000000", - "name": "Tool Assistant", - "description": "Tool assistant that can be used to complete many different tasks", + "name": "Utility Assistant", + "description": "Utility assistant that can be used to complete many different tasks", "type": "static", "createdDateTime": "2023-06-24T10:39:32.2349685Z", "updatedDateTime": "2023-06-24T14:39:32.2349686Z", diff --git a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/instruction.liquid b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/instruction.liquid index 941957e34..0b8dcffe2 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/instruction.liquid +++ b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/instruction.liquid @@ -1 +1 @@ -You are a tool agent. \ No newline at end of file +You are a utility agent. \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs index 5d34ec77f..cac85ac50 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs @@ -141,9 +141,9 @@ public async Task DeleteAgent([FromRoute] string agentId) return await _agentService.DeleteAgent(agentId); } - [HttpGet("/agent/tools")] - public IEnumerable GetAgentTools() + [HttpGet("/agent/utilities")] + public IEnumerable GetAgentUtilities() { - return _agentService.GetAgentTools(); + return _agentService.GetAgentUtilities(); } } \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs index 4078fc034..c0fa8320d 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs @@ -1,6 +1,7 @@ using BotSharp.Abstraction.Agents.Models; using BotSharp.Abstraction.Functions.Models; using BotSharp.Abstraction.Routing.Models; +using BotSharp.Core.Infrastructures; namespace BotSharp.OpenAPI.ViewModels.Agents; @@ -43,7 +44,7 @@ public class AgentCreationModel /// Combine different Agents together to form a Profile. /// public List Profiles { get; set; } = new List(); - public List Tools { get; set; } = new List(); + public List Utilities { get; set; } = new List(); public List RoutingRules { get; set; } = new List(); public AgentLlmConfig? LlmConfig { get; set; } @@ -58,7 +59,7 @@ public Agent ToAgent() Functions = Functions, Responses = Responses, Samples = Samples, - Tools = Tools, + Utilities = Utilities, IsPublic = IsPublic, Type = Type, Disabled = Disabled, diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs index ba331f85d..96cc72785 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs @@ -26,9 +26,9 @@ public class AgentUpdateModel public List? Samples { get; set; } /// - /// Tools + /// Utilities /// - public List? Tools { get; set; } + public List? Utilities { get; set; } /// /// Functions @@ -76,7 +76,7 @@ public Agent ToAgent() Templates = Templates ?? new List(), Functions = Functions ?? new List(), Responses = Responses ?? new List(), - Tools = Tools ?? new List(), + Utilities = Utilities ?? new List(), LlmConfig = LlmConfig }; diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs index 5faa1b98c..a88b3c722 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs @@ -17,7 +17,7 @@ public class AgentViewModel public List Functions { get; set; } public List Responses { get; set; } public List Samples { get; set; } - public List Tools { get; set; } + public List Utilities { get; set; } [JsonPropertyName("is_public")] public bool IsPublic { get; set; } @@ -64,7 +64,7 @@ public static AgentViewModel FromAgent(Agent agent) Functions = agent.Functions, Responses = agent.Responses, Samples = agent.Samples, - Tools = agent.Tools, + Utilities = agent.Utilities, IsPublic= agent.IsPublic, Disabled = agent.Disabled, IconUrl = agent.IconUrl, diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Enums/Tool.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Enums/Utility.cs similarity index 83% rename from src/Plugins/BotSharp.Plugin.HttpHandler/Enums/Tool.cs rename to src/Plugins/BotSharp.Plugin.HttpHandler/Enums/Utility.cs index 893f068a9..3389206ad 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/Enums/Tool.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Enums/Utility.cs @@ -1,6 +1,6 @@ namespace BotSharp.Plugin.HttpHandler.Enums; -public class Tool +public class Utility { public const string HttpHandler = "http-handler"; } diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs index d5405d3dc..ae7adea05 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs @@ -8,7 +8,7 @@ namespace BotSharp.Plugin.HttpHandler.Hooks; public class HttpHandlerHook : AgentHookBase { - private static string TOOL_ASSISTANT = Guid.Empty.ToString(); + private static string UTILITY_ASSISTANT = Guid.Empty.ToString(); public override string SelfId => string.Empty; @@ -21,7 +21,7 @@ public override void OnAgentLoaded(Agent agent) { var conv = _services.GetRequiredService(); var isConvMode = conv.IsConversationMode(); - var isEnabled = !agent.Tools.IsNullOrEmpty() && agent.Tools.Contains(Tool.HttpHandler); + var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(Utility.HttpHandler); if (isConvMode && isEnabled) { @@ -51,7 +51,7 @@ public override void OnAgentLoaded(Agent agent) { var fn = "handle_http_request"; var db = _services.GetRequiredService(); - var agent = db.GetAgent(TOOL_ASSISTANT); + var agent = db.GetAgent(UTILITY_ASSISTANT); var prompt = agent?.Templates?.FirstOrDefault(x => x.Name.IsEqualTo($"{fn}.fn"))?.Content ?? string.Empty; var loadAttachmentFn = agent?.Functions?.FirstOrDefault(x => x.Name.IsEqualTo(fn)); return (prompt, loadAttachmentFn); diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerToolHook.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerToolHook.cs deleted file mode 100644 index 1d14beb97..000000000 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerToolHook.cs +++ /dev/null @@ -1,12 +0,0 @@ -using BotSharp.Abstraction.Agents; -using BotSharp.Plugin.HttpHandler.Enums; - -namespace BotSharp.Plugin.HttpHandler.Hooks; - -public class HttpHandlerToolHook : IAgentToolHook -{ - public void AddTools(List tools) - { - tools.Add(Tool.HttpHandler); - } -} diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerUtilityHook.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerUtilityHook.cs new file mode 100644 index 000000000..ee81372d9 --- /dev/null +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerUtilityHook.cs @@ -0,0 +1,12 @@ +using BotSharp.Abstraction.Agents; +using BotSharp.Plugin.HttpHandler.Enums; + +namespace BotSharp.Plugin.HttpHandler.Hooks; + +public class HttpHandlerUtilityHook : IAgentUtilityHook +{ + public void AddUtilities(List utilities) + { + utilities.Add(Utility.HttpHandler); + } +} diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs index c3427615d..8958a6b12 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs @@ -22,6 +22,6 @@ public void RegisterDI(IServiceCollection services, IConfiguration config) }); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); } } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs index 8e4395a19..075efc2b4 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs @@ -14,7 +14,7 @@ public class AgentDocument : MongoBase public List Functions { get; set; } public List Responses { get; set; } public List Samples { get; set; } - public List Tools { get; set; } + public List Utilities { get; set; } public bool IsPublic { get; set; } public bool Disabled { get; set; } public List Profiles { get; set; } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs index 2fe77b39b..60dcd6c3d 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs @@ -55,8 +55,8 @@ public void UpdateAgent(Agent agent, AgentField field) case AgentField.LlmConfig: UpdateAgentLlmConfig(agent.Id, agent.LlmConfig); break; - case AgentField.Tool: - UpdateAgentTools(agent.Id, agent.Tools); + case AgentField.Utility: + UpdateAgentUtilities(agent.Id, agent.Utilities); break; case AgentField.All: UpdateAgentAllFields(agent); @@ -219,13 +219,13 @@ private void UpdateAgentSamples(string agentId, List samples) _dc.Agents.UpdateOne(filter, update); } - private void UpdateAgentTools(string agentId, List tools) + private void UpdateAgentUtilities(string agentId, List utilities) { - if (tools == null) return; + if (utilities == null) return; var filter = Builders.Filter.Eq(x => x.Id, agentId); var update = Builders.Update - .Set(x => x.Tools, tools) + .Set(x => x.Utilities, utilities) .Set(x => x.UpdatedTime, DateTime.UtcNow); _dc.Agents.UpdateOne(filter, update); @@ -257,7 +257,7 @@ private void UpdateAgentAllFields(Agent agent) .Set(x => x.Functions, agent.Functions.Select(f => FunctionDefMongoElement.ToMongoElement(f)).ToList()) .Set(x => x.Responses, agent.Responses.Select(r => AgentResponseMongoElement.ToMongoElement(r)).ToList()) .Set(x => x.Samples, agent.Samples) - .Set(x => x.Tools, agent.Tools) + .Set(x => x.Utilities, agent.Utilities) .Set(x => x.LlmConfig, AgentLlmConfigMongoElement.ToMongoElement(agent.LlmConfig)) .Set(x => x.IsPublic, agent.IsPublic) .Set(x => x.UpdatedTime, DateTime.UtcNow); @@ -383,7 +383,7 @@ public void BulkInsertAgents(List agents) .Select(r => AgentResponseMongoElement.ToMongoElement(r))? .ToList() ?? new List(), Samples = x.Samples ?? new List(), - Tools = x.Tools ?? new List(), + Utilities = x.Utilities ?? new List(), IsPublic = x.IsPublic, Type = x.Type, InheritAgentId = x.InheritAgentId, @@ -473,7 +473,7 @@ private Agent TransformAgentDocument(AgentDocument? agentDoc) .Select(r => AgentResponseMongoElement.ToDomainElement(r)) .ToList() : new List(), Samples = agentDoc.Samples ?? new List(), - Tools = agentDoc.Tools ?? new List(), + Utilities = agentDoc.Utilities ?? new List(), IsPublic = agentDoc.IsPublic, Disabled = agentDoc.Disabled, Type = agentDoc.Type, diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs index eb05768d1..4a4542ed5 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs @@ -50,7 +50,7 @@ public int Transaction(Action action) .Select(r => AgentResponseMongoElement.ToMongoElement(r))? .ToList() ?? new List(), Samples = x.Samples ?? new List(), - Tools = x.Tools ?? new List(), + Utilities = x.Utilities ?? new List(), IsPublic = x.IsPublic, Type = x.Type, InheritAgentId = x.InheritAgentId, @@ -75,7 +75,7 @@ public int Transaction(Action action) .Set(x => x.Functions, agent.Functions) .Set(x => x.Responses, agent.Responses) .Set(x => x.Samples, agent.Samples) - .Set(x => x.Tools, agent.Tools) + .Set(x => x.Utilities, agent.Utilities) .Set(x => x.IsPublic, agent.IsPublic) .Set(x => x.Type, agent.Type) .Set(x => x.InheritAgentId, agent.InheritAgentId)