Giữ block ảnh, QR, con dấu, chữ ký rỗng của model
validate_response từ chối mọi block có html rỗng, trong khi model trả đúng như thế cho các vùng không có chữ: xem chính dla_example_document.json, các block Image, QR Code, Stamp, Signature đều có "html": "". Nghĩa là mọi trang có con dấu hay QR đều bị coi là output hỏng, retry 3 lần rồi thành trang lỗi. Chỉ block chữ mà rỗng mới là output hỏng; thông báo lỗi kèm luôn nhãn. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -322,6 +322,26 @@ def test_kie_prompt_schema_and_answer_shape():
|
||||
assert kie.select_pages(20, 5) == [1, 2, 3, 4, 20]
|
||||
|
||||
|
||||
def test_keeps_empty_visual_blocks_but_rejects_empty_text_blocks():
|
||||
"""Model trả div rỗng cho con dấu, QR, chữ ký; chỉ block chữ mà rỗng mới là output hỏng."""
|
||||
def response(content):
|
||||
return {"choices": [{"finish_reason": "stop", "message": {"content": content}}]}
|
||||
|
||||
blocks = validate_response(response(
|
||||
'<div data-label="Stamp" data-bbox="736 86 909 142"></div>'
|
||||
'<div data-label="QR Code" data-bbox="814 55 896 112"></div>'
|
||||
'<div data-label="Paragraph" data-bbox="92 85 795 151"><p>Nội dung</p></div>'))
|
||||
assert [block["label"] for block in blocks] == ["Stamp", "QR Code", "Paragraph"]
|
||||
assert [block["html"] for block in blocks[:2]] == ["", ""]
|
||||
|
||||
try:
|
||||
validate_response(response('<div data-label="Paragraph" data-bbox="1 1 500 500"></div>'))
|
||||
except InvalidOutput as exc:
|
||||
assert "Paragraph" in str(exc)
|
||||
else:
|
||||
raise AssertionError("Block chữ rỗng đáng lẽ phải bị từ chối")
|
||||
|
||||
|
||||
def test_rejects_truncated_plain_text_and_invalid_bbox():
|
||||
def response(content, finish="stop"):
|
||||
return {"choices": [{"finish_reason": finish, "message": {"content": content}}]}
|
||||
|
||||
Reference in New Issue
Block a user