Skip to content

Commit

Permalink
修改detail详情类型
Browse files Browse the repository at this point in the history
  • Loading branch information
ide-rea committed Mar 20, 2024
1 parent eb6f982 commit 47d4b79
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
34 changes: 20 additions & 14 deletions appbuilder/core/console/agent_builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN"

### 非流式返回

| 参数名称 | 参数类型 | 描述 | 示例值 |
|----------------|--------------------|------------------|------------------------------------------------------------------|
| content | AgentBuilderAnswer | 对话返回结果 | |
| +code | Int | 错误码,0代码成功,非0表示失败 | 0 |
| +message | String | 错误具体消息 | |
| +answer | String | 智能体返回的回答 | |
| +events | List[Event] | 事件列表 | |
| +events[0] | Event | 具体事件内容 | |
| ++code | String | 错误码 | |
| ++message | String | 错误具体消息 | |
| ++status | String | 事件状态 | 状态描述,preparing(准备运行)running(运行中)error(执行错误) done(执行完成) |
| ++event_type | String | 事件类型 | |
| ++content_type | String | 内容类型 | 可选值包括:code text, image, status,image, function_call, rag, audio等 |
| ++detail | Dict | 事件输出详情 | 代码解释器、文生图、工具组件等的详细输出内容 |
| 参数名称 | 参数类型 | 描述 | 示例值 |
|----------------|--------------------|------------------|------------------------------------------------------------------------|
| content | AgentBuilderAnswer | 对话返回结果 | |
| +code | Int | 错误码,0代码成功,非0表示失败 | 0 |
| +message | String | 错误具体消息 | |
| +answer | String | 智能体返回的回答 | |
| +events | List[Event] | 事件列表 | |
| +events[0] | Event | 具体事件内容 | |
| ++code | String | 错误码 | |
| ++message | String | 错误具体消息 | |
| ++status | String | 事件状态 | 状态描述,preparing(准备运行)running(运行中)error(执行错误) done(执行完成) |
| ++event_type | String | 事件类型 | |
| ++content_type | String | 内容类型 | 可选值包括:code text, image, status,image, function_call, rag, audio、video等 |
| ++detail | Dict | 事件输出详情 | 代码解释器、文生图、工具组件等的详细输出内容 |

### 流式返回

Expand Down Expand Up @@ -141,6 +141,12 @@ for content in message.content:
elif content_type == "function_call":
function_call_detail = FunctionCallDetail(**detail)
print(function_call_detail.video)
elif content_type == "audio":
audio_detail = AudioDetail(**detail)
print(audio_detail)
elif content_type == "video":
video_detail = VideoDetail(**detail)
print(video_detail)
elif content_type == "status":
StatusDetail(**detail)
else:
Expand Down
1 change: 0 additions & 1 deletion appbuilder/core/console/agent_builder/agent_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def run(self, conversation_id: str,
request_id = self.http_client.response_request_id(response)
if stream:
client = SSEClient(response)

return Message(content=self._iterate_events(request_id, client.events()))
else:
data = response.json()
Expand Down
28 changes: 26 additions & 2 deletions appbuilder/core/console/agent_builder/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Result(BaseModel):
is_completion: Union[bool, None] = ""
content: list[OriginalEvent] = []


class HTTPResponse(BaseModel):
"""会话请求参数
属性:
Expand Down Expand Up @@ -118,14 +119,37 @@ class FunctionCallDetail(BaseModel):
"""content_type=function_call,详情内容
属性:
text(str): 文本详情
references(list[dict]): 引用详情
"""
text: Union[str, dict] = ""
image: str = ""
audio: str = ""
video: str = ""


class ImageDetail(BaseModel):
"""content_type=function_call,详情内容
属性:
image(str): 图片下载地址
"""
image: str = ""


class AudioDetail(BaseModel):
"""content_type=audio,详情内容
属性:
image(str): 音频下载地址
"""
audio: str = ""


class VideoDetail(BaseModel):
"""content_type=video,详情内容
属性:
vidoe(str): 视频下载地址
"""
video: str = ""


class StatusDetail(BaseModel):
pass

Expand Down Expand Up @@ -203,4 +227,4 @@ class CreateConversationResponse(BaseModel):
"""
code: int = 0
message: str = ""
result: CreateConversationResult = CreateConversationResult()
result: CreateConversationResult = CreateConversationResult()

0 comments on commit 47d4b79

Please sign in to comment.