diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
index ee99085..a1d32be 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
@@ -115,7 +115,8 @@
-
+
+
@@ -126,6 +127,15 @@
+
+
+
+
+
+
+
+
+
@@ -141,8 +151,6 @@
-
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs
index 0047608..6e5ba83 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs
@@ -40,6 +40,8 @@ public partial class RecipeEditor : UserControl
private void ModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(RecipeEditorViewModel.SopRecording)) BindRecording();
+ if (e.PropertyName == nameof(RecipeEditorViewModel.StepDecisionLog))
+ Dispatcher.UIThread.Post(() => this.FindControl("StepDecisionLogScroll")?.ScrollToEnd(), DispatcherPriority.Background);
}
private void ChatChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
=> Dispatcher.UIThread.Post(() => this.FindControl("AgentChatScroll")?.ScrollToEnd(), DispatcherPriority.Background);
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/StepTestDecisionViewModel.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/StepTestDecisionViewModel.cs
index e667fa8..55eb479 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/StepTestDecisionViewModel.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/StepTestDecisionViewModel.cs
@@ -20,7 +20,30 @@ public partial class RecipeEditorViewModel
}
}
private string _stepTestStatus = "";
- public string StepTestStatus { get => _stepTestStatus; private set => SetProperty(ref _stepTestStatus, value); }
+ public string StepTestStatus
+ {
+ get => _stepTestStatus;
+ private set
+ {
+ SetProperty(ref _stepTestStatus, value);
+ AppendStepDecisionLog(value);
+ }
+ }
+ private string _stepDecisionLog = "";
+ public string StepDecisionLog { get => _stepDecisionLog; private set => SetProperty(ref _stepDecisionLog, value); }
+ private void AppendStepDecisionLog(string message)
+ {
+ var entry = $"[{DateTime.Now:HH:mm:ss}] {message}\n\n";
+ // 保留最近的完整记录,避免长时间反复测试导致界面日志无限增长。
+ const int limit = 64 * 1024;
+ var retained = StepDecisionLog;
+ while (retained.Length > 0 && retained.Length + entry.Length > limit)
+ {
+ var end = retained.IndexOf("\n\n", StringComparison.Ordinal);
+ retained = end < 0 ? "" : retained[(end + 2)..];
+ }
+ StepDecisionLog = retained + entry;
+ }
private async Task TestStepDecisionAsync()
{
@@ -52,6 +75,8 @@ public partial class RecipeEditorViewModel
cancellation.Token.ThrowIfCancellationRequested();
var request = new VisionDecisionRequest(recipe, id, name, description, description, 0, DateTime.Now, jpeg,
SourceSeconds: seconds);
+ AppendStepDecisionLog($"{label} · dlite 单图判定提示词\nstate:\n{D3VisionDecisionClient.StatePrompt}\n"
+ + $"questions.step_completed (type=noul).instructions:\n{D3VisionDecisionClient.BuildInstructions(request.Criteria)}");
var result = await RealtimeDecisionPolicy.RunAsync(StepTestDecisionClient, request, cancellation.Token);
cancellation.Token.ThrowIfCancellationRequested();
var passed = result.EffectiveStatus == VisionDecisionStatus.Completed && result.Completed
diff --git a/src/SopHelper.CrossPlatform.Engine/Sop/D3VisionDecisionClient.cs b/src/SopHelper.CrossPlatform.Engine/Sop/D3VisionDecisionClient.cs
index 20a7e25..913657a 100644
--- a/src/SopHelper.CrossPlatform.Engine/Sop/D3VisionDecisionClient.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Sop/D3VisionDecisionClient.cs
@@ -9,6 +9,10 @@ namespace SopHelper.Engine.Sop;
/// D3-lite 原生 System One 图片接口;noul 是完成条件的正例概率。
public sealed class D3VisionDecisionClient(HttpClient http) : IVisionDecisionClient
{
+ public const string StatePrompt = "正在检查当前工位图片。完成条件是待验证的假设,不代表已经发生。";
+ public static string BuildInstructions(string criteria) =>
+ $"仅依据当前图片中清晰可见的证据判断。看不到判据要求的目标或关键部位、存在遮挡或不能确认时回答否。图片里是否满足这个完成条件:{criteria}";
+
public async Task DecideAsync(VisionDecisionRequest request, CancellationToken cancellationToken)
{
if (request.EvidenceMode != VisionEvidenceMode.SingleFrame || request.Frames is { Count: > 1 })
@@ -26,14 +30,14 @@ public sealed class D3VisionDecisionClient(HttpClient http) : IVisionDecisionCli
message.Content = JsonContent.Create(new
{
// 完成判据是待验证假设,不能在 state 中当作已知事实重复陈述。
- state = "正在检查当前工位图片。完成条件是待验证的假设,不代表已经发生。",
+ state = StatePrompt,
images = new[] { "data:image/jpeg;base64," + Convert.ToBase64String(request.Jpeg) },
questions = new
{
step_completed = new
{
type = "noul",
- instructions = $"仅依据当前图片中清晰可见的证据判断。看不到判据要求的目标或关键部位、存在遮挡或不能确认时回答否。图片里是否满足这个完成条件:{request.Criteria}"
+ instructions = BuildInstructions(request.Criteria)
}
}
});
diff --git a/tests/VideoFlowTest.Smoke/Program.cs b/tests/VideoFlowTest.Smoke/Program.cs
index 2901586..610c0aa 100644
--- a/tests/VideoFlowTest.Smoke/Program.cs
+++ b/tests/VideoFlowTest.Smoke/Program.cs
@@ -207,6 +207,13 @@ internal static class Program
var keyFrame = view.FindControl("StepKeyFrameImage")!;
Check(ReferenceEquals(view.FindControl