P2AF 收口自动化后续和默认冻结口径
这个提交包含在:
@@ -26,6 +26,7 @@ function parseArgs(argv) {
|
||||
json: false,
|
||||
strict: false,
|
||||
manifest: process.env.OCR_PROVIDER_SAMPLE_MANIFEST || "",
|
||||
imageEvaluation: process.env.OCR_IMAGE_OCR_EVALUATION === "1",
|
||||
};
|
||||
|
||||
for (const arg of argv) {
|
||||
@@ -33,6 +34,8 @@ function parseArgs(argv) {
|
||||
options.json = true;
|
||||
} else if (arg === "--strict") {
|
||||
options.strict = true;
|
||||
} else if (arg === "--image-evaluation") {
|
||||
options.imageEvaluation = true;
|
||||
} else if (arg.startsWith("--provider=")) {
|
||||
options.provider = arg.slice("--provider=".length);
|
||||
} else if (arg.startsWith("--manifest=")) {
|
||||
@@ -164,6 +167,16 @@ function loadEnvSamples() {
|
||||
return samples;
|
||||
}
|
||||
|
||||
function hasExplicitImageEnv() {
|
||||
return [
|
||||
"PLAYWRIGHT_OCR_IMAGE_FILE",
|
||||
"PLAYWRIGHT_OCR_IMAGE_FILES",
|
||||
"PLAYWRIGHT_OCR_IMAGE_DIR",
|
||||
"LIVE_OCR_IMAGE_FILE",
|
||||
"LIVE_OCR_IMAGE_DIR",
|
||||
].some((key) => Boolean(process.env[key]?.trim()));
|
||||
}
|
||||
|
||||
function dedupeSamples(samples) {
|
||||
const seen = new Set();
|
||||
const result = [];
|
||||
@@ -274,7 +287,8 @@ async function checkSample(provider, config, sample) {
|
||||
}
|
||||
}
|
||||
|
||||
function buildDecision(results, manifestError) {
|
||||
function buildDecision(results, manifestError, imageEvaluation) {
|
||||
if (!imageEvaluation) return "FREEZE_BY_DEFAULT";
|
||||
if (manifestError) return "HOLD_FOR_SAMPLE";
|
||||
if (!results.length) return "HOLD_FOR_SAMPLE";
|
||||
const imageResults = results.filter((item) => item.kind === "image");
|
||||
@@ -285,7 +299,7 @@ function buildDecision(results, manifestError) {
|
||||
|
||||
function printHuman(summary) {
|
||||
console.log(`[ocr-provider-samples] status=${summary.status} decision=${summary.decision}`);
|
||||
console.log(`[ocr-provider-samples] provider=${summary.provider} samples=${summary.counts.total} pdf=${summary.counts.pdf} image=${summary.counts.image}`);
|
||||
console.log(`[ocr-provider-samples] provider=${summary.provider} imageEvaluation=${summary.imageEvaluation} samples=${summary.counts.total} pdf=${summary.counts.pdf} image=${summary.counts.image}`);
|
||||
if (summary.manifestError) {
|
||||
console.log(`[ocr-provider-samples] manifest=${summary.manifestError}`);
|
||||
}
|
||||
@@ -307,12 +321,13 @@ async function main() {
|
||||
const samples = dedupeSamples([...manifest.samples, ...loadEnvSamples()]);
|
||||
const config = getTencentConfig();
|
||||
const results = [];
|
||||
const imageEvaluation = options.imageEvaluation || Boolean(options.manifest) || hasExplicitImageEnv();
|
||||
|
||||
for (const sample of samples) {
|
||||
results.push(await checkSample(options.provider, config, sample));
|
||||
}
|
||||
|
||||
const decision = buildDecision(results, manifest.error);
|
||||
const decision = buildDecision(results, manifest.error, imageEvaluation);
|
||||
const failed = results.some((item) => item.status === "HOLD");
|
||||
const skipped = !results.length || results.some((item) => item.status === "SKIP");
|
||||
const summary = {
|
||||
@@ -320,6 +335,7 @@ async function main() {
|
||||
provider: options.provider,
|
||||
status: failed ? "HOLD" : skipped ? "SKIP" : "PASS",
|
||||
decision,
|
||||
imageEvaluation,
|
||||
manifestProvided: Boolean(options.manifest),
|
||||
manifestError: manifest.error,
|
||||
credentialReady: hasTencentCredentials(config),
|
||||
|
||||
在新工单中引用
屏蔽一个用户