From 2066b56b33f2b33967cfb0d1927f60f993883eec Mon Sep 17 00:00:00 2001 From: userpj Date: Wed, 15 Jan 2025 18:56:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E5=AF=BC=E8=87=B4=E7=9A=84=E6=B5=81=E5=BC=8F=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/core/_client.py | 3 --- python/core/console/component_client/data_class.py | 11 ++++++----- python/tests/test_component_client.py | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/python/core/_client.py b/python/core/_client.py index c493f571..2468fe65 100644 --- a/python/core/_client.py +++ b/python/core/_client.py @@ -114,9 +114,6 @@ def check_response_header(response: requests.Response): """ status_code = response.status_code if status_code == requests.codes.ok: - logger.debug("request_id={} , http status code is {} , response text is {}".format( - __class__.response_request_id(response), status_code, response.text - )) return message = "request_id={} , http status code is {}, body is {}".format( __class__.response_request_id(response), status_code, response.text diff --git a/python/core/console/component_client/data_class.py b/python/core/console/component_client/data_class.py index 5761c556..30f6f62d 100644 --- a/python/core/console/component_client/data_class.py +++ b/python/core/console/component_client/data_class.py @@ -14,7 +14,7 @@ from pydantic import BaseModel from pydantic import Field -from typing import Optional +from typing import Optional, Union from appbuilder.core.component import ComponentOutput, Content @@ -74,7 +74,7 @@ class Event(BaseModel): description="错误信息", ) - event: Event = Field(..., description="事件信息") + event: Event = Field(None, description="事件信息") class RunResponse(BaseModel): @@ -87,12 +87,13 @@ class RunOutput(ComponentOutput): user_id: str = Field(..., description="开发者UUID(计费依赖)") end_user_id: str = Field(None, description="终端用户id") is_completion: bool = Field(..., description="是否完成") + role: str = Field(..., description="当前消息来源,默认tool") content: list[ContentWithEvent] = Field( None, description="当前组件返回内容的主要payload,List[ContentWithEvent],每个 Content 包括了当前 event 的一个元素", ) - request_id: str = Field(..., description="请求id") - code: str = Field(None, description="响应码") + request_id: str = Field(None, description="请求id") + code: Union[str,int] = Field(None, description="响应码") message: str = Field(None, description="响应消息") - data: RunOutput = Field(..., description="响应数据") + data: RunOutput = Field(None, description="响应数据") diff --git a/python/tests/test_component_client.py b/python/tests/test_component_client.py index 0921dd85..756bfca2 100644 --- a/python/tests/test_component_client.py +++ b/python/tests/test_component_client.py @@ -16,7 +16,7 @@ import os -@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_SERIAL", "") +#unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_SERIAL", "") class TestComponentCLient(unittest.TestCase): def test_component_client(self): appbuilder.logger.setLoglevel("DEBUG") @@ -24,7 +24,7 @@ def test_component_client(self): res = client.run(component_id="44205c67-3980-41f7-aad4-37357b577fd0", version="latest", sys_origin_query="北京景点推荐") - print(res.content.content) + print(res.content) def test_component_client_stream(self): appbuilder.logger.setLoglevel("DEBUG")