feat(ai): 建立 PixelRAG OCR VLM replay contract

This commit is contained in:
ogt
2026-07-09 23:01:54 +08:00
parent 1bbf73a176
commit a72713af1e
12 changed files with 739 additions and 14 deletions

View File

@@ -0,0 +1,60 @@
#!/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())