Files
ewoooc/scripts/ops/report_pixelrag_ocr_vlm_replay.py

61 lines
1.6 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Report PixelRAG receipts as OCR/VLM replay contracts."""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from services.pixelrag_ocr_vlm_replay_service import ( # noqa: E402
build_pixelrag_ocr_vlm_replay_contract,
)
def main() -> int:
parser = argparse.ArgumentParser(
description="輸出 PixelRAG receipt 的 no-write OCR/VLM replay contract。"
)
parser.add_argument(
"--artifact-root",
help="PixelRAG visual evidence artifact root預設使用 production/container 設定。",
)
parser.add_argument(
"--platform",
action="append",
dest="platforms",
help="限制平台,可重複指定,例如 --platform shopee_tw --platform coupang_tw。",
)
parser.add_argument(
"--max-age-hours",
type=int,
default=168,
help="receipt 最大新鮮度小時數。",
)
parser.add_argument(
"--limit",
type=int,
default=50,
help="最多輸出 receipt contract 數。",
)
args = parser.parse_args()
payload = build_pixelrag_ocr_vlm_replay_contract(
artifact_root=args.artifact_root,
platform=tuple(args.platforms or ()),
max_age_hours=args.max_age_hours,
limit=args.limit,
)
print(json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True))
return 0 if payload.get("success") else 1
if __name__ == "__main__":
raise SystemExit(main())