feat(crawler): add pixelrag visual evidence lane
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-09 16:53:08 +08:00
parent 5d6737599c
commit 19e8bf9cbc
4 changed files with 860 additions and 0 deletions

View File

@@ -51,3 +51,39 @@ python scripts/tools/browse_sh_probe.py -- screenshot
- PChome目前已有搜尋 API 與商品 API`browse` 只用於確認 API 參數、分頁行為、前端是否切新 endpoint。
- MOMO若既有 BeautifulSoup selector 失效,先用 `browse` 找出前端實際 XHR找到 API 時優先改成 structured API parser。
- Matcher`browse` 只提供候選證據;是否為同款仍由 `marketplace_product_matcher.score_marketplace_match()` 決定。
## PixelRAG-style 視覺證據 fallback
2026-07-09 評估 PixelRAG 後結論是「可導入但不可直接取代正式爬蟲」。PixelRAG 的核心價值是把渲染後頁面截圖切成 tiles讓 AI 讀到 HTML parser 可能丟失的視覺結構;本專案第一階段只採用這個視覺證據思路,不直接拉外部 runtime、不用外部 embedding API、不把像素結果寫入正式價格表。
導入順序:
1. 既有 PChome API / MOMO structured parser 先跑;若 parser 結果為空、價格欄位缺失、規格/組合資訊疑似只存在渲染畫面,才啟動視覺證據 fallback。
2. Phase 1 只輸出 screenshot/tile manifestURL、platform、crawler、parse failure、viewport、tile coordinates、artifact path、evidence intent。
3. Phase 2 用 manifest 收集 replay samples對照 `marketplace_product_matcher``competitor_match_attempts` 的診斷結果,評估是否提高身份證據覆蓋率。
4. Phase 3 才評估 Ollama-first multimodal embedding未完成 GCP-A → GCP-B → 111 視覺 embedding 驗證前,不做自動像素檢索。
5. Phase 4 若需要索引,優先設計 pgvector-compatible evidence metadataFAISS 只能先當本地研究/ADR 候選,不直接進 production。
6. Phase 5 才談 crawler fusion正式 `competitor_prices` / `competitor_price_history` 寫入仍需 matcher replay/canary 證據。
機器可讀評估:
```bash
python scripts/ops/report_pixelrag_crawler_integration.py
python scripts/ops/report_pixelrag_crawler_integration.py --platform momo
python scripts/ops/report_pixelrag_crawler_integration.py --capability ollama_multimodal_ready --capability pgvector_visual_ready
python scripts/ops/report_pixelrag_crawler_integration.py \
--platform momo \
--manifest-url "https://m.momoshop.com.tw/search.momo?searchKeyword=test" \
--crawler MomoCrawler.search_products \
--trigger-reason parser_empty \
--page-size page=1440x1900 \
--tile-size tile=512x512
```
安全邊界:
- read-only不登入、不下單、不加入購物車、不寫第三方狀態。
- 不從像素結果直接寫正式價格或同款判斷,只寫 artifact / review diagnostics。
- 不使用 GitHub runtime 依賴;不讀 secrets / sessions / cookies。
- 不呼叫 hosted embedding / VLM API如需 embedding必須走 Ollama-first 並保留成本/品質 benchmark。
- 若穩定 XHR/API 可取得同樣資訊,仍優先回補 structured parser不把視覺 fallback 變成主路徑。