Skip to content

Commit 1dbb409

Browse files
dt-yyquyuan
andauthored
update error judge (#393)
Co-authored-by: quyuan <quyuan@pjlab.org>
1 parent 16e75af commit 1dbb409

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dingo/model/llm/llm_document_parsing_ocr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@ def process_response(cls, response: str) -> EvalDetail:
103103
json_match = re.search(r'\{[\s\S]*"errors"[\s\S]*\}', response)
104104
types = []
105105
names = []
106+
parse_ok = False
107+
errors_nonempty = False
106108

107109
if json_match:
108110
try:
109111
json_str = json_match.group()
110112
result_data = json.loads(json_str)
111113
errors = result_data.get("errors", [])
114+
parse_ok = True
115+
errors_nonempty = len(errors) > 0
112116

113117
for error in errors:
114118
error_category = error.get("error_category", "")
@@ -123,7 +127,7 @@ def process_response(cls, response: str) -> EvalDetail:
123127
log.error("未找到JSON内容")
124128

125129
result = EvalDetail(metric=cls.__name__)
126-
result.status = False
130+
result.status = (not parse_ok) or errors_nonempty
127131

128132
tmp_type = '.'.join(types)
129133
tmp_name = '.'.join(names)

0 commit comments

Comments
 (0)