diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs index 37a02428..afae2e00 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs @@ -67,4 +67,21 @@ public class RoleDialogModel : ITrackableMessage return $"{Role}: {Content}"; } } + + public static RoleDialogModel From(RoleDialogModel source, + string? role = null, + string? content = null) + { + return new RoleDialogModel(role ?? source.Role, content ?? source.Content) + { + CurrentAgentId = source.CurrentAgentId, + MessageId = source.MessageId, + FunctionArgs = source.FunctionArgs, + FunctionName = source.FunctionName, + RichContent = source.RichContent, + StopCompletion = source.StopCompletion, + Instruction = source.Instruction, + Data = source.Data + }; + } } diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs index e347ff4e..e861b2bb 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs @@ -55,24 +55,16 @@ public partial class RoutingService var responseTemplate = await templateService.RenderFunctionResponse(agent.Id, message); if (!string.IsNullOrEmpty(responseTemplate)) { - dialogs.Add(new RoleDialogModel(AgentRole.Assistant, responseTemplate) - { - CurrentAgentId = agent.Id, - MessageId = message.MessageId, - FunctionArgs = message.FunctionArgs, - FunctionName = message.FunctionName - }); + dialogs.Add(RoleDialogModel.From(message, + role: AgentRole.Assistant, + content: responseTemplate)); } else { // Save to memory dialogs - dialogs.Add(new RoleDialogModel(AgentRole.Function, message.Content) - { - CurrentAgentId = agent.Id, - MessageId = message.MessageId, - FunctionArgs = message.FunctionArgs, - FunctionName = message.FunctionName - }); + dialogs.Add(RoleDialogModel.From(message, + role: AgentRole.Function, + content: message.Content)); // Send to LLM await InvokeAgent(agent.Id, dialogs); @@ -80,14 +72,9 @@ public partial class RoutingService } else { - dialogs.Add(new RoleDialogModel(AgentRole.Assistant, message.Content) - { - CurrentAgentId = agent.Id, - MessageId = message.MessageId, - FunctionArgs = message.FunctionArgs, - FunctionName = message.FunctionName, - StopCompletion = true - }); + dialogs.Add(RoleDialogModel.From(message, + role: AgentRole.Assistant, + content: message.Content)); } return true; diff --git a/src/WebStarter/WebStarter.csproj b/src/WebStarter/WebStarter.csproj index 6723a4da..3cb6b16b 100644 --- a/src/WebStarter/WebStarter.csproj +++ b/src/WebStarter/WebStarter.csproj @@ -1,9 +1,10 @@ - + net6.0 enable enable + InProcess 4fb8c9df-7975-4926-ba73-46c8ca440691 False