Skip to content

Commit

Permalink
修复日志打印导致的流式失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
userpj committed Jan 15, 2025
1 parent 9a830a7 commit 2066b56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 0 additions & 3 deletions python/core/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions python/core/console/component_client/data_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -74,7 +74,7 @@ class Event(BaseModel):
description="错误信息",
)

event: Event = Field(..., description="事件信息")
event: Event = Field(None, description="事件信息")


class RunResponse(BaseModel):
Expand All @@ -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="响应数据")
4 changes: 2 additions & 2 deletions python/tests/test_component_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
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")
client = appbuilder.ComponentClient()

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")
Expand Down

0 comments on commit 2066b56

Please sign in to comment.