更新时间:2025-01-05 GMT+08:00
分享

应用

功能介绍

通过调用创建好的应用API,输入问题,将得到应用执行的结果。

URI

获取URI方式请参见请求URI

POST /v1/{project_id}/agent-run/agents/{agent_id}/conversations/{conversation_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参见获取项目ID

agent_id

String

Agent ID,获取方式如下:

在“Agent开发”页面,左侧导航栏选择“工作台 > 应用”,在所需Agent中单击“ > 复制ID”。

conversation_id

String

会话ID,唯一标识每个会话的标识符,可将会话ID设置为任意值,使用标准UUID格式。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

用于获取操作API的权限。获取Token接口响应消息头中X-Subject-Token的值即为Token。

Content-Type

String

发送的实体的MIME类型,参数值为“application/json”。

stream

Boolean

是否开启流式调用,默认开启。

  • true:开启
  • false:不开启
说明:

当前Agent只支持流式调用,需设置为true。

表3 请求Body参数

参数

是否必选

参数类型

描述

query

String

用户问题,作为运行Agent的输入。

响应参数

流式(Header中的stream参数为true)

状态码: 200

表4 流式输出的数据单元

参数

参数类型

描述

data

String

  • stream=true时,执行Agent的消息以流式形式返回。
  • 生成的内容以增量的方式逐步发送回来,每个data字段均包含一部分生成的内容,直到所有data返回,响应结束。
表5 流式输出的数据单元

参数

参数类型

描述

event

String

数据单元类型,有以下几种类型:

  • start,开始节点,表示开始调用模型进行会话。
  • message,消息节点,表示模型返回的消息。
  • plugin_start,插件调用请求节点,表示调用插件的请求信息。
  • plugin_end,插件调用响应节点,表示调用插件的响应信息。
  • statistic_data,执行数据节点,包含本次调用的耗时信息。
  • summary_response,消息总结节点,包含本次调用的全量响应信息。
  • done,流式调用结束节点,表示流式响应结束。

content

Object

消息块内容,不同event的消息块内容不同。

createdTime

long

消息块返回的时间戳,如1733817348963。

latency

Object

耗时,包括以下三个元素:

  • plugin,插件调用耗时
  • model,模型调用耗时
  • overall,总耗时

plugin

Object

插件请求信息,包括以下两个元素:

  • name,插件名
  • arguments,插件入参名

请求示例

流式(Header中的stream参数为true)

POST https://{endpoint}/v1/{project_id}/agent-run/agents/{agent_id}/conversations/{conversation_id}

Request Header:   
Content-Type: application/json   
X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...  
stream: true    

Request Body:
{ 
  "query": "查询A12会议室在9:00到10:00的状态"
}

响应示例

data:{"event":"start","createdTime":1735558575017}

data:{"event":"message","content":"好的","createdTime":1735558576300}

data:{"event":"message","content":",","createdTime":1735558576301}

data:{"event":"message","content":"我将","createdTime":1735558576301}

data:{"event":"message","content":"调用","createdTime":1735558576302}

data:{"event":"message","content":"query","createdTime":1735558576302}

data:{"event":"message","content":"_","createdTime":1735558576302}

data:{"event":"message","content":"meeting","createdTime":1735558576302}

data:{"event":"message","content":"_","createdTime":1735558576302}

data:{"event":"message","content":"room","createdTime":1735558576303}

data:{"event":"message","content":"_status","createdTime":1735558576303}

data:{"event":"message","content":"工具","createdTime":1735558576303}

data:{"event":"message","content":"来","createdTime":1735558576304}

data:{"event":"message","content":"查询","createdTime":1735558576304}

data:{"event":"message","content":"A","createdTime":1735558576304}

data:{"event":"message","content":"12","createdTime":1735558576304}

data:{"event":"message","content":"会议室","createdTime":1735558576305}

data:{"event":"message","content":"在","createdTime":1735558576305}

data:{"event":"message","content":"9","createdTime":1735558576305}

data:{"event":"message","content":":00","createdTime":1735558576305}

data:{"event":"message","content":"到","createdTime":1735558576306}

data:{"event":"message","content":"10","createdTime":1735558576306}

data:{"event":"message","content":":00","createdTime":1735558576306}

data:{"event":"message","content":"的状态","createdTime":1735558576306}

data:{"event":"message","content":"。","createdTime":1735558576306}

data:{"event":"message","content":"请","createdTime":1735558576307}

data:{"event":"message","content":"稍","createdTime":1735558576307}

data:{"event":"message","content":"等","createdTime":1735558576307}

data:{"event":"message","content":"。","createdTime":1735558576307}

data:{"event":"message","content":" ","createdTime":1735558576307}

data:{"event":"message","content":" query","createdTime":1735558576307}

data:{"event":"message","content":"_","createdTime":1735558576308}

data:{"event":"message","content":"meeting","createdTime":1735558576308}

data:{"event":"message","content":"_","createdTime":1735558576308}

data:{"event":"message","content":"room","createdTime":1735558576308}

data:{"event":"message","content":"_status","createdTime":1735558576308}

data:{"event":"message","content":"|","createdTime":1735558576308}

data:{"event":"message","content":"{\"","createdTime":1735558576309}

data:{"event":"message","content":"meeting","createdTime":1735558576309}

data:{"event":"message","content":"Room","createdTime":1735558576309}

data:{"event":"message","content":"\":","createdTime":1735558576309}

data:{"event":"message","content":"{\"","createdTime":1735558576309}

data:{"event":"message","content":"number","createdTime":1735558576310}

data:{"event":"message","content":"\":","createdTime":1735558576310}

data:{"event":"message","content":" 12","createdTime":1735558576310}

data:{"event":"message","content":"}","createdTime":1735558576310}

data:{"event":"message","content":",\"","createdTime":1735558576310}

data:{"event":"message","content":"start","createdTime":1735558576310}

data:{"event":"message","content":"\":\"","createdTime":1735558576311}

data:{"event":"message","content":"9","createdTime":1735558576311}

data:{"event":"message","content":":00","createdTime":1735558576311}

data:{"event":"message","content":"\",\"","createdTime":1735558576311}

data:{"event":"message","content":"end","createdTime":1735558576311}

data:{"event":"message","content":"\":\"","createdTime":1735558576311}

data:{"event":"message","content":"10","createdTime":1735558576311}

data:{"event":"message","content":":00","createdTime":1735558576312}

data:{"event":"message","content":"\"}","createdTime":1735558576312}

data:{"event":"message","content":" ","createdTime":1735558576312}

data:{"event":"plugin_start","type":"plugin","latency":{"overall":1.3},"plugin":{"name":"query_meeting_room_status","arguments":"{\"meetingRoom\": {\"number\": 12}, \"start\": \"9:00\", \"end\": \"10:00\"}"},"createdTime":1735558576316}

data:{"event":"plugin_end","content":{"result":"空闲"},"role":"function","latency":{"overall":1.51,"plugin":0.0},"createdTime":1735558576521}

data:{"event":"start","createdTime":1735558576522}

data:{"event":"message","content":"A","createdTime":1735558576976}

data:{"event":"message","content":"12","createdTime":1735558576977}

data:{"event":"message","content":"会议室","createdTime":1735558576977}

data:{"event":"message","content":"在","createdTime":1735558576977}

data:{"event":"message","content":"9","createdTime":1735558576978}

data:{"event":"message","content":":00","createdTime":1735558576978}

data:{"event":"message","content":"到","createdTime":1735558576978}

data:{"event":"message","content":"10","createdTime":1735558576978}

data:{"event":"message","content":":00","createdTime":1735558576978}

data:{"event":"message","content":"的时间","createdTime":1735558576978}

data:{"event":"message","content":"段","createdTime":1735558576979}

data:{"event":"message","content":"内","createdTime":1735558576979}

data:{"event":"message","content":"是","createdTime":1735558576979}

data:{"event":"message","content":"空闲","createdTime":1735558576979}

data:{"event":"message","content":"的","createdTime":1735558576979}

data:{"event":"message","content":"。","createdTime":1735558576980}

data:{"event":"statistic_data","latency":{"overall":1.97},"createdTime":1735558576986}

data:{"event":"summary_response","content":"A12会议室在9:00到10:00的时间段内是空闲的。","role":"assistant","createdTime":1735558576987}

data:{"event":"done","createdTime":1735558577011}

状态码

请参见状态码

错误码

请参见错误码

相关文档