From 0cd664636e34a6aac004d49778fa42338a7e686b Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 3 Jul 2024 10:24:30 -0500 Subject: [PATCH] change to read file --- .../Agents/Enums/AgentUtility.cs | 2 +- .../BotSharp.Core/BotSharp.Core.csproj | 8 ++++---- src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs | 4 ++-- .../Functions/{LoadAttachmentFn.cs => ReadFileFn.cs} | 12 ++++++------ .../Hooks/{FileAnalyzerHook.cs => FileReaderHook.cs} | 8 ++++---- ...alyzerUtilityHook.cs => FileReaderUtilityHook.cs} | 4 ++-- .../{load_attachment.json => read_file.json} | 2 +- .../templates/load_attachment.fn.liquid | 1 - .../templates/read_file.fn.liquid | 1 + 9 files changed, 21 insertions(+), 21 deletions(-) rename src/Infrastructure/BotSharp.Core/Files/Functions/{LoadAttachmentFn.cs => ReadFileFn.cs} (94%) rename src/Infrastructure/BotSharp.Core/Files/Hooks/{FileAnalyzerHook.cs => FileReaderHook.cs} (86%) rename src/Infrastructure/BotSharp.Core/Files/Hooks/{FileAnalyzerUtilityHook.cs => FileReaderUtilityHook.cs} (50%) rename src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/{load_attachment.json => read_file.json} (96%) delete mode 100644 src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/load_attachment.fn.liquid create mode 100644 src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/read_file.fn.liquid diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs index 3168a776..4f477563 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs @@ -2,6 +2,6 @@ namespace BotSharp.Abstraction.Agents.Enums; public class AgentUtility { - public const string FileAnalyzer = "file-analyzer"; + public const string FileReader = "file-reader"; public const string ImageGenerator = "image-generator"; } diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index 2ca27817..8f44be5c 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -48,10 +48,10 @@ + - - + @@ -159,10 +159,10 @@ PreserveNewest - + PreserveNewest - + PreserveNewest diff --git a/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs b/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs index 4ddb3ab5..83f60654 100644 --- a/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs +++ b/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs @@ -17,8 +17,8 @@ public class FilePlugin : IBotSharpPlugin { services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + 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/ReadFileFn.cs similarity index 94% rename from src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs rename to src/Infrastructure/BotSharp.Core/Files/Functions/ReadFileFn.cs index 67701575..a1bb50df 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Functions/ReadFileFn.cs @@ -3,20 +3,20 @@ using BotSharp.Abstraction.MLTasks; namespace BotSharp.Core.Files.Functions; -public class LoadAttachmentFn : IFunctionCallback +public class ReadFileFn : IFunctionCallback { - public string Name => "load_attachment"; - public string Indication => "Analyzing files"; + public string Name => "read_file"; + public string Indication => "Reading files"; private readonly IServiceProvider _services; - private readonly ILogger _logger; + 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 UTILITY_ASSISTANT = Guid.Empty.ToString(); - public LoadAttachmentFn( + public ReadFileFn( IServiceProvider services, - ILogger logger) + ILogger logger) { _services = services; _logger = logger; diff --git a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderHook.cs similarity index 86% rename from src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs rename to src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderHook.cs index cded3e62..b9f57846 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderHook.cs @@ -1,13 +1,13 @@ namespace BotSharp.Core.Files.Hooks; -public class FileAnalyzerHook : AgentHookBase +public class FileReaderHook : AgentHookBase { private static string UTILITY_ASSISTANT = Guid.Empty.ToString(); - private static string FUNCTION_NAME = "load_attachment"; + private static string FUNCTION_NAME = "read_file"; public override string SelfId => string.Empty; - public FileAnalyzerHook(IServiceProvider services, AgentSettings settings) + public FileReaderHook(IServiceProvider services, AgentSettings settings) : base(services, settings) { } @@ -16,7 +16,7 @@ public class FileAnalyzerHook : AgentHookBase { var conv = _services.GetRequiredService(); var isConvMode = conv.IsConversationMode(); - var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileAnalyzer); + var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileReader); if (isConvMode && isEnabled) { diff --git a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerUtilityHook.cs b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderUtilityHook.cs similarity index 50% rename from src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerUtilityHook.cs rename to src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderUtilityHook.cs index 3a807e38..c63fa780 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerUtilityHook.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderUtilityHook.cs @@ -1,9 +1,9 @@ namespace BotSharp.Core.Files.Hooks; -public class FileAnalyzerUtilityHook : IAgentUtilityHook +public class FileReaderUtilityHook : IAgentUtilityHook { public void AddUtilities(List utilities) { - utilities.Add(AgentUtility.FileAnalyzer); + utilities.Add(AgentUtility.FileReader); } } diff --git a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/load_attachment.json b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/read_file.json similarity index 96% rename from src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/load_attachment.json rename to src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/read_file.json index a30e7f9a..faff2747 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/load_attachment.json +++ b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/functions/read_file.json @@ -1,5 +1,5 @@ { - "name": "load_attachment", + "name": "read_file", "description": "If the user's request is related to analyzing files and/or images, you can call this function to analyze files and images.", "parameters": { "type": "object", diff --git a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/load_attachment.fn.liquid b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/load_attachment.fn.liquid deleted file mode 100644 index 1e1f0ab8..00000000 --- a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/load_attachment.fn.liquid +++ /dev/null @@ -1 +0,0 @@ -Please call load_attachment if user wants to describe files, such as images, pdf. \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/read_file.fn.liquid b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/read_file.fn.liquid new file mode 100644 index 00000000..598f2da0 --- /dev/null +++ b/src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/read_file.fn.liquid @@ -0,0 +1 @@ +Please call read_file if user wants to describe files, such as images, pdf. \ No newline at end of file