diff --git a/appbuilder/core/components/handwrite_ocr/component.py b/appbuilder/core/components/handwrite_ocr/component.py index 11a126c04..3d2a82f48 100644 --- a/appbuilder/core/components/handwrite_ocr/component.py +++ b/appbuilder/core/components/handwrite_ocr/component.py @@ -120,12 +120,7 @@ def tool_eval(self, name: str, streaming: bool, **kwargs): req.detect_direction = "true" req.detect_alteration = "true" response = self._recognize(req) - out = HandwriteOCROutMsg() - out.direction = response.direction - [out.contents.append( - Content(text=w.words)) - for w in response.words_result] - result[file_name] = out.dict() + result[file_name] = [w.words for w in response.words_result] if streaming: yield json.dumps(result, ensure_ascii=False) diff --git a/appbuilder/core/components/qrcode_ocr/component.py b/appbuilder/core/components/qrcode_ocr/component.py index 28f58bc26..5edb5a0b8 100644 --- a/appbuilder/core/components/qrcode_ocr/component.py +++ b/appbuilder/core/components/qrcode_ocr/component.py @@ -167,7 +167,7 @@ def tool_eval(self, name: str, streaming: bool, **kwargs): raise InvalidRequestArgumentError("location must be a string with value 'true' or 'false'") req.location = location resp = self._recognize(req) - result[file_name] = proto.Message.to_dict(resp)["codes_result"] + result[file_name] = [item["text"] for item in proto.Message.to_dict(resp).get("codes_result", [])] if streaming: yield json.dumps(result, ensure_ascii=False) else: