fix(ai): classify empty PixelRAG VLM offers as platform barriers
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
This commit is contained in:
@@ -177,6 +177,73 @@ def test_pixelrag_vlm_replay_worker_writes_model_error_receipt(tmp_path, monkeyp
|
||||
assert receipt["next_machine_action"] == "repair_ollama_vlm_runtime_or_model_route"
|
||||
|
||||
|
||||
def test_pixelrag_vlm_replay_worker_empty_fields_routes_to_platform_probe(tmp_path, monkeypatch):
|
||||
from services import pixelrag_vlm_replay_worker_service as service
|
||||
|
||||
_write_receipt(
|
||||
tmp_path,
|
||||
platform="shopee_tw",
|
||||
manifest_id="shopee-language",
|
||||
title="蝦皮購物 | 花得更少買得更好",
|
||||
url="https://shopee.tw/search?keyword=sunscreen",
|
||||
)
|
||||
|
||||
class FakeOllama:
|
||||
def __init__(self, model):
|
||||
self.model = model
|
||||
|
||||
def generate(self, *args, **kwargs):
|
||||
return SimpleNamespace(
|
||||
success=True,
|
||||
content=json.dumps({
|
||||
"blocked_page_detected": False,
|
||||
"fields": {
|
||||
"title": {"value": None, "confidence": 0.0, "evidence_refs": []},
|
||||
"price": {"value": None, "confidence": 0.0, "evidence_refs": []},
|
||||
"currency": {"value": None, "confidence": 0.0, "evidence_refs": []},
|
||||
},
|
||||
"quality": {
|
||||
"overall_confidence": 0.0,
|
||||
"missing_required_fields": [],
|
||||
"requires_identity_matcher_replay": True,
|
||||
"requires_promotion_gate": True,
|
||||
},
|
||||
"notes": [],
|
||||
}),
|
||||
model="minicpm-v:latest",
|
||||
error=None,
|
||||
total_duration=2.0,
|
||||
host="http://192.168.0.111:11434",
|
||||
input_tokens=10,
|
||||
output_tokens=40,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(service, "OllamaService", FakeOllama)
|
||||
payload = service.run_pixelrag_ollama_vlm_replay_worker(
|
||||
artifact_root=tmp_path,
|
||||
output_root=tmp_path / "receipts",
|
||||
platform="shopee_tw",
|
||||
execute=True,
|
||||
write_receipt=True,
|
||||
tile_limit=4,
|
||||
auto_select_model=False,
|
||||
)
|
||||
|
||||
assert payload["status"] == "warning"
|
||||
assert payload["summary"]["executed_warning_count"] == 1
|
||||
assert payload["summary"]["required_field_missing_count"] == 2
|
||||
assert payload["next_machine_action"] == "rerun_vlm_replay_with_more_tiles_or_platform_probe"
|
||||
item = payload["worker_items"][0]
|
||||
assert item["worker_status"] == "executed_warning"
|
||||
assert item["next_machine_action"] == "run_platform_probe_or_use_structured_api"
|
||||
assert item["validation"]["present_field_count"] == 0
|
||||
assert item["validation"]["non_product_or_interstitial_detected"] is True
|
||||
assert item["validation"]["valid_for_identity_matcher_replay"] is False
|
||||
receipt_path = tmp_path / "receipts" / "shopee_tw" / "shopee-language" / "vlm_replay_receipt.json"
|
||||
receipt = json.loads(receipt_path.read_text(encoding="utf-8"))
|
||||
assert receipt["next_machine_action"] == "run_platform_probe_or_use_structured_api"
|
||||
|
||||
|
||||
def test_pixelrag_vlm_replay_worker_auto_selects_installed_candidate(tmp_path, monkeypatch):
|
||||
from services import pixelrag_vlm_replay_worker_service as service
|
||||
|
||||
|
||||
Reference in New Issue
Block a user