From d530b59b1afac7ea8eb3d2eb1f3bf7e287b7ed9f Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Fri, 5 Apr 2024 13:53:37 -0500 Subject: [PATCH] patch state source --- .../Controllers/InstructModeController.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs index 725b6e2b..985526d9 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs @@ -22,12 +22,12 @@ public class InstructModeController : ControllerBase [FromBody] InstructMessageModel input) { var state = _services.GetRequiredService(); - input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds)); - state.SetState("provider", input.Provider) - .SetState("model", input.Model) - .SetState("model_id", input.ModelId) - .SetState("instruction", input.Instruction) - .SetState("input_text", input.Text); + input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External)); + state.SetState("provider", input.Provider, source: StateSource.External) + .SetState("model", input.Model, source: StateSource.External) + .SetState("model_id", input.ModelId, source: StateSource.External) + .SetState("instruction", input.Instruction, source: StateSource.External) + .SetState("input_text", input.Text,source: StateSource.External); var instructor = _services.GetRequiredService(); var result = await instructor.Execute(agentId, @@ -44,10 +44,10 @@ public class InstructModeController : ControllerBase public async Task TextCompletion([FromBody] IncomingMessageModel input) { var state = _services.GetRequiredService(); - input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds)); - state.SetState("provider", input.Provider) - .SetState("model", input.Model) - .SetState("model_id", input.ModelId); + input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External)); + state.SetState("provider", input.Provider, source: StateSource.External) + .SetState("model", input.Model, source: StateSource.External) + .SetState("model_id", input.ModelId, source: StateSource.External); var textCompletion = CompletionProvider.GetTextCompletion(_services); return await textCompletion.GetCompletion(input.Text, Guid.Empty.ToString(), Guid.NewGuid().ToString()); @@ -57,10 +57,10 @@ public class InstructModeController : ControllerBase public async Task ChatCompletion([FromBody] IncomingMessageModel input) { var state = _services.GetRequiredService(); - input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds)); - state.SetState("provider", input.Provider) - .SetState("model", input.Model) - .SetState("model_id", input.ModelId); + input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External)); + state.SetState("provider", input.Provider, source: StateSource.External) + .SetState("model", input.Model, source: StateSource.External) + .SetState("model_id", input.ModelId, source: StateSource.External); var textCompletion = CompletionProvider.GetChatCompletion(_services); var message = await textCompletion.GetChatCompletions(new Agent()