fix(ai): 保留 PixelRAG VLM model error receipt
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:
@@ -123,6 +123,54 @@ def test_pixelrag_vlm_replay_worker_execute_writes_artifact_receipt(tmp_path, mo
|
||||
assert receipt["parsed_output"]["fields"]["title"]["value"] == "防曬乳 SPF50"
|
||||
|
||||
|
||||
def test_pixelrag_vlm_replay_worker_writes_model_error_receipt(tmp_path, monkeypatch):
|
||||
from services import pixelrag_vlm_replay_worker_service as service
|
||||
|
||||
_write_receipt(
|
||||
tmp_path,
|
||||
platform="shopee_tw",
|
||||
manifest_id="shopee-ok",
|
||||
title="Shopee 防曬乳",
|
||||
url="https://shopee.tw/search?keyword=sunscreen",
|
||||
)
|
||||
|
||||
class FakeOllama:
|
||||
def __init__(self, model):
|
||||
self.model = model
|
||||
|
||||
def generate(self, *args, **kwargs):
|
||||
return SimpleNamespace(
|
||||
success=False,
|
||||
content="",
|
||||
model="minicpm-v:latest",
|
||||
error="all hosts failed",
|
||||
total_duration=None,
|
||||
host="http://34.21.145.224:11434",
|
||||
input_tokens=0,
|
||||
output_tokens=0,
|
||||
)
|
||||
|
||||
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=1,
|
||||
)
|
||||
|
||||
assert payload["status"] == "critical"
|
||||
assert payload["summary"]["model_error_count"] == 1
|
||||
assert payload["summary"]["receipt_written_count"] == 1
|
||||
assert payload["summary"]["artifact_write_performed"] is True
|
||||
assert payload["controlled_apply"]["writes_database"] is False
|
||||
receipt_path = tmp_path / "receipts" / "shopee_tw" / "shopee-ok" / "vlm_replay_receipt.json"
|
||||
receipt = json.loads(receipt_path.read_text(encoding="utf-8"))
|
||||
assert receipt["worker_status"] == "model_error"
|
||||
assert receipt["next_machine_action"] == "repair_ollama_vlm_runtime_or_model_route"
|
||||
|
||||
|
||||
def test_pixelrag_vlm_replay_worker_cli_outputs_machine_readable_json(tmp_path):
|
||||
_write_receipt(
|
||||
tmp_path,
|
||||
|
||||
Reference in New Issue
Block a user