diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs index 17369f28..7214a3d5 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs @@ -57,7 +57,7 @@ public abstract class AgentHookBase : IAgentHook { } - public virtual void OnLoadAgentUtility(Agent agent, IEnumerable utilities) + public virtual void OnLoadAgentUtility(Agent agent, IEnumerable utilities) { if (agent.Type == AgentType.Routing || utilities.IsNullOrEmpty()) return; @@ -70,14 +70,14 @@ public abstract class AgentHookBase : IAgentHook agent.Functions ??= []; var agentUtilities = agent.Utilities ?? []; - foreach (var item in utilities) + foreach (var utillity in utilities) { - if (item.UtilityName.IsNullOrEmpty() || item.Content == null) continue; + if (utillity.Name.IsNullOrEmpty() || utillity.Content == null) continue; - var isEnabled = agentUtilities.Contains(item.UtilityName); + var isEnabled = agentUtilities.Contains(utillity.Name); if (!isEnabled) continue; - var (fns, prompts) = GetUtilityContent(item.Content); + var (fns, prompts) = GetUtilityContent(utillity.Content); if (!fns.IsNullOrEmpty()) { @@ -121,10 +121,6 @@ public abstract class AgentHookBase : IAgentHook var prompt = agent?.Templates?.FirstOrDefault(x => x.Name.IsEqualTo(template.Name))?.Content ?? string.Empty; if (string.IsNullOrWhiteSpace(prompt)) continue; - if (!template.Data.IsNullOrEmpty()) - { - prompt = render.Render(prompt, template.Data); - } prompts.Add(prompt); } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs index f8e3c545..d60f348c 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs @@ -32,5 +32,5 @@ public interface IAgentHook /// void OnAgentLoaded(Agent agent); - void OnLoadAgentUtility(Agent agent, IEnumerable utilities); + void OnLoadAgentUtility(Agent agent, IEnumerable utilities); } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentUtilityLoadModel.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentUtility.cs similarity index 66% rename from src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentUtilityLoadModel.cs rename to src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentUtility.cs index 938c5546..672c9f3d 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentUtilityLoadModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentUtility.cs @@ -1,18 +1,18 @@ namespace BotSharp.Abstraction.Agents.Models; -public class AgentUtilityLoadModel +public class AgentUtility { - public string UtilityName { get; set; } + public string Name { get; set; } public UtilityContent Content { get; set; } - public AgentUtilityLoadModel() + public AgentUtility() { } - public AgentUtilityLoadModel(string utilityName, UtilityContent content) + public AgentUtility(string utilityName, UtilityContent content) { - UtilityName = utilityName; + Name = utilityName; Content = content; } } @@ -44,17 +44,14 @@ public class UtilityFunction : UtilityBase public class UtilityTemplate : UtilityBase { - public Dictionary? Data { get; set; } - public UtilityTemplate() { } - public UtilityTemplate(string name, Dictionary? data = null) + public UtilityTemplate(string name) { Name = name; - Data = data; } } diff --git a/src/Plugins/BotSharp.Plugin.AudioHandler/Hooks/AudioHandlerHook.cs b/src/Plugins/BotSharp.Plugin.AudioHandler/Hooks/AudioHandlerHook.cs index f391ac2a..547cd7c3 100644 --- a/src/Plugins/BotSharp.Plugin.AudioHandler/Hooks/AudioHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.AudioHandler/Hooks/AudioHandlerHook.cs @@ -15,9 +15,9 @@ public class AudioHandlerHook : AgentHookBase, IAgentHook public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.AudioHandler, + Name = UtilityName.AudioHandler, Content = new UtilityContent { Functions = [new(HANDLER_AUDIO)], diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/Hooks/EmailHandlerHook.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/Hooks/EmailHandlerHook.cs index 132f84ae..4bee4bff 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/Hooks/EmailHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/Hooks/EmailHandlerHook.cs @@ -18,9 +18,9 @@ public class EmailHandlerHook : AgentHookBase public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.EmailHandler, + Name = UtilityName.EmailHandler, Content = new UtilityContent { Functions = [new(EMAIL_READER_FN), new(EMAIL_SENDER_FN)], diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Hooks/ExcelHandlerHook.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Hooks/ExcelHandlerHook.cs index 98368bd3..453386ed 100644 --- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Hooks/ExcelHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Hooks/ExcelHandlerHook.cs @@ -12,9 +12,9 @@ public class ExcelHandlerHook : AgentHookBase, IAgentHook public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.ExcelHandler, + Name = UtilityName.ExcelHandler, Content = new UtilityContent { Functions = [new(HANDLER_EXCEL)], diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Hooks/FileHandlerHook.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Hooks/FileHandlerHook.cs index c200d7fc..f43c9a1d 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Hooks/FileHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Hooks/FileHandlerHook.cs @@ -15,38 +15,38 @@ public class FileHandlerHook : AgentHookBase, IAgentHook public override void OnAgentLoaded(Agent agent) { - var utilityLoads = new List + var utilityLoads = new List { - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.ImageGenerator, + Name = UtilityName.ImageGenerator, Content = new UtilityContent { Functions = [new(GENERATE_IMAGE_FN)], Templates = [new($"{GENERATE_IMAGE_FN}.fn")] } }, - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.ImageReader, + Name = UtilityName.ImageReader, Content = new UtilityContent { Functions = [new(READ_IMAGE_FN)], Templates = [new($"{READ_IMAGE_FN}.fn")] } }, - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.ImageEditor, + Name = UtilityName.ImageEditor, Content = new UtilityContent { Functions = [new(EDIT_IMAGE_FN)], Templates = [new($"{EDIT_IMAGE_FN}.fn")] } }, - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.PdfReader, + Name = UtilityName.PdfReader, Content = new UtilityContent { Functions = [new(READ_PDF_FN)], diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs index cf9f77f2..049f4718 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/HttpHandlerHook.cs @@ -16,9 +16,9 @@ public class HttpHandlerHook : AgentHookBase public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.HttpHandler, + Name = UtilityName.HttpHandler, Content = new UtilityContent { Functions = [new(HTTP_HANDLER_FN)], diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Hooks/KnowledgeBaseAgentHook.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Hooks/KnowledgeBaseAgentHook.cs index 01c6ffd6..8988c241 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Hooks/KnowledgeBaseAgentHook.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Hooks/KnowledgeBaseAgentHook.cs @@ -14,9 +14,9 @@ public class KnowledgeBaseAgentHook : AgentHookBase, IAgentHook public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.KnowledgeRetrieval, + Name = UtilityName.KnowledgeRetrieval, Content = new UtilityContent { Functions = [new(KNOWLEDGE_RETRIEVAL_FN)], diff --git a/src/Plugins/BotSharp.Plugin.Planner/Hooks/PlannerAgentHook.cs b/src/Plugins/BotSharp.Plugin.Planner/Hooks/PlannerAgentHook.cs index 7c37ef8f..2b098b78 100644 --- a/src/Plugins/BotSharp.Plugin.Planner/Hooks/PlannerAgentHook.cs +++ b/src/Plugins/BotSharp.Plugin.Planner/Hooks/PlannerAgentHook.cs @@ -34,9 +34,9 @@ public class PlannerAgentHook : AgentHookBase public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.TwoStagePlanner, + Name = UtilityName.TwoStagePlanner, Content = new UtilityContent { Functions = [ diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Hooks/SqlDriverAgentHook.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Hooks/SqlDriverAgentHook.cs index 24c803aa..0ad432b0 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/Hooks/SqlDriverAgentHook.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Hooks/SqlDriverAgentHook.cs @@ -19,38 +19,35 @@ public class SqlDriverAgentHook : AgentHookBase, IAgentHook public override void OnAgentLoaded(Agent agent) { var dbType = SqlDriverHelper.GetDatabaseType(_services); - var promptData = new Dictionary - { - { "db_type", dbType } - }; + agent.TemplateDict["db_type"] = dbType; - var utilityLoads = new List + var utilityLoads = new List { - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.SqlTableDefinition, + Name = UtilityName.SqlTableDefinition, Content = new UtilityContent { Functions = new List { new(SQL_TABLE_DEFINITION_FN) }, - Templates = new List { new($"{SQL_TABLE_DEFINITION_FN}.fn", promptData) } + Templates = new List { new($"{SQL_TABLE_DEFINITION_FN}.fn") } } }, - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.SqlDictionaryLookup, + Name = UtilityName.SqlDictionaryLookup, Content = new UtilityContent { Functions = new List { new(VERIFY_DICTIONARY_TERM_FN) }, - Templates = new List { new($"{VERIFY_DICTIONARY_TERM_FN}.fn", promptData) } + Templates = new List { new($"{VERIFY_DICTIONARY_TERM_FN}.fn") } } }, - new AgentUtilityLoadModel + new AgentUtility { - UtilityName = UtilityName.SqlExecutor, + Name = UtilityName.SqlExecutor, Content = new UtilityContent { Functions = new List { new(SQL_SELECT_FN), new(SQL_TABLE_DEFINITION_FN) }, - Templates = new List { new($"sql_executor.fn", promptData) } + Templates = new List { new($"sql_executor.fn") } } } }; diff --git a/src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Hooks/OutboundPhoneCallHandlerHook.cs b/src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Hooks/OutboundPhoneCallHandlerHook.cs index 9fce1d20..664a4e80 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Hooks/OutboundPhoneCallHandlerHook.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Hooks/OutboundPhoneCallHandlerHook.cs @@ -16,9 +16,9 @@ namespace BotSharp.Plugin.Twilio.OutboundPhoneCallHandler.Hooks public override void OnAgentLoaded(Agent agent) { - var utilityLoad = new AgentUtilityLoadModel + var utilityLoad = new AgentUtility { - UtilityName = UtilityName.OutboundPhoneCall, + Name = UtilityName.OutboundPhoneCall, Content = new UtilityContent { Functions = [new(OUTBOUND_PHONE_CALL_FN)],