From 48e1e1880acedec4aac8dbaa2e23c0d46214b4bc Mon Sep 17 00:00:00 2001 From: sucuicong <704347179@qq.com> Date: Fri, 8 Mar 2024 14:50:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=96=87=E5=AD=97?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E3=80=81=E6=9D=A1=E5=BD=A2=E7=A0=81/?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E8=AF=86=E5=88=AB=E3=80=81=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E8=AF=81=E6=B7=B7=E8=B4=B4=E8=AF=86=E5=88=AB=E3=80=81?= =?UTF-8?q?=E6=89=8B=E5=86=99=E6=96=87=E5=AD=97=E8=AF=86=E5=88=AB=E6=94=AF?= =?UTF-8?q?=E6=8C=81function=20call=20=E7=AE=80=E5=8C=96OCR=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appbuilder/core/components/handwrite_ocr/component.py | 7 +------ appbuilder/core/components/qrcode_ocr/component.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) 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..fbe173a2c 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)["codes_result"]] if streaming: yield json.dumps(result, ensure_ascii=False) else: From 208266e8ceecb7495c00c1095696b30f6d03a0ce Mon Sep 17 00:00:00 2001 From: sucuicong <704347179@qq.com> Date: Fri, 8 Mar 2024 15:11:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=96=87=E5=AD=97?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E3=80=81=E6=9D=A1=E5=BD=A2=E7=A0=81/?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E8=AF=86=E5=88=AB=E3=80=81=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E8=AF=81=E6=B7=B7=E8=B4=B4=E8=AF=86=E5=88=AB=E3=80=81?= =?UTF-8?q?=E6=89=8B=E5=86=99=E6=96=87=E5=AD=97=E8=AF=86=E5=88=AB=E6=94=AF?= =?UTF-8?q?=E6=8C=81function=20call=20=E7=AE=80=E5=8C=96OCR=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appbuilder/core/components/qrcode_ocr/component.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appbuilder/core/components/qrcode_ocr/component.py b/appbuilder/core/components/qrcode_ocr/component.py index fbe173a2c..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] = [item["text"] for item in 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: