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:
@@ -18,6 +18,8 @@ LABELS = {
|
||||
}
|
||||
LABEL_ALIASES = {"Page-Header": "Header", "Page Header": "Header",
|
||||
"Page-Footer": "Footer", "Page Footer": "Footer"}
|
||||
# Vùng không có chữ: model trả div rỗng, không phải output hỏng.
|
||||
VISUAL_LABELS = {"Image", "QR Code", "Barcode", "Signature", "Stamp"}
|
||||
|
||||
|
||||
class InvalidOutput(Exception):
|
||||
@@ -54,8 +56,8 @@ def validate_response(response: dict) -> list[dict]:
|
||||
box = block["bbox"]
|
||||
if box is None or len(box) != 4 or not (0 <= box[0] < box[2] <= 1000 and 0 <= box[1] < box[3] <= 1000):
|
||||
raise InvalidOutput(f"Invalid bounding box: {box}")
|
||||
if not block["html"]:
|
||||
raise InvalidOutput("Empty layout block")
|
||||
if not block["html"] and block["label"] not in VISUAL_LABELS:
|
||||
raise InvalidOutput(f"Empty layout block: {block['label']}")
|
||||
return blocks
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user