避免视觉判定将完成条件当作已知事实并要求图片证据

This commit is contained in:
tfarcraw 2026-11-18 00:00:48 +08:00
parent 61685187e6
commit b47dda9fb8
2 changed files with 6 additions and 2 deletions

View File

@ -23,14 +23,15 @@ public sealed class D3VisionDecisionClient(HttpClient http) : IVisionDecisionCli
if (!string.IsNullOrWhiteSpace(key)) message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);
message.Content = JsonContent.Create(new
{
state = $"当前步骤:{request.Step}。{request.Description}",
// 完成判据是待验证假设,不能在 state 中当作已知事实重复陈述。
state = "正在检查当前工位图片。完成条件是待验证的假设,不代表已经发生。",
images = new[] { "data:image/jpeg;base64," + Convert.ToBase64String(request.Jpeg) },
questions = new
{
step_completed = new
{
type = "noul",
instructions = $"图片里是否满足这个完成条件:{request.Criteria}"
instructions = $"仅依据当前图片中清晰可见的证据判断。看不到判据要求的目标或关键部位、存在遮挡或不能确认时回答否。图片里是否满足这个完成条件:{request.Criteria}"
}
}
});

View File

@ -29,6 +29,9 @@ internal static class D3Checks
using var body = JsonDocument.Parse(handler.Body!);
Check(body.RootElement.GetProperty("images")[0].GetString() == "data:image/jpeg;base64,AQID", "D3 必须发送准确的 JPEG 字节");
Check(body.RootElement.GetProperty("questions").GetProperty("step_completed").GetProperty("instructions").GetString()!.Contains(request.Criteria), "D3 必须发送中文完成条件");
var state = body.RootElement.GetProperty("state").GetString()!;
Check(!state.Contains(request.Description) && !state.Contains(request.Criteria) && state.Contains("待验证"), "D3 不得将待检查的完成判据预先陈述为已知状态");
Check(body.RootElement.GetProperty("questions").GetProperty("step_completed").GetProperty("instructions").GetString()!.Contains("不能确认时回答否"), "D3 必须要求图片证据不足时拒绝通过");
handler.Content = """{"answers":{"step_completed":{"type":"noul","noul":0.02}}}""";
decision = await client.DecideAsync(request, default);
Check(!decision.Completed && decision.Confidence == .02, "D3 不得将否定答案的置信度当成完成概率");