From 74898e27d36bebab01d599a4769ba251d633357f Mon Sep 17 00:00:00 2001
From: tfarcraw <123211521@163.com>
Date: Thu, 19 Nov 2026 23:17:34 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=8A=A9=E6=89=8B=E7=9A=84dj?=
=?UTF-8?q?ev=E5=9B=9E=E6=B5=8B=E5=85=A5=E5=8F=A3=E5=8F=8A=E9=80=BB?=
=?UTF-8?q?=E8=BE=91=E5=B9=B6=E4=BF=9D=E7=95=99=E6=AD=A5=E9=AA=A4=E7=94=9F?=
=?UTF-8?q?=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../VVMs/RecipeEditor/RecipeEditor.axaml | 12 +-
.../SopAgentVerificationViewModel.cs | 116 ------------------
.../RecipeEditor/SopVideoAgentViewModel.cs | 88 +++++--------
.../AgentBenchmarkChecks.cs | 2 +-
...hecks.cs => AgentDraftGenerationChecks.cs} | 79 +++++-------
tests/VideoFlowTest.Smoke/Program.cs | 3 +-
6 files changed, 68 insertions(+), 232 deletions(-)
delete mode 100644 src/SopHelper.Avalonia/VVMs/RecipeEditor/SopAgentVerificationViewModel.cs
rename tests/VideoFlowTest.Smoke/{AgentDraftVerificationChecks.cs => AgentDraftGenerationChecks.cs} (69%)
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
index 4c1820e..02fc4d8 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
@@ -482,21 +482,13 @@
-
-
+
-
-
-
-
-
-
-
-
+
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopAgentVerificationViewModel.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopAgentVerificationViewModel.cs
deleted file mode 100644
index 93862f1..0000000
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopAgentVerificationViewModel.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using System.ComponentModel;
-using System.Text.Json;
-using SopHelper.Presentation;
-using Prism.Commands;
-using SopHelper.Engine.Sop;
-using SopHelper.Engine.SopAgent;
-using SopHelper.Training;
-
-namespace SopHelper.VVMs.RecipeEditor;
-
-public partial class RecipeEditorViewModel
-{
- public ISopDraftVideoVerifier DraftVerifier { get; set; } = new SopDraftVideoVerifier();
- private bool _agentVerificationRequired;
- private string? _agentVerifiedFingerprint;
- private Task? _agentVerificationTask;
- private readonly List _agentRegionAdjustments = [];
- private string _agentVerificationSummary = "";
- public string AgentVerificationSummary { get => _agentVerificationSummary; private set => SetProperty(ref _agentVerificationSummary, value); }
- public string AgentRegionAdjustmentsSummary => string.Join("\n", _agentRegionAdjustments.Select(r =>
- $"区域校正草稿:{r.Key} [{r.X1},{r.Y1}]–[{r.X2},{r.Y2}] · {r.Note}"));
- public DelegateCommand VerifyAgentDraftCommand { get; private set; } = null!;
- private async Task ReplayDraftWithDliteAsync()
- {
- if (IsAgentBusy || IsCapturing || _agentSample is null || AgentDraftSteps.Count == 0) return;
- var draft = CreateAgentDraftSnapshot()!;
- var video = _agentSample;
- _agentCancellation = new CancellationTokenSource();
- var token = _agentCancellation.Token;
- IsAgentBusy = true;
- _agentVerificationRequired = true;
- AgentStatus = "正在由djev单图回测,每次判定500ms硬截止…";
- using var runLog = new SopAgentRunLog(DesktopPlatform.WorkspaceRoot, "");
- runLog.Write(new("session_start", 0, "djev_replay: single_frame; deadline_ms=500; agent_calls=0"));
- runLog.Write(new("verification_start", 0, JsonSerializer.Serialize(draft)));
- try
- {
- var progress = new Progress(value => AgentStatus = value);
- draft.Verification = await VerifyAgentDraftAsync(draft, video, CreateAgentVerificationTemplate(), progress, token);
- token.ThrowIfCancellationRequested();
- runLog.Write(new("verification_end", 0, JsonSerializer.Serialize(new { report = draft.Verification, decisions = draft.Verification.Images })));
- foreach (var row in AgentDraftSteps) { row.PropertyChanged -= DraftRowChanged; row.Dispose(); }
- AgentDraftSteps.Clear();
- for (var i = 0; i < draft.Steps.Count; i++)
- {
- var step = draft.Steps[i];
- var row = new AgentDraftRow(step, video.Frames[step.EvidenceFrame], draft.Verification.Images.LastOrDefault(v => v.StepId == i + 1));
- row.PropertyChanged += DraftRowChanged; AgentDraftSteps.Add(row);
- }
- _agentRegionAdjustments.Clear();
- PresentVerification(draft);
- AgentStatus = draft.Verification.Passed ? "djev回测通过,未调用Agent或修改判据。"
- : "djev回测未通过,未自动修改步骤;可根据失败证据编辑草稿后再回测。";
- AgentChatMessages.Add(new("djev回测", AgentVerificationSummary));
- }
- catch (OperationCanceledException) { runLog.Write(new("cancelled_or_timeout", 0, "cancelled")); AgentStatus = "djev回测已取消。"; }
- catch (Exception error) { AgentStatus = "djev回测失败:" + error.Message; }
- finally
- {
- runLog.Write(new("session_end", 0, AgentStatus));
- await WaitForAgentVerificationCleanupAsync();
- _agentCancellation.Dispose(); _agentCancellation = null; IsAgentBusy = false;
- }
- }
- private bool CanApplyAgentDraft() => !IsAgentBusy && !_draftApplied && AgentDraftSteps.Count > 0
- && (!_agentVerificationRequired || _agentVerifiedFingerprint is not null);
-
- private async Task VerifyAgentDraftAsync(SopVideoDraft draft, SopVideoSample video, SopConfig template,
- IProgress progress, CancellationToken token)
- {
- token.ThrowIfCancellationRequested();
- var operation = DraftVerifier.VerifyAsync(draft, video, template, progress, token);
- Interlocked.Exchange(ref _agentVerificationTask, operation);
- try { return await operation.ConfigureAwait(false); }
- finally { Interlocked.CompareExchange(ref _agentVerificationTask, null, operation); }
- }
-
- private async Task WaitForAgentVerificationCleanupAsync()
- {
- var verification = Volatile.Read(ref _agentVerificationTask);
- if (verification is null) return;
- try { await verification; } catch { /* 已取消分析;仍等待本地解码/模型资源释放。 */ }
- }
-
- private SopConfig CreateAgentVerificationTemplate()
- {
- var template = Recipe.ToConfig();
- var definitions = template.Sop.Steps;
- template.Sop.Steps = _agentAppliedNodes.Where(Recipe.Steps.Contains)
- .Select(node => definitions.First(s => s.Id == node.Id)).ToList();
- return template;
- }
-
- private void DraftRowChanged(object? sender, PropertyChangedEventArgs e)
- {
- if (_agentVerifiedFingerprint is not null)
- {
- _agentVerifiedFingerprint = null;
- AgentVerificationSummary = "草稿已修改,请点击“djev回测”后再应用。";
- ApplyAgentDraftCommand.RaiseCanExecuteChanged();
- }
- }
-
- private void PresentVerification(SopVideoDraft draft)
- {
- _agentRegionAdjustments.AddRange(draft.RegionAdjustments);
- RaisePropertyChanged(nameof(AgentRegionAdjustmentsSummary));
- _agentVerifiedFingerprint = draft.Verification?.Passed == true && !string.IsNullOrWhiteSpace(draft.Verification.Fingerprint)
- ? draft.Verification.Fingerprint : null;
- AgentVerificationSummary = draft.Verification is { } report ? report.Summary + "\n"
- + string.Join("\n", report.Steps.Select(s => $"{(s.Completed ? "✓" : "○")} {s.Id} {s.Name}:{s.Message}"))
- : "尚未进行标准视频回测。";
- VerifyAgentDraftCommand.RaiseCanExecuteChanged();
- ApplyAgentDraftCommand.RaiseCanExecuteChanged();
- }
-}
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs
index bcdff9b..2a50993 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs
@@ -79,7 +79,6 @@ public partial class RecipeEditorViewModel
SaveCommand.RaiseCanExecuteChanged();
SendAgentChatCommand.RaiseCanExecuteChanged();
ClearAgentChatCommand.RaiseCanExecuteChanged();
- VerifyAgentDraftCommand?.RaiseCanExecuteChanged();
}
}
public DelegateCommand GenerateStepsCommand { get; private set; } = null!;
@@ -100,8 +99,6 @@ public partial class RecipeEditorViewModel
FetchAgentModelsCommand = new DelegateCommand(() => ScheduleModelDiscovery(immediate: true));
CancelAgentCommand = new DelegateCommand(() => _agentCancellation?.Cancel(), () => IsAgentBusy);
ApplyAgentDraftCommand = new DelegateCommand(ApplyAgentDraft, CanApplyAgentDraft);
- VerifyAgentDraftCommand = new DelegateCommand(() => _agentTask = ReplayDraftWithDliteAsync(),
- () => !IsAgentBusy && !IsCapturing && AgentDraftSteps.Count > 0);
BrowseAgentVideoCommand = new DelegateCommand(async () =>
{
var dialog = new OpenFileDialog { Title = "选择标准 SOP 视频", Filter = "视频|*.avi;*.mp4;*.mov;*.mkv;*.webm|所有文件|*.*" };
@@ -219,7 +216,7 @@ public partial class RecipeEditorViewModel
if (string.IsNullOrWhiteSpace(AgentVideoPath) && SopRecording is not null) AgentVideoPath = SopRecording.StandardVideoPath;
}
- private async Task AnalyzeVideoAsync(string? userMessage = null, bool verifyDraft = false)
+ private async Task AnalyzeVideoAsync(string? userMessage = null)
{
if (IsAgentBusy || IsCapturing) return;
if (SopRecording?.IsRecording == true) { AgentStatus = "请先停止并保存 SOP 录像,再开始分析。"; return; }
@@ -236,7 +233,7 @@ public partial class RecipeEditorViewModel
var regionDefinitions = Recipe.ToConfig().Sop.Regions;
var regions = regionDefinitions.Keys.ToArray();
var recipeName = Recipe.Name; var instructions = AgentInstructions;
- _agentCancellation = new CancellationTokenSource(); // 每次模型请求和每轮回测分别限时,支持整段视频多轮验证。
+ _agentCancellation = new CancellationTokenSource();
var token = _agentCancellation.Token;
IsAgentBusy = true;
AgentStatus = "正在读取标准 SOP 视频…";
@@ -251,25 +248,15 @@ public partial class RecipeEditorViewModel
+ (string.IsNullOrWhiteSpace(prompt.Compression) ? "" : "\n" + prompt.Compression)));
});
var progress = new Progress(value => { if (IsAgentBusy && ReferenceEquals(_agentCancellation, activeAnalysis)) AgentStatus = value; });
- var verificationRequired = verifyDraft || userMessage is not null && _agentVerificationRequired;
- var verificationTemplate = verifyDraft ? CreateAgentVerificationTemplate() : null;
- Func>? verify = verifyDraft
- ? async (draft, video, cancellation) =>
- {
- runLog?.Write(new("verification_start", 0, JsonSerializer.Serialize(draft)));
- var result = await VerifyAgentDraftAsync(draft, video, verificationTemplate!, progress, cancellation);
- runLog?.Write(new("verification_end", 0, JsonSerializer.Serialize(result)));
- return result;
- } : null;
try
{
runLog = new SopAgentRunLog(DesktopPlatform.WorkspaceRoot, connection.ApiKey);
runLog.Write(new("session_start", 0, JsonSerializer.Serialize(new
{
- Recipe = recipeName, Video = path, Mode = verifyDraft ? "verify_and_revise" : userMessage is null ? "generate" : "chat",
+ Recipe = recipeName, Video = path, Mode = userMessage is null ? "generate" : "chat",
instructions, userMessage, Endpoint = new UriBuilder(endpoint) { UserName = "", Password = "", Query = "", Fragment = "" }.Uri.ToString(),
connection.Model, connection.ContextLength, connection.MaxTokens,
- connection.Temperature, connection.TopP, connection.TimeoutSeconds, MaxFrames = maxFrames, VerifyDraft = verifyDraft
+ connection.Temperature, connection.TopP, connection.TimeoutSeconds, MaxFrames = maxFrames
})));
AgentChatMessages.Add(new("分析日志", "本次分析过程自动保存:" + runLog.Path));
var sample = await Task.Run(() => SopVideoSampler.ReadInfo(path, token), token);
@@ -285,10 +272,7 @@ public partial class RecipeEditorViewModel
AgentChatMessages.Add(new("我", userMessage));
var result = await AgentClient.ChatAsync(new(recipeName, instructions, sample, regions, maxFrames, progress,
userMessage, _agentConversation.ToArray(), CreateAgentDraftSnapshot(), regionDefinitions,
- CreateAgentImageScopes(), VerifyDraft: verify, PromptSent: promptLog, Trace: runLog.Write,
- VerifyCurrentDraftFirst: verifyDraft,
- CheckReference: verifyDraft ? (candidate, video, id, cancellation) => new SopDraftReferenceVerifier().CheckAsync(
- SopDraftConfigBuilder.Build(verificationTemplate!, candidate), candidate, video, id, cancellation) : null,
+ CreateAgentImageScopes(), PromptSent: promptLog, Trace: runLog.Write,
SequenceAvailable: false), connection, token).WaitAsync(token);
token.ThrowIfCancellationRequested();
draft = result.Draft; reply = result.Reply;
@@ -300,7 +284,7 @@ public partial class RecipeEditorViewModel
else
{
draft = await AgentClient.AnalyzeAsync(new(recipeName, instructions, sample, regions, maxFrames, progress,
- RegionDefinitions: regionDefinitions, VerifyDraft: verify, PromptSent: promptLog, Trace: runLog.Write,
+ RegionDefinitions: regionDefinitions, PromptSent: promptLog, Trace: runLog.Write,
SequenceAvailable: false), connection, token).WaitAsync(token);
sample = sample with { Frames = draft.ObservedFrames };
reply = string.IsNullOrWhiteSpace(draft.Summary) ? $"已生成 {draft.Steps.Count} 步。" : draft.Summary;
@@ -309,25 +293,18 @@ public partial class RecipeEditorViewModel
if (draft is not null)
{
SopVideoDraftClient.Validate(draft, sample, regions, regionDefinitions);
- if (verify is not null && draft.Verification is null) draft.Verification = await verify(draft, sample, token);
- token.ThrowIfCancellationRequested();
token.ThrowIfCancellationRequested();
ClearAgentDraft(clearConversation: false, forgetApplied: userMessage is null);
- _agentVerificationRequired = verificationRequired;
+ _agentRegionAdjustments.AddRange(draft.RegionAdjustments);
+ RaisePropertyChanged(nameof(AgentRegionAdjustmentsSummary));
for (var i = 0; i < draft.Steps.Count; i++)
{
var step = draft.Steps[i];
- var actual = draft.Verification?.Images.LastOrDefault(image => image.StepId == i + 1);
- var row = new AgentDraftRow(step, sample.Frames[step.EvidenceFrame], actual);
- row.PropertyChanged += DraftRowChanged;
+ var row = new AgentDraftRow(step, sample.Frames[step.EvidenceFrame]);
AgentDraftSteps.Add(row);
}
- PresentVerification(draft);
AgentSummary = draft.Summary + (draft.Warnings.Count == 0 ? "" : "\n需核对:" + string.Join(";", draft.Warnings));
- AgentStatus = draft.Verification is { Passed: false } ? "草稿回测未通过,未修改配方。可继续对话修订。"
- : draft.Verification?.Passed == true ? $"已更新 {draft.Steps.Count} 步草稿,标准视频回测通过。"
- : _agentVerificationRequired ? $"已更新 {draft.Steps.Count} 步草稿,请单独点击“djev回测”后更新配方。"
- : $"已更新 {draft.Steps.Count} 步草稿。可先编辑或添加到配方,再按需点击“djev回测”。";
+ AgentStatus = $"已更新 {draft.Steps.Count} 步草稿,可编辑或添加到配方。";
}
else AgentStatus = "";
_agentSample = sample;
@@ -336,8 +313,7 @@ public partial class RecipeEditorViewModel
}
catch (OperationCanceledException error)
{
- await WaitForAgentVerificationCleanupAsync();
- AgentStatus = token.IsCancellationRequested ? "分析已取消,当前配方未修改。" : "模型请求或本地回测超时,当前配方未修改。";
+ AgentStatus = token.IsCancellationRequested ? "分析已取消,当前配方未修改。" : "模型请求超时,当前配方未修改。";
AgentChatMessages.Add(new("系统", AgentStatus));
try { runLog?.Write(new("cancelled_or_timeout", 0, error.ToString())); }
catch (Exception logError) when (logError is IOException or UnauthorizedAccessException) { }
@@ -363,16 +339,10 @@ public partial class RecipeEditorViewModel
var definitions = Recipe.ToConfig().Sop.Regions;
try { SopVideoDraftClient.Validate(draft, _agentSample, definitions.Keys.ToArray(), definitions); }
catch (FormatException error) { AgentStatus = "草稿未添加:" + error.Message; return; }
- var resolved = SopDraftConfigBuilder.Build(CreateAgentVerificationTemplate(), draft);
- if (_agentVerificationRequired && (_agentVerifiedFingerprint is null || _agentVerifiedFingerprint != SopDraftConfigBuilder.Fingerprint(resolved, _agentSample)))
- {
- _agentVerifiedFingerprint = null;
- AgentVerificationSummary = "草稿、配方设置或区域已变化,请重新回测后应用。";
- ApplyAgentDraftCommand.RaiseCanExecuteChanged(); return;
- }
+ var resolved = SopDraftConfigBuilder.Build(CreateAgentDraftTemplate(), draft);
var currentVideo = new FileInfo(_agentSample.Path);
if (!currentVideo.Exists || _agentSample.SourceLength > 0 && (currentVideo.Length != _agentSample.SourceLength || currentVideo.LastWriteTimeUtc != _agentSample.SourceModifiedUtc))
- { AgentStatus = "标准视频已变化,请重新生成并回测。"; return; }
+ { AgentStatus = "标准视频已变化,请重新生成。"; return; }
foreach (var adjusted in _agentRegionAdjustments)
{
var source = resolved.Sop.Regions[adjusted.Key];
@@ -398,8 +368,7 @@ public partial class RecipeEditorViewModel
RaisePropertyChanged(nameof(AgentCanEditDraft));
ApplyAgentDraftCommand.RaiseCanExecuteChanged();
RefreshWarnings();
- AgentStatus = $"已写入 {AgentDraftSteps.Count} 步,待保存。"
- + (_agentVerificationRequired && Recipe.Steps.Count > applied.Count ? "已验证草稿步骤;完整配方请到“SOP流程视频”测试。" : "");
+ AgentStatus = $"已写入 {AgentDraftSteps.Count} 步,待保存。";
}
private SopVideoDraft? CreateAgentDraftSnapshot()
@@ -428,7 +397,7 @@ public partial class RecipeEditorViewModel
private IReadOnlyList CreateAgentImageScopes()
{
if (CreateAgentDraftSnapshot() is not { } draft) return [];
- var resolved = SopDraftConfigBuilder.Build(CreateAgentVerificationTemplate(), draft);
+ var resolved = SopDraftConfigBuilder.Build(CreateAgentDraftTemplate(), draft);
return resolved.Sop.Steps.Select((step, index) =>
{
var ai = step.AiConfirmation!;
@@ -438,15 +407,27 @@ public partial class RecipeEditorViewModel
}).ToArray();
}
+ private readonly List _agentRegionAdjustments = [];
+ public string AgentRegionAdjustmentsSummary => string.Join("\n", _agentRegionAdjustments.Select(r =>
+ $"区域建议草稿:{r.Key} [{r.X1},{r.Y1}]–[{r.X2},{r.Y2}] · {r.Note}"));
+
+ private bool CanApplyAgentDraft() => !IsAgentBusy && !_draftApplied && AgentDraftSteps.Count > 0;
+
+ private SopConfig CreateAgentDraftTemplate()
+ {
+ var template = Recipe.ToConfig();
+ var definitions = template.Sop.Steps;
+ template.Sop.Steps = _agentAppliedNodes.Where(Recipe.Steps.Contains)
+ .Select(node => definitions.First(s => s.Id == node.Id)).ToList();
+ return template;
+ }
+
private void ClearAgentConversation() { _agentPromptSession = null; _agentConversation.Clear(); AgentChatMessages.Clear(); }
private void ClearAgentDraft(bool clearConversation = true, bool forgetApplied = true)
{
- foreach (var row in AgentDraftSteps) { row.PropertyChanged -= DraftRowChanged; row.Dispose(); }
- _agentVerifiedFingerprint = null;
- _agentVerificationRequired = false;
+ foreach (var row in AgentDraftSteps) row.Dispose();
_agentRegionAdjustments.Clear();
- AgentVerificationSummary = "";
RaisePropertyChanged(nameof(AgentRegionAdjustmentsSummary));
AgentDraftSteps.Clear(); _agentSample = null; _draftApplied = false; AgentSummary = "";
if (clearConversation) ClearAgentConversation();
@@ -454,7 +435,6 @@ public partial class RecipeEditorViewModel
RaisePropertyChanged(nameof(AgentApplyLabel));
RaisePropertyChanged(nameof(AgentCanEditDraft));
ApplyAgentDraftCommand?.RaiseCanExecuteChanged();
- VerifyAgentDraftCommand?.RaiseCanExecuteChanged();
}
}
@@ -482,10 +462,10 @@ public sealed class AgentDraftRow : BindableBase, IDisposable
+ $";判定:{Step.Inspection?.EvidenceMode ?? "沿用/单帧"};检查窗口:{Step.Inspection?.CheckWindowMs?.ToString() ?? "默认"}ms"
+ (string.IsNullOrWhiteSpace(Region) ? " 触发区域未设置。" : "");
public BitmapSource EvidenceImage { get; }
- public AgentDraftRow(SopDraftStep step, SopVideoFrame frame, SopDraftVerificationImage? actual = null)
+ public AgentDraftRow(SopDraftStep step, SopVideoFrame frame)
{
- Step = step; EvidenceLabel = actual is null ? $"参考画面 {frame.Seconds:F1}s" : $"回测送检 {actual.Seconds:F1}s · {actual.Confidence:P1}";
- using var image = Cv2.ImDecode(actual?.Jpeg ?? frame.Jpeg, ImreadModes.Color);
+ Step = step; EvidenceLabel = $"参考画面 {frame.Seconds:F1}s";
+ using var image = Cv2.ImDecode(frame.Jpeg, ImreadModes.Color);
EvidenceImage = BitmapSource.Create(image.Width, image.Height, 96, 96, PixelFormats.Bgr24, null,
image.Data, checked((int)(image.Step() * image.Height)), checked((int)image.Step()));
}
diff --git a/tests/VideoFlowTest.Smoke/AgentBenchmarkChecks.cs b/tests/VideoFlowTest.Smoke/AgentBenchmarkChecks.cs
index 5feae8c..e3916c7 100644
--- a/tests/VideoFlowTest.Smoke/AgentBenchmarkChecks.cs
+++ b/tests/VideoFlowTest.Smoke/AgentBenchmarkChecks.cs
@@ -30,7 +30,7 @@ internal static class AgentBenchmarkChecks
Number("contextLength", 131702), Number("maxTokens", 8192), Decimal("temperature", .2), Decimal("topP", .9), Number("timeoutSeconds", 300),
disableThinking ? false : root.TryGetProperty("enableThinking", out var agentThinking) && agentThinking.ValueKind != JsonValueKind.Null ? agentThinking.GetBoolean() : null);
var template = SopConfigLoader.Load(configPath);
- // 与界面未应用草稿的 CreateAgentVerificationTemplate 一致,不能继承不相关旧步骤的送检区。
+ // 与界面未应用草稿的 CreateAgentDraftTemplate 一致,不能继承不相关旧步骤的送检区。
template.Sop.Steps = [];
var original = File.ReadAllBytes(configPath);
var video = SopVideoSampler.ReadInfo(videoPath, default);
diff --git a/tests/VideoFlowTest.Smoke/AgentDraftVerificationChecks.cs b/tests/VideoFlowTest.Smoke/AgentDraftGenerationChecks.cs
similarity index 69%
rename from tests/VideoFlowTest.Smoke/AgentDraftVerificationChecks.cs
rename to tests/VideoFlowTest.Smoke/AgentDraftGenerationChecks.cs
index c7b8fa2..4249099 100644
--- a/tests/VideoFlowTest.Smoke/AgentDraftVerificationChecks.cs
+++ b/tests/VideoFlowTest.Smoke/AgentDraftGenerationChecks.cs
@@ -10,26 +10,26 @@ using SopHelper.Training;
using SopHelper.VVMs.RecipeEditor;
using Window = Avalonia.Controls.Window;
-internal static class AgentDraftVerificationChecks
+internal static class AgentDraftGenerationChecks
{
public static void Run(string root)
{
var store = new RecipeWorkspace(root);
Directory.CreateDirectory(root);
- var video = Path.Combine(root, "agent-verification.avi");
+ var video = Path.Combine(root, "agent-generation.avi");
using (var writer = new VideoWriter(video, FourCC.MJPG, 10, new OpenCvSharp.Size(64, 48)))
{
- Check(writer.IsOpened(), "Agent verification test video opens");
+ Check(writer.IsOpened(), "Agent generation test video opens");
for (var i = 0; i < 20; i++) { using var image = new Mat(48, 64, MatType.CV_8UC3, new Scalar(20, 50, 100)); writer.Write(image); }
}
- var config = new SopConfig(); config.Sop.Name = "代理草稿验证"; config.Sop.Parts = [];
+ var config = new SopConfig(); config.Sop.Name = "代理草稿生成"; config.Sop.Parts = [];
ReferenceEvidenceChecks.Run(video);
config.Sop.Regions["work"] = new() { X2 = 64, Y2 = 48 };
config.Sop.Steps = [new() { Id = 1, Name = "保留人工步骤", Description = "人工要求" }];
Directory.CreateDirectory(Path.Combine(root,"workspace"));
File.WriteAllText(Path.Combine(root,"workspace","sop-agent.json"),"{\"endpoint\":\"http://127.0.0.1:1/v1\",\"model\":\"unit-test\",\"autoVerify\":true}");
var model = new RecipeEditorViewModel();
- var verifier = new ProbeVerifier(); var client = new ProbeClient(); model.DraftVerifier = verifier; model.AgentClient = client;
+ var client = new ProbeClient(); model.AgentClient = client;
model.OnDialogOpened(new DialogParameters { { "directory", store.RecipesDirectory }, { "config", config }, { "new", true } });
model.SaveCommand.Execute();
var path = store.ConfigPath(config.Sop.Name); var before = File.ReadAllBytes(path);
@@ -42,19 +42,23 @@ internal static class AgentDraftVerificationChecks
var window = new Window { Width = 1040, Height = 900, Content = view }; window.Show(); window.UpdateLayout();
var tabs = view.GetVisualDescendants().OfType().Single();
tabs.SelectedItem = tabs.Items.OfType().Single(t => t.Header?.ToString() == "Agent助手"); window.UpdateLayout();
- Check(view.GetVisualDescendants().OfType