From e6758e332b7351e2ba116e2d59eb54ba9d875df4 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Fri, 17 Oct 2025 16:14:06 -0500 Subject: [PATCH] save file and code options --- .../Instructs/Options/CodeInstructOptions.cs | 8 ++++++++ .../Instructs/Options/FileInstructOptions.cs | 2 ++ .../Instructs/Services/InstructService.Execute.cs | 1 - .../Controllers/InstructModeController.cs | 4 +++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/CodeInstructOptions.cs b/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/CodeInstructOptions.cs index 89684cfdf..2ea99275f 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/CodeInstructOptions.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/CodeInstructOptions.cs @@ -2,7 +2,15 @@ namespace BotSharp.Abstraction.Instructs.Options; public class CodeInstructOptions { + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("processor")] public string? Processor { get; set; } + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("code_script_name")] public string? CodeScriptName { get; set; } + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("arguments")] public List? Arguments { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/FileInstructOptions.cs b/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/FileInstructOptions.cs index bb575f49d..6e6ac1fd1 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/FileInstructOptions.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Instructs/Options/FileInstructOptions.cs @@ -2,5 +2,7 @@ namespace BotSharp.Abstraction.Instructs.Options; public class FileInstructOptions { + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("processor")] public string? Processor { get; set; } } diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs index 7885afa89..3556cabc6 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs @@ -125,7 +125,6 @@ public async Task Execute( Data = state.GetStates().ToDictionary(x => x.Key, x => (object)x.Value) }); result = fileResponse.Result.IfNullOrEmptyAs(string.Empty); - state.SetState("fileOptions", fileOptions.ConvertToString()); } else { diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs index cdb1dab49..dab28ca6b 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs @@ -32,7 +32,9 @@ public async Task InstructCompletion([FromRoute] string agentId, .SetState("instruction", input.Instruction, source: StateSource.External) .SetState("input_text", input.Text, source: StateSource.External) .SetState("template_name", input.Template, source: StateSource.External) - .SetState("channel", input.Channel, source: StateSource.External); + .SetState("channel", input.Channel, source: StateSource.External) + .SetState("code_options", input.CodeOptions, source: StateSource.External) + .SetState("file_options", input.FileOptions, source: StateSource.External); var instructor = _services.GetRequiredService(); var result = await instructor.Execute(agentId,