提供可复现实测参数的时序模型思考开关
This commit is contained in:
parent
54af738dc1
commit
f5f3adad10
@ -29,7 +29,9 @@ public sealed class DesktopSequenceVisionClient(HttpClient http) : IVisionDecisi
|
||||
if (root.TryGetProperty("useForSequence", out var enabled) && enabled.GetBoolean())
|
||||
_client = new(http, new(root.GetProperty("endpoint").GetString() ?? "",
|
||||
root.GetProperty("model").GetString() ?? "",
|
||||
root.TryGetProperty("apiKey", out var key) ? key.GetString() ?? "" : ""));
|
||||
root.TryGetProperty("apiKey", out var key) ? key.GetString() ?? "" : "",
|
||||
root.TryGetProperty("sequenceEnableThinking", out var thinking) && thinking.ValueKind != JsonValueKind.Null
|
||||
? thinking.GetBoolean() : null));
|
||||
}
|
||||
catch (Exception error) when (error is IOException or UnauthorizedAccessException or JsonException or InvalidOperationException or KeyNotFoundException)
|
||||
{ _client = new(http, new("", "")); }
|
||||
|
||||
@ -195,7 +195,7 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto,Auto,Auto">
|
||||
<TextBlock Text="最低完成概率(0–1)" VerticalAlignment="Center" />
|
||||
<TextBlock Text="最低完成置信度(0–1)" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiMinConfidence, Mode=TwoWay}" Minimum="0" Maximum="1" Increment="0.05" FormatString="0.00" />
|
||||
<TextBlock Grid.Row="1" Text="重试间隔(毫秒)" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Row="1" Grid.Column="1" Value="{Binding AiRetryDelayMs, Mode=TwoWay}" Minimum="500" Maximum="600000" Increment="500" />
|
||||
@ -514,6 +514,7 @@
|
||||
<TextBox Grid.Column="1" Text="{Binding AgentApiKey, Mode=TwoWay}" PasswordChar="●" />
|
||||
</Grid>
|
||||
<CheckBox Content="同时用于过程时序判定(模型须支持多图)" IsChecked="{Binding AgentUseForSequence, Mode=TwoWay}" />
|
||||
<CheckBox Content="过程判定启用模型思考" IsThreeState="True" IsEnabled="{Binding AgentUseForSequence}" IsChecked="{Binding AgentSequenceEnableThinking, Mode=TwoWay}" ToolTip.Tip="适用于支持思考开关的服务;横线沿用服务默认,取消勾选可减少推导耗时。" />
|
||||
<Expander Header="参数">
|
||||
<Grid ColumnDefinitions="80,*,80,*" RowDefinitions="Auto,Auto,Auto">
|
||||
<TextBlock Text="上下文长度" VerticalAlignment="Center" />
|
||||
|
||||
@ -24,6 +24,8 @@ public partial class RecipeEditorViewModel
|
||||
private bool _isAgentBusy, _draftApplied;
|
||||
private bool _agentSettingsLoaded, _agentUseForSequence;
|
||||
public bool AgentUseForSequence { get => _agentUseForSequence; set { if (SetProperty(ref _agentUseForSequence, value)) SaveAgentSettings(); } }
|
||||
private bool? _agentSequenceEnableThinking;
|
||||
public bool? AgentSequenceEnableThinking { get => _agentSequenceEnableThinking; set { if (SetProperty(ref _agentSequenceEnableThinking, value)) SaveAgentSettings(); } }
|
||||
private string _agentEndpoint = "", _agentModel = "", _agentApiKey = "", _agentVideoPath = "", _agentInstructions = "";
|
||||
private string _agentStatus = "", _agentSummary = "";
|
||||
private int _agentMaxFrames = 3;
|
||||
@ -118,6 +120,7 @@ public partial class RecipeEditorViewModel
|
||||
AgentApiKey = document.RootElement.TryGetProperty("apiKey", out var key) ? key.GetString() ?? "" : "";
|
||||
var root = document.RootElement;
|
||||
if (root.TryGetProperty("useForSequence", out var sequence)) AgentUseForSequence = sequence.GetBoolean();
|
||||
if (root.TryGetProperty("sequenceEnableThinking", out var thinking)) AgentSequenceEnableThinking = thinking.ValueKind == JsonValueKind.Null ? null : thinking.GetBoolean();
|
||||
if (root.TryGetProperty("maxFrames", out var frames)) AgentMaxFrames = frames.GetInt32();
|
||||
if (root.TryGetProperty("contextLength", out var context)) AgentContextLength = context.GetInt32();
|
||||
if (root.TryGetProperty("maxTokens", out var output)) AgentMaxTokens = output.GetInt32();
|
||||
@ -146,7 +149,8 @@ public partial class RecipeEditorViewModel
|
||||
if (!OperatingSystem.IsWindows()) options.UnixCreateMode = UnixFileMode.UserRead | UnixFileMode.UserWrite;
|
||||
using (var stream = new FileStream(temporary, options))
|
||||
JsonSerializer.Serialize(stream, new { endpoint = AgentEndpoint, model = AgentModel, apiKey = AgentApiKey,
|
||||
useForSequence = AgentUseForSequence, maxFrames = AgentMaxFrames, contextLength = AgentContextLength, maxTokens = AgentMaxTokens,
|
||||
useForSequence = AgentUseForSequence, sequenceEnableThinking = AgentSequenceEnableThinking,
|
||||
maxFrames = AgentMaxFrames, contextLength = AgentContextLength, maxTokens = AgentMaxTokens,
|
||||
temperature = AgentTemperature, topP = AgentTopP, timeoutSeconds = AgentTimeoutSeconds });
|
||||
File.Move(temporary, AgentSettingsPath, overwrite: true);
|
||||
}
|
||||
|
||||
@ -34,6 +34,9 @@ internal static class AgentDraftVerificationChecks
|
||||
model.SaveCommand.Execute();
|
||||
var path = store.ConfigPath(config.Sop.Name); var before = File.ReadAllBytes(path);
|
||||
model.AgentVideoPath = video; model.AgentEndpoint = "http://127.0.0.1:1/v1"; model.AgentModel = "unit-test";
|
||||
model.AgentSequenceEnableThinking = false;
|
||||
using (var saved = System.Text.Json.JsonDocument.Parse(File.ReadAllText(Path.Combine(root, "workspace", "sop-agent.json"))))
|
||||
Check(!saved.RootElement.GetProperty("sequenceEnableThinking").GetBoolean(), "时序思考设置须可持久化,便于复现实测参数");
|
||||
var view = new RecipeEditor { DataContext = model };
|
||||
var window = new Window { Width = 1040, Height = 900, Content = view }; window.Show(); window.UpdateLayout();
|
||||
var tabs = view.GetVisualDescendants().OfType<TabControl>().Single();
|
||||
|
||||
@ -12,6 +12,9 @@ internal static class SequenceProtocolTests
|
||||
{
|
||||
using var body = JsonDocument.Parse(await request.Content!.ReadAsStringAsync(token));
|
||||
Check(body.RootElement.GetProperty("max_tokens").GetInt32() == 768, "时序接口应限制解释输出预算");
|
||||
Check(mode == "backdated"
|
||||
? !body.RootElement.GetProperty("chat_template_kwargs").GetProperty("enable_thinking").GetBoolean()
|
||||
: !body.RootElement.TryGetProperty("chat_template_kwargs", out _), "思考开关必须按显式选择发送,默认沿用服务设置");
|
||||
var parts = body.RootElement.GetProperty("messages")[1].GetProperty("content");
|
||||
Check(parts.EnumerateArray().Count(p => p.GetProperty("type").GetString() == "image_url") == 3,
|
||||
"必须发送三张真实证据,不能把时序请求退化为尾图");
|
||||
@ -30,7 +33,7 @@ internal static class SequenceProtocolTests
|
||||
foreach (var mode in new[] { "valid", "backdated", "fabricated", "truncated" })
|
||||
{
|
||||
using var http = new HttpClient(new Handler(mode));
|
||||
var client = new SequenceVisionDecisionClient(http, new("https://probe.invalid/v1", "test-model"));
|
||||
var client = new SequenceVisionDecisionClient(http, new("https://probe.invalid/v1", "test-model", EnableThinking: mode == "backdated" ? false : null));
|
||||
var result = await client.DecideAsync(request, default);
|
||||
Check(result.Completed == (mode is "valid" or "backdated") && (mode is "valid" or "backdated" || result.EffectiveStatus == VisionDecisionStatus.Insufficient),
|
||||
"缩短输出预算后仍须拒绝虚构帧和被截断的判定");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user