feat(review): 取证层多源化 + 视觉多图(整体+2x2 象限)
- 新增 evidence_model.py:统一证据模型(source_type + images 列表),访问器兼容旧 image_b64/image_mime 单图字段 - phases/evidence.py:新增 collect() 多源分发 seam(仅 CAD)、capture_images() 整体+等分象限多图(结束复位视口)、sub_windows() - phases/review.py:多图逐张下采样喂 LLM,payload 增加 source_type - config.py:EVIDENCE_DETAIL_TILES=4 / EVIDENCE_MAX_IMAGES=5(默认开启多图) - 新增 tests/test_evidence_model.py,更新 evidence/review 断言与 fakes 归一
This commit is contained in:
1 parent
22db93b6f5
commit
1c9fc72839
10 files changed
+396
-32
No files matched your search
+57
-5
@@ -55,8 +55,8 @@ def test_collect_frame_assembles_evidence():
|
||||
assert ev["dimensions"]["total"] == 2
|
||||
assert ev["blocks"]["total"] == 0
|
||||
assert ev["polylines"]["total"] == 3
|
||||
assert ev["image_b64"] == "QUJD"
|
||||
assert ev["image_mime"] == "image/png"
|
||||
assert ev["source_type"] == "cad"
|
||||
assert ev["images"] == [{"b64": "QUJD", "mime": "image/png", "label": "overall"}]
|
||||
|
||||
|
||||
def test_collect_frame_calls_expected_tools():
|
||||
@@ -80,12 +80,64 @@ def test_collect_frame_calls_expected_tools():
|
||||
def test_collect_frame_without_image():
|
||||
ctx = make_ctx(client=build_evidence_client(image=ok_text({})))
|
||||
ev = collect_frame(ctx, 1, frame([0, 0, 10, 10]))
|
||||
assert ev["image_b64"] is None
|
||||
assert ev["image_mime"] is None
|
||||
assert ev["images"] == []
|
||||
|
||||
|
||||
def test_collect_frame_tolerates_empty_structured_data():
|
||||
ctx = make_ctx(client=FakeMcpClient()) # 全部默认 ok_text({})
|
||||
ev = collect_frame(ctx, 1, frame([0, 0, 10, 10]))
|
||||
assert ev["entities"] == {}
|
||||
assert ev["image_b64"] is None
|
||||
assert ev["images"] == []
|
||||
|
||||
|
||||
def test_sub_windows_2x2():
|
||||
from dwg_review.phases.evidence import sub_windows
|
||||
|
||||
win = {"min_x": 0.0, "min_y": 0.0, "max_x": 10.0, "max_y": 10.0}
|
||||
subs = sub_windows(win, 4)
|
||||
assert len(subs) == 4
|
||||
# 行优先:左上 → 右上 → 左下 → 右下
|
||||
assert subs[0] == {"min_x": 0.0, "min_y": 5.0, "max_x": 5.0, "max_y": 10.0}
|
||||
assert subs[1] == {"min_x": 5.0, "min_y": 5.0, "max_x": 10.0, "max_y": 10.0}
|
||||
assert subs[2] == {"min_x": 0.0, "min_y": 0.0, "max_x": 5.0, "max_y": 5.0}
|
||||
assert subs[3] == {"min_x": 5.0, "min_y": 0.0, "max_x": 10.0, "max_y": 5.0}
|
||||
|
||||
|
||||
def test_sub_windows_disabled():
|
||||
from dwg_review.phases.evidence import sub_windows
|
||||
|
||||
win = {"min_x": 0.0, "min_y": 0.0, "max_x": 10.0, "max_y": 10.0}
|
||||
assert sub_windows(win, 0) == []
|
||||
assert sub_windows(win, 1) == []
|
||||
|
||||
|
||||
def test_collect_frame_captures_multiple_images(monkeypatch):
|
||||
from dwg_review import config
|
||||
from dwg_review.phases.evidence import collect_frame
|
||||
|
||||
monkeypatch.setattr(config, "EVIDENCE_DETAIL_TILES", 4)
|
||||
ctx = make_ctx(client=build_evidence_client())
|
||||
ev = collect_frame(ctx, 1, frame([0, 0, 100, 50]))
|
||||
assert [img["label"] for img in ev["images"]] == [
|
||||
"overall",
|
||||
"tile-1",
|
||||
"tile-2",
|
||||
"tile-3",
|
||||
"tile-4",
|
||||
]
|
||||
|
||||
|
||||
def test_collect_dispatches_cad_source():
|
||||
from dwg_review.phases.evidence import collect
|
||||
|
||||
ctx = make_ctx(client=build_evidence_client())
|
||||
ev = collect(ctx, 1, frame([0, 0, 10, 10]))
|
||||
assert ev is not None
|
||||
assert ev["source_type"] == "cad"
|
||||
|
||||
|
||||
def test_collect_returns_none_for_unsupported_source():
|
||||
from dwg_review.phases.evidence import collect
|
||||
|
||||
ctx = make_ctx(client=FakeMcpClient())
|
||||
assert collect(ctx, 1, {"source_type": "pdf", "bbox": [0, 0, 1, 1]}) is None
|
||||
Reference in new issue
Block a user