From 92ff9e6f3c8f9c194917050bf4fa890b4342e03f Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 13 Dec 2023 14:26:46 -0600 Subject: [PATCH] add agent llm config --- .../Agents/Enums/AgentField.cs | 3 +- .../Agents/Models/Agent.cs | 12 +++++++ .../Agents/Models/AgentLlmConfig.cs | 9 ++++++ .../Evaluations/Settings/EvaluatorSetting.cs | 2 +- .../Routing/Models/RoutingContext.cs | 4 +-- .../Routing/Settings/RoutingSettings.cs | 2 +- .../Services/AgentService.CreateAgent.cs | 3 +- .../Services/AgentService.UpdateAgent.cs | 4 ++- .../ConversationService.SendMessage.cs | 2 +- .../Evaluations/EvaluatingService.cs | 2 +- .../Repository/FileRepository.cs | 22 ++++++++++--- .../Routing/Hooks/RoutingAgentHook.cs | 2 +- .../BotSharp.Core/Routing/RoutingService.cs | 2 +- .../Controllers/AgentController.cs | 8 +++++ .../ViewModels/Agents/AgentCreationModel.cs | 4 ++- .../ViewModels/Agents/AgentUpdateModel.cs | 5 ++- .../ViewModels/Agents/AgentViewModel.cs | 5 +++ .../Collections/AgentDocument.cs | 1 + .../Models/AgentLlmConfigMongoElement.cs | 31 +++++++++++++++++++ .../Repository/MongoRepository.cs | 28 ++++++++++++++--- .../RoutingConversationHook.cs | 2 +- .../Services/TwilioService.cs | 4 +-- 22 files changed, 133 insertions(+), 24 deletions(-) create mode 100644 src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs create mode 100644 src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs index 0a8b38e8..669ebaba 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs @@ -14,5 +14,6 @@ public enum AgentField Function, Template, Response, - Sample + Sample, + LlmConfig } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs index 4092f9c7..0a66f0b5 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs @@ -66,6 +66,12 @@ public class Agent public List RoutingRules { get; set; } = new List(); + /// + /// Agent LLM Config, i.e., provider & model + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public AgentLlmConfig? LlmConfig { get; set; } + /// /// For rendering deferral /// @@ -176,4 +182,10 @@ public class Agent RoutingRules = rules ?? new List(); return this; } + + public Agent SetLlmConfig(AgentLlmConfig? llmConfig) + { + LlmConfig = llmConfig; + return this; + } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs new file mode 100644 index 00000000..b920fcf9 --- /dev/null +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs @@ -0,0 +1,9 @@ +namespace BotSharp.Abstraction.Agents.Models; + +public class AgentLlmConfig +{ + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? Provider { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string Model { get; set; } +} diff --git a/src/Infrastructure/BotSharp.Abstraction/Evaluations/Settings/EvaluatorSetting.cs b/src/Infrastructure/BotSharp.Abstraction/Evaluations/Settings/EvaluatorSetting.cs index c08f4f71..e67621fe 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Evaluations/Settings/EvaluatorSetting.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Evaluations/Settings/EvaluatorSetting.cs @@ -2,7 +2,7 @@ namespace BotSharp.Abstraction.Evaluations.Settings; public class EvaluatorSetting { - public string EvaluatorId { get; set; } + public string AgentId { get; set; } public string Provider { get; set; } public string Model { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs index c65ea62f..18a20713 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs @@ -22,14 +22,14 @@ public class RoutingContext /// Agent that can handl user original goal. /// public string OriginAgentId - => _stack.Where(x => x != _setting.RouterId).Last(); + => _stack.Where(x => x != _setting.AgentId).Last(); public bool IsEmpty => !_stack.Any(); public string GetCurrentAgentId() { if (_stack.Count == 0) { - _stack.Push(_setting.RouterId); + _stack.Push(_setting.AgentId); } return _stack.Peek(); } diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs index 62a6ae4a..bbe76a81 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs @@ -5,7 +5,7 @@ public class RoutingSettings /// /// Router Agent Id /// - public string RouterId { get; set; } = string.Empty; + public string AgentId { get; set; } = string.Empty; public string Planner { get; set; } = string.Empty; public string Provider { get; set; } = string.Empty; diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs index be9ef658..b88322dc 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs @@ -39,7 +39,8 @@ public partial class AgentService .SetInstruction(foundAgent.Instruction) .SetTemplates(foundAgent.Templates) .SetFunctions(foundAgent.Functions) - .SetResponses(foundAgent.Responses); + .SetResponses(foundAgent.Responses) + .SetLlmConfig(foundAgent.LlmConfig); } var user = _db.GetUserById(_user.Id); diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs index 292b83bb..e0a225e2 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs @@ -27,6 +27,7 @@ public partial class AgentService record.Templates = agent.Templates ?? new List(); record.Responses = agent.Responses ?? new List(); record.Samples = agent.Samples ?? new List(); + record.LlmConfig = agent.LlmConfig; _db.UpdateAgent(record, updateField); await Task.CompletedTask; @@ -58,7 +59,8 @@ public partial class AgentService .SetTemplates(foundAgent.Templates) .SetFunctions(foundAgent.Functions) .SetResponses(foundAgent.Responses) - .SetSamples(foundAgent.Samples); + .SetSamples(foundAgent.Samples) + .SetLlmConfig(foundAgent.LlmConfig); _db.UpdateAgent(clonedAgent, AgentField.All); } diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index ad1faeef..eebf4c00 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -59,7 +59,7 @@ public partial class ConversationService var routing = _services.GetRequiredService(); var settings = _services.GetRequiredService(); - response = agentId == settings.RouterId ? + response = agentId == settings.AgentId ? await routing.InstructLoop(message) : await routing.ExecuteDirectly(agent, message); diff --git a/src/Infrastructure/BotSharp.Core/Evaluations/EvaluatingService.cs b/src/Infrastructure/BotSharp.Core/Evaluations/EvaluatingService.cs index 75191edf..340b8f7e 100644 --- a/src/Infrastructure/BotSharp.Core/Evaluations/EvaluatingService.cs +++ b/src/Infrastructure/BotSharp.Core/Evaluations/EvaluatingService.cs @@ -20,7 +20,7 @@ public class EvaluatingService : IEvaluatingService public async Task Execute(string task, EvaluationRequest request) { var agentService = _services.GetRequiredService(); - var evaluator = await agentService.GetAgent(_settings.EvaluatorId); + var evaluator = await agentService.GetAgent(_settings.AgentId); // Task execution mode evaluator.Instruction = evaluator.Templates.First(x => x.Name == "instruction.executor").Content; var taskPrompt = evaluator.Templates.First(x => x.Name == $"task.{task}").Content; diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs index 8b90ae79..c5b22d89 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs @@ -246,6 +246,9 @@ public class FileRepository : IBotSharpRepository case AgentField.Sample: UpdateAgentSamples(agent.Id, agent.Samples); break; + case AgentField.LlmConfig: + UpdateAgentLlmConfig(agent.Id, agent.LlmConfig); + break; case AgentField.All: UpdateAgentAllFields(agent); break; @@ -431,6 +434,17 @@ public class FileRepository : IBotSharpRepository File.WriteAllLines(file, samples); } + private void UpdateAgentLlmConfig(string agentId, AgentLlmConfig? config) + { + var (agent, agentFile) = GetAgentFromFile(agentId); + if (agent == null) return; + + agent.LlmConfig = config; + agent.UpdatedDateTime = DateTime.UtcNow; + var json = JsonSerializer.Serialize(agent, _options); + File.WriteAllText(agentFile, json); + } + private void UpdateAgentAllFields(Agent inputAgent) { var (agent, agentFile) = GetAgentFromFile(inputAgent.Id); @@ -493,10 +507,10 @@ public class FileRepository : IBotSharpRepository var templates = FetchTemplates(dir); var responses = FetchResponses(dir); return record.SetInstruction(instruction) - .SetFunctions(functions) - .SetSamples(samples) - .SetTemplates(templates) - .SetResponses(responses); + .SetFunctions(functions) + .SetSamples(samples) + .SetTemplates(templates) + .SetResponses(responses); } return null; diff --git a/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs b/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs index 07647e10..2d3d3ab2 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs @@ -7,7 +7,7 @@ namespace BotSharp.Core.Routing.Hooks; public class RoutingAgentHook : AgentHookBase { private readonly RoutingSettings _routingSetting; - public override string SelfId => _routingSetting.RouterId; + public override string SelfId => _routingSetting.AgentId; public RoutingAgentHook(IServiceProvider services, AgentSettings settings, RoutingSettings routingSetting) : base(services, settings) diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs index a92e4a6e..8304b46e 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs @@ -64,7 +64,7 @@ public partial class RoutingService : IRoutingService public async Task InstructLoop(RoleDialogModel message) { var agentService = _services.GetRequiredService(); - _router = await agentService.LoadAgent(_settings.RouterId); + _router = await agentService.LoadAgent(_settings.AgentId); RoleDialogModel response = default; diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs index eb84453c..12d17e51 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs @@ -149,4 +149,12 @@ public class AgentController : ControllerBase, IApiAdapter model.Id = agentId; await _agentService.UpdateAgent(model, AgentField.Sample); } + + [HttpPut("/agent/{agentId}/llm-config")] + public async Task UpdateAgentLlmConfig([FromRoute] string agentId, [FromBody] AgentUpdateModel agent) + { + var model = agent.ToAgent(); + model.Id = agentId; + await _agentService.UpdateAgent(model, AgentField.LlmConfig); + } } \ 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 9af1dda6..fe6ce7e2 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs @@ -43,6 +43,7 @@ public class AgentCreationModel /// public List Profiles { get; set; } = new List(); public List RoutingRules { get; set; } = new List(); + public AgentLlmConfig? LlmConfig { get; set; } public Agent ToAgent() { @@ -61,7 +62,8 @@ public class AgentCreationModel Profiles = Profiles, RoutingRules = RoutingRules? .Select(x => RoutingRuleUpdateModel.ToDomainElement(x))? - .ToList() ?? new List() + .ToList() ?? new List(), + LlmConfig = LlmConfig }; } } diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs index c340b57a..b394b3bb 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs @@ -47,6 +47,8 @@ public class AgentUpdateModel public List? RoutingRules { get; set; } + public AgentLlmConfig? LlmConfig { get; set; } + public Agent ToAgent() { var agent = new Agent() @@ -63,7 +65,8 @@ public class AgentUpdateModel Instruction = Instruction ?? string.Empty, Templates = Templates ?? new List(), Functions = Functions ?? new List(), - Responses = Responses ?? new List() + Responses = Responses ?? new List(), + LlmConfig = LlmConfig }; return agent; diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs index 2ef67efd..c09f417a 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs @@ -26,6 +26,10 @@ public class AgentViewModel [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List RoutingRules { get; set; } + [JsonPropertyName("llmConfig")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public AgentLlmConfig? LlmConfig { get; set; } + [JsonPropertyName("created_datetime")] public DateTime CreatedDateTime { get; set; } @@ -49,6 +53,7 @@ public class AgentViewModel AllowRouting = agent.AllowRouting, Profiles = agent.Profiles, RoutingRules = agent.RoutingRules, + LlmConfig = agent.LlmConfig, CreatedDateTime = agent.CreatedDateTime, UpdatedDateTime = agent.UpdatedDateTime }; diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs index 5e7c2f35..c9e7298b 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs @@ -16,6 +16,7 @@ public class AgentDocument : MongoBase public bool Disabled { get; set; } public List Profiles { get; set; } public List RoutingRules { get; set; } + public AgentLlmConfigMongoElement? LlmConfig { get; set; } public DateTime CreatedTime { get; set; } public DateTime UpdatedTime { get; set; } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs new file mode 100644 index 00000000..f5217fd5 --- /dev/null +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs @@ -0,0 +1,31 @@ +using BotSharp.Abstraction.Agents.Models; + +namespace BotSharp.Plugin.MongoStorage.Models; + +public class AgentLlmConfigMongoElement +{ + public string? Provider { get; set; } + public string Model { get; set; } + + public static AgentLlmConfigMongoElement? ToMongoElement(AgentLlmConfig? config) + { + if (config == null) return null; + + return new AgentLlmConfigMongoElement + { + Provider = config.Provider, + Model = config.Model + }; + } + + public static AgentLlmConfig? ToDomainElement(AgentLlmConfigMongoElement? config) + { + if (config == null) return null; + + return new AgentLlmConfig + { + Provider = config.Provider, + Model = config.Model + }; + } +} diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs index cc7ea6e0..0dc83366 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs @@ -82,6 +82,7 @@ public class MongoRepository : IBotSharpRepository RoutingRules = x.RoutingRules? .Select(r => RoutingRuleMongoElement.ToMongoElement(r))? .ToList() ?? new List(), + LlmConfig = AgentLlmConfigMongoElement.ToMongoElement(x.LlmConfig), CreatedTime = x.CreatedDateTime, UpdatedTime = x.UpdatedDateTime }).ToList(); @@ -102,6 +103,7 @@ public class MongoRepository : IBotSharpRepository .Set(x => x.Disabled, agent.Disabled) .Set(x => x.Profiles, agent.Profiles) .Set(x => x.RoutingRules, agent.RoutingRules) + .Set(x => x.LlmConfig, agent.LlmConfig) .Set(x => x.CreatedTime, agent.CreatedTime) .Set(x => x.UpdatedTime, agent.UpdatedTime); _dc.Agents.UpdateOne(filter, update, _options); @@ -211,6 +213,9 @@ public class MongoRepository : IBotSharpRepository case AgentField.Sample: UpdateAgentSamples(agent.Id, agent.Samples); break; + case AgentField.LlmConfig: + UpdateAgentLlmConfig(agent.Id, agent.LlmConfig); + break; case AgentField.All: UpdateAgentAllFields(agent); break; @@ -362,6 +367,17 @@ public class MongoRepository : IBotSharpRepository _dc.Agents.UpdateOne(filter, update); } + private void UpdateAgentLlmConfig(string agentId, AgentLlmConfig? config) + { + var llmConfig = AgentLlmConfigMongoElement.ToMongoElement(config); + var filter = Builders.Filter.Eq(x => x.Id, agentId); + var update = Builders.Update + .Set(x => x.LlmConfig, llmConfig) + .Set(x => x.UpdatedTime, DateTime.UtcNow); + + _dc.Agents.UpdateOne(filter, update); + } + private void UpdateAgentAllFields(Agent agent) { var filter = Builders.Filter.Eq(x => x.Id, agent.Id); @@ -377,6 +393,7 @@ public class MongoRepository : IBotSharpRepository .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.LlmConfig, AgentLlmConfigMongoElement.ToMongoElement(agent.LlmConfig)) .Set(x => x.IsPublic, agent.IsPublic) .Set(x => x.UpdatedTime, DateTime.UtcNow); @@ -413,7 +430,8 @@ public class MongoRepository : IBotSharpRepository Profiles = agent.Profiles, RoutingRules = !agent.RoutingRules.IsNullOrEmpty() ? agent.RoutingRules .Select(r => RoutingRuleMongoElement.ToDomainElement(agent.Id, agent.Name, r)) - .ToList() : new List() + .ToList() : new List(), + LlmConfig = AgentLlmConfigMongoElement.ToDomainElement(agent.LlmConfig) }; } @@ -469,7 +487,8 @@ public class MongoRepository : IBotSharpRepository Profiles = x.Profiles, RoutingRules = !x.RoutingRules.IsNullOrEmpty() ? x.RoutingRules .Select(r => RoutingRuleMongoElement.ToDomainElement(x.Id, x.Name, r)) - .ToList() : new List() + .ToList() : new List(), + LlmConfig = AgentLlmConfigMongoElement.ToDomainElement(x.LlmConfig) }).ToList(); } @@ -482,8 +501,8 @@ public class MongoRepository : IBotSharpRepository var filter = new AgentFilter { - IsPublic = true, - AgentIds = agentIds + AgentIds = agentIds, + IsPublic = true }; var agents = GetAgents(filter); return agents; @@ -533,6 +552,7 @@ public class MongoRepository : IBotSharpRepository RoutingRules = x.RoutingRules? .Select(r => RoutingRuleMongoElement.ToMongoElement(r))? .ToList() ?? new List(), + LlmConfig = AgentLlmConfigMongoElement.ToMongoElement(x.LlmConfig), CreatedTime = x.CreatedDateTime, UpdatedTime = x.UpdatedDateTime }).ToList(); diff --git a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs index 368f49bf..11744d0d 100644 --- a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs +++ b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs @@ -53,7 +53,7 @@ public class RoutingConversationHook: ConversationHookBase public override async Task OnResponseGenerated(RoleDialogModel message) { var routerSettings = _services.GetRequiredService(); - bool saveFlag = message.CurrentAgentId != routerSettings.RouterId; + bool saveFlag = message.CurrentAgentId != routerSettings.AgentId; if (saveFlag) { diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs b/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs index dcbcf30c..374a00ad 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs @@ -56,7 +56,7 @@ public class TwilioService { Gather.InputEnum.Speech }, - Action = new Uri($"{_settings.CallbackHost}/twilio/voice/{routingSetting.RouterId}") + Action = new Uri($"{_settings.CallbackHost}/twilio/voice/{routingSetting.AgentId}") }; gather.Say(message); response.Append(gather); @@ -82,7 +82,7 @@ public class TwilioService var gather = new Gather() { Input = new List() { Gather.InputEnum.Speech }, - Action = new Uri($"{_settings.CallbackHost}/twilio/voice/{routingSetting.RouterId}"), + Action = new Uri($"{_settings.CallbackHost}/twilio/voice/{routingSetting.AgentId}"), ActionOnEmptyResult = true }; if (!string.IsNullOrEmpty(message))