diff --git a/appbuilder/core/components/handwrite_ocr/component.py b/appbuilder/core/components/handwrite_ocr/component.py index 3d2a82f48..7753f1671 100644 --- a/appbuilder/core/components/handwrite_ocr/component.py +++ b/appbuilder/core/components/handwrite_ocr/component.py @@ -122,10 +122,20 @@ def tool_eval(self, name: str, streaming: bool, **kwargs): response = self._recognize(req) result[file_name] = [w.words for w in response.words_result] + result = json.dumps(result, ensure_ascii=False) if streaming: - yield json.dumps(result, ensure_ascii=False) + yield { + "type": "text", + "text": result, + "visible_scope": 'llm', + } + yield { + "type": "text", + "text": "", + "visible_scope": "user", + } else: - return json.dumps(result, ensure_ascii=False) + return result def _recognize(self, request: HandwriteOCRRequest, timeout: float = None, retry: int = 0) -> HandwriteOCRResponse: r"""调用底层接口进行通用文字识别 diff --git a/appbuilder/core/components/mix_card_ocr/component.py b/appbuilder/core/components/mix_card_ocr/component.py index 93f352bbd..5e6704eba 100644 --- a/appbuilder/core/components/mix_card_ocr/component.py +++ b/appbuilder/core/components/mix_card_ocr/component.py @@ -183,7 +183,17 @@ def tool_eval(self, name: str, streaming: bool, **kwargs): out.direction = response.direction result[file_name] = out.dict() + result = json.dumps(result, ensure_ascii=False) if streaming: - yield json.dumps(result, ensure_ascii=False) + yield { + "type": "text", + "text": result, + "visible_scope": 'llm', + } + yield { + "type": "text", + "text": "", + "visible_scope": "user", + } else: - return json.dumps(result, ensure_ascii=False) + return result diff --git a/appbuilder/core/components/qrcode_ocr/component.py b/appbuilder/core/components/qrcode_ocr/component.py index 5edb5a0b8..95628b6a6 100644 --- a/appbuilder/core/components/qrcode_ocr/component.py +++ b/appbuilder/core/components/qrcode_ocr/component.py @@ -168,7 +168,18 @@ def tool_eval(self, name: str, streaming: bool, **kwargs): req.location = location resp = self._recognize(req) result[file_name] = [item["text"] for item in proto.Message.to_dict(resp).get("codes_result", [])] + + result = json.dumps(result, ensure_ascii=False) if streaming: - yield json.dumps(result, ensure_ascii=False) + yield { + "type": "text", + "text": result, + "visible_scope": 'llm', + } + yield { + "type": "text", + "text": "", + "visible_scope": "user", + } else: - return json.dumps(result, ensure_ascii=False) + return result diff --git a/appbuilder/core/components/table_ocr/component.py b/appbuilder/core/components/table_ocr/component.py index 0947d36be..29326772c 100644 --- a/appbuilder/core/components/table_ocr/component.py +++ b/appbuilder/core/components/table_ocr/component.py @@ -194,7 +194,18 @@ def tool_eval(self, name: str, streaming: bool, **kwargs): tables_result = proto.Message.to_dict(resp)["tables_result"] markdowns = self.get_table_markdown(tables_result) result[file_name] = markdowns + + result = json.dumps(result, ensure_ascii=False) if streaming: - yield json.dumps(result, ensure_ascii=False) + yield { + "type": "text", + "text": result, + "visible_scope": 'llm', + } + yield { + "type": "text", + "text": "", + "visible_scope": "user", + } else: - return json.dumps(result, ensure_ascii=False) + return result