3.1 获取Agent信息
2.2 创建Session(会话)
2.3 使用Agent会话
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| Authorization | heder | string | yes | API Key |
| userSn | heder | string | yes | 用户唯一标识 |
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| agentType | query | string | no | agent类型: |
| searchWord | query | string | no | 关键字查询,支持agent名称、描述、创建人 |
| createTimeStart | query | number | no | 起始创建时间 |
| createTimeEnd | query | number | no | 结束创建时间 |
| updateTimeStart | query | number | no | 起始更新时间 |
| updateTimeEnd | query | number | no | 结束更新时间 |
| agentStatus | query | number | no | agent状态:0-未启用,1-启用 |
| pageSize | query | number | yes | 分页大小 |
| pageNum | query | number | yes | 页码 |
| Authorization | header | string | yes | API key |
请求示例
http://10.102.200.234:8073/agent-api/v1/open/agents?agentType=chat&agentStatus=0&pageSize=10&pageNum=1响应示例
{
"code": 0,
"success": true,
"data": {
"list": [
{
"agentSn": "agent-b5812f4d97cc4974a595f",
"agentName": "asdas",
"agentDesc": "",
"agentStatus": 1,
"agentVerName": "1.0.0",
"agentVerSn": "ver-1127dd1a48294d35927ca",
"agentType": "form",
"userSn": "ec2c7e93-0682-48f3-b5a3-894a2b75f9a5",
"userName": "sunyf",
"createTime": "1718105869000",
"updateTime": "1718105887000"
}
],
"pageNum": 1,
"pageSize": 10,
"total": 1
},
"message": "操作成功"
}| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| Authorization | heder | string | yes | API Key |
| userSn | heder | string | yes | 用户唯一标识 |
| Name | Location | Type | Required | Title | Description |
|---|---|---|---|---|---|
| Authorization | header | string | yes | API key | |
| body | body | object | no | none | |
| » agentSn | body | string | yes | agent唯一标识 | none |
| » verSn | body | string | no | agent版本唯一标识 | 默认使用启用版本 |
请求示例
{
"agentSn": "agent-0745360f809e4f83ba5e3",
"verSn": ""
}响应示例
{
"code": 0,
"success": true,
"data": {
"sessionSn": "session-80adcf0f85b640f09fcda",
"userSn": "ff530954-82fd-4ac9-870b-adfd02893042"
},
"message": "操作成功"
}| Name | Location | Type | Required | Title | Description |
|---|---|---|---|---|---|
| » sessionSn | body | string | yes | 会话唯一标识 | |
| » msgContent | body | string | yes | 提问内容 | |
| » msgType | body | string | yes | 消息类型 | |
| » delayInMs | body | number | no | 吐字间隔,默认20ms | |
| » stream | body | boolean | no | 是否流式,默认是 | |
| » files | body | string(binary) | no | none | |
| » promptParamValues | body | array | no | 自定义变量,name:变量名称 value:变量值 type:变量类型 text-文本 string-段落 radio-单选 checkBox-多选 json-json textArr-文本数组 jsonArr-json数 组 | |
| » streamMode | body | string | no | 流式模式,仅在stream参数为true时生效,可选值: append(累加) delta(增量), 默认累加模式, |
请求示例
curl --location --request POST 'http://10.102.200.234:8073/agent-api/v1/open/agents/chat'
--header 'Authorization: db67f3f2-23b2-4c3c-b47f-1ef23839a94c'
--header 'Content-Type: multipart/form-data; boundary=--------------------------205853495601612827179871'
--form 'sessionSn="session-7b0f025b6ba94ea7a8730"'
--form 'msgContent="老虎"'
--form 'msgType="text"'
--form 'delayInMs="20"'
--form 'stream="true"'
--form 'files=@"F:\下载\logo.png"'
--form 'promptParamValues="{"name":"变量名称","value":"abcd","type":"text"}"'
--form 'promptParamValues="{"name":"变量名称","value":"abcd","type":"string"}"'
--form 'promptParamValues="{"name": "自定义文本", "type": "radio", "value": "选项1"}"'
--form 'promptParamValues="{"name": "自定义文本", "type": "checkbox", "value": "[\"选项1\",\"选项2\"]"}"'
--form 'promptParamValues="{"name": "json", "type": "json", "value": "{\"c\":1}"}"'
--form 'promptParamValues="{"name": "自定义文本", "type": "textArr", "value": "[\"文本1\",\"文本2\"]"}"'
--form 'promptParamValues="{"name": "json", "type": "jsonArr", "value": "[{\"c\":1},{\"c\":1}]"}"'
--form 'streamMode="append"'
响应示例
{
"code": 0,
"success": true,
"data": {
"sessionSn": "session-c8dcf316e11347eca984c",
"msgSn": "msg-2482646ee2714ae5905dd",
"msgType": "process",
"source": "bot",
"msgStatus": "normal",
"msgTime": 1734518162865,
"rate": 0,
"success": true,
"time": "2024/12/18 18:36",
"content": {
"outputs": [],
"references": null,
"completed": false,
"nodes": [
{
"status": "RUNNING",
"message": null,
"name": "输入",
"id": "input",
"resultOutputted": false,
"remainingCriticalNodeCountRange": {
"low": 2,
"high": 2
},
"outputs": null,
"durationInMills": null
}
]
}
},
"message": null
}| 字段 | 描述 | 备注 |
|---|---|---|
| sessionSn | 会话唯一标识 | |
| msgSn | 消息唯一标识 | |
| source | 消息来源:user用户 bot机器人 system系统 | |
| msgStatus | 消息状态 | |
| msgTime | 消息发送时间 | |
| content | 消息体 | |
| content.output | 结果输出 | |
| content.output.append | 消息内容是否需要累加,当streamMode=delta时生效,true表示返回的是增量的内容,false表示的完整的内容 | |
| content.output.nodes | 运行中的节点状态信息,status--状态,message:消息,name--节点名称,id--节点标识,resultOutputted:是否输出结果, remainingCriticalNodeCountRange-- 剩余关键节点区间, outputs--节点输出列表,durationInMills--运行时长 毫秒 |
| Name | Value |
|---|---|
| » streamMode | append |
| » streamMode | delta |
Response Examples
| HTTP Status Code | Meaning | Description | Data schema |
|---|---|---|---|
| 200 | OK | none | Inline |
data:{"code":0,"success":true,"data":{"sessionSn":"session-c8dcf316e11347eca984c","msgSn":"msg-2482646ee2714ae5905dd","msgType":"process","source":"bot","msgStatus":"normal","msgTime":1734518162865,"rate":0,"success":true,"time":"2024/12/18 18:36","content":{"outputs":[],"references":null,"completed":false,"nodes":[{"status":"RUNNING","message":null,"name":"输入","id":"input","resultOutputted":false,"remainingCriticalNodeCountRange":{"low":2,"high":2},"outputs":null,"durationInMills":null}]}},"message":null}
data:{"code":0,"success":true,"data":{"sessionSn":"session-c8dcf316e11347eca984c","msgSn":"msg-2482646ee2714ae5905dd","msgType":"process","source":"bot","msgStatus":"normal","msgTime":1734518163132,"rate":0,"success":true,"time":"2024/12/18 18:36","content":{"outputs":[],"references":null,"completed":false,"nodes":[{"status":"COMPLETED","message":null,"name":"输入","id":"input","resultOutputted":false,"remainingCriticalNodeCountRange":{"low":2,"high":2},"outputs":[],"durationInMills":137}]}},"message":null}
data:{"code":0,"success":true,"data":{"sessionSn":"session-c8dcf316e11347eca984c","msgSn":"msg-2482646ee2714ae5905dd","msgType":"process","source":"bot","msgStatus":"normal","msgTime":1734518166735,"rate":0,"success":true,"time":"2024/12/18 18:36","content":{"outputs":[{"output":"你好!有什么我","type":"TEXT","id":"e6840418ef","name":"LLM输出","state":"sending","append":false,"fileSn":null,"fileName":null,"processFileSn":null}],"references":null,"completed":false,"nodes":null}},"message":null}
data:{"code":0,"success":true,"data":{"sessionSn":"session-c8dcf316e11347eca984c","msgSn":"msg-2482646ee2714ae5905dd","msgType":"process","source":"bot","msgStatus":"normal","msgTime":1734518166821,"rate":0,"success":true,"time":"2024/12/18 18:36","content":{"outputs":[{"output":"你好!有什么我可以帮助","type":"TEXT","id":"e6840418ef","name":"LLM输出","state":"sending","append":false,"fileSn":null,"fileName":null,"processFileSn":null}],"references":null,"completed":false,"nodes":null}},"message":null}
| 字段 | 描述 | 备注 |
|---|---|---|
| sessionSn | 会话唯一标识 | |
| msgSn | 消息唯一标识 | |
| source | 消息来源:user用户 bot机器人 system系统 | |
| msgTime | 消息发送时间 | |
| content | 消息体 | |
| content.answer | 消息内容 |
Body 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| » sessionSn | body | string | 是 | 会话唯一ID |
| » msgContent | body | string | 是 | 提问内容 |
| » msgType | body | string | 是 | 消息类型 |
| » delayInMs | body | number | 否 | 吐字间隔,默认20ms |
| » stream | body | boolean | 否 | 是否流式,默认是 |
| » promptParamValues | body | array | 否 | 自定义变量,name:变量名称 value:变量值 type:变量类型 text-文本 string-段落 radio-单选 |
请求示例
curl --location --request POST 'http://10.102.200.234:8073/agent-api/v1/open/agents/chat'
--header 'Authorization: db67f3f2-23b2-4c3c-b47f-1ef23839a94c'
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)'
--header 'Accept: /'
--header 'Host: 10.102.200.234:8073'
--header 'Connection: keep-alive'
--header 'Content-Type: multipart/form-data; boundary=--------------------------131905984493673506529254'
--form 'sessionSn="session-c17b42e00ba04f1f9fd98"'
--form 'msgContent="你好"'
--form 'msgType="text"'
--form 'delayInMs="20"'
--form 'stream="true"'
--form 'promptParamValues="{"name":"变量名称","value":"abcd","type":"text"}"'
--form 'promptParamValues="{"name":"变量名称","value":"abcd","type":"string"}"'
--form 'promptParamValues="{"name": "自定义文本", "type": "radio", "value": "选项1"}"'
返回示例
该接口使用sse技术开发(具体细节可查阅网上教程),通过服务器与客户端的http长连接,根据传递的delayInMs间隔返回消息,每次返回的消息格式为json
样例数据:
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
data:{"code":0,"success":true,"data":{"sessionSn":"session-c17b42e00ba04f1f9fd98","msgSn":"4368a92d-8c80-4ab0-a2c5-ab5fd84ebffe","msgType":"text","source":"bot","msgStatus":"normal","msgTime":1719304752552,"rate":0,"success":true,"time":"2024/06/25 16:39","content":{"answer":""}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"sessionSn":"session-c17b42e00ba04f1f9fd98","msgSn":"4368a92d-8c80-4ab0-a2c5-ab5fd84ebffe","msgType":"text","source":"bot","msgStatus":"normal","msgTime":1719304752792,"rate":0,"success":true,"time":"2024/06/25 16:39","content":{"answer":"你"}},"message":"操作成功"}Body 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| » sessionSn | body | string | 是 | 会话唯一标识 |
| » msgContent | body | string | 是 | 提问内容 |
| » msgType | body | string | 是 | 消息类型 |
| » requestType | body | number | 是 | 问答类型:0-知识问答,1-文档检索,2-网络搜索 |
| » delayInMs | body | number | 否 | 吐字间隔,默认20ms |
| » stream | body | boolean | 否 | 是否流式 ,默认是 |
| » promptParamValues | body | array | 否 | name:变量名称 value:变量值 type:变量类型 text-文本 string-段落 radio-单选 |
返回示例
| 字段 | 描述 | 备注 |
|---|---|---|
| sessionSn | 会话唯一标识 | |
| msgSn | 消息唯一标识 | |
| source | 消息来源:user用户 bot机器人 system系统 | |
| msgTime | 消息发送时间 | |
| content | 消息体 | |
| content.pages | 文档引用页信息 | |
| content.pages.fileId | 文档唯一标识 | |
| content.pages.fileName | 文档名称 | |
| content.pages.fileType | 文档类型 | |
| content.pages.fileDownloadUrl | 文件下载链接 | |
| content.pages.pageList | 页码列表 | |
| content.pages.pageList.page | 页码 | |
| content.pages.pageList.pageContent | 页码内容 | |
| content.pages.pageList.score | 内容评分 | |
| content.imagePages | 召回图片所在文档引用页信息 | |
| content.imagePages.fileId | 文档唯一标识 | |
| content.imagePages.fileName | 文档名称 | |
| content.imagePages.fileType | 文档类型 | |
| content.imagePages.fileDownloadUrl | 文件下载链接 | |
| content.imagePages.list | 召回图片列表 | |
| content.imagePages.list.page | 召回图片所在页码 | |
| content.imagePages.list.imageSn | 召回图片唯一标识 | |
| content.imagePages.list.imageName | 召回图片名称 | |
| content.imagePages.list.score | 召回图片评分 | |
| content.imagePages.list.imageDownloadUrl | 召回图片下载链接 |
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » code | integer | true | none | none | |
| » success | boolean | true | none | none | |
| » data | object | true | none | none | |
| »» sessionSn | string | true | none | 会话唯一标识 | none |
| »» msgSn | string | true | none | 消息唯一标识 | none |
| »» msgType | string | true | none | 消息类型 | none |
| »» source | string | true | none | 消息来源 | none |
| »» msgStatus | string | true | none | 消息状态 | none |
| »» msgTime | integer | true | none | 发送时间戳 | none |
| »» time | string | true | none | 发送时间 | none |
| »» content | object | true | none | 回答内容 | none |
| »»» answer | string | true | none | 回答 | none |
| »»» pages | [object] | true | none | 文档引用 | none |
| »»»» fileId | string | false | none | 文档唯一标识 | none |
| »»»» fileName | string | false | none | 文档名称 | none |
| »»»» pageList | [object] | false | none | 引用页信息 | none |
| »»»»» page | integer | false | none | 页码 | none |
| »»»»» pageContent | string | false | none | 引用信息 | none |
| »»»»» score | number | false | none | 评分 | none |
| »»»» fileType | string | false | none | 文档类型 | none |
| »»» imagePages | [string] | true | none | 引用图片 | none |
| » message | string | true | none | none |
data:{"code":0,"success":true,"data":{"sessionSn":"session-1da630847d0d40ea89bdd","msgSn":"msg-b9cc1c81833c41648c827","msgType":"docref","source":"bot","msgStatus":"normal","msgTime":1719368866409,"time":"2024/06/26 10:27","content":{"answer":"应"}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"sessionSn":"session-1da630847d0d40ea89bdd","msgSn":"msg-b9cc1c81833c41648c827","msgType":"docref","source":"bot","msgStatus":"normal","msgTime":1719368866409,"time":"2024/06/26 10:27","content":{"answer":"的"}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"sessionSn":"session-1da630847d0d40ea89bdd","msgSn":"msg-b9cc1c81833c41648c827","msgType":"docref","source":"bot","msgStatus":"normal","msgTime":1719368866409,"time":"2024/06/26 10:27","content":{"answer":"产品"}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"sessionSn":"session-1da630847d0d40ea89bdd","msgSn":"msg-b9cc1c81833c41648c827","msgType":"docref","source":"bot","msgStatus":"normal","msgTime":1719368866409,"time":"2024/06/26 10:27","content":{"answer":"大"}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"sessionSn":"session-1da630847d0d40ea89bdd","msgSn":"msg-b9cc1c81833c41648c827","msgType":"docref","source":"bot","msgStatus":"normal","msgTime":1719368866410,"time":"2024/06/26 10:27","content":{"answer":"类"}},"message":"操作成功"}Body 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| Authorization | header | string | 是 | none |
| body | body | object | 否 | none |
| » sessionSn | body | string | 是 | 会话唯一标识 |
| » msgContent | body | string | 是 | 提问内容 |
| » msgType | body | string | 是 | 消息类型 |
| » delayInMs | body | number | 否 | 吐字间隔,默认20ms |
| » stream | body | boolean | 否 | 是否流式,默认是 |
| » files | body | string(binary) | 否 | none |
| » promptParamValues | body | array | 否 | name:变量名称 value:变量值 type:变量类型 text-文本 string-段落 radio-单选 |
返回示例
| 字段 | 描述 | 备注 |
|---|---|---|
| sessionSn | 会话唯一标识 | |
| msgSn | 消息唯一标识 | |
| source | 消息来源:user用户 bot机器人 system系统 | |
| msgTime | 消息发送时间 | |
| content | 消息体 | |
| content.answer | 消息内容 |
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393977001,"time":"2024/06/26 17:26:17","content":{"answer":"","steps":[{"status":0,"stage":"初始化","messages":["正在初始化"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393977657,"time":"2024/06/26 17:26:17","content":{"answer":"","steps":[{"status":0,"stage":"模型调用","messages":["正在调用大模型"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393979434,"time":"2024/06/26 17:26:19","content":{"answer":"","steps":[{"status":1,"stage":"思考分析","messages":["模型选择调用:音频解析"],"loading":false},{"status":0,"stage":"使用技能: 音频解析","messages":["{\"32c1a97037\":\"abc170706cab4983ad380ca0b8a9a085/b1cb083863ca45a5820fadf5762fda4f\"}"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}Body 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| Authorization | header | string | 是 | none |
| body | body | object | 否 | none |
| » sessionSn | body | string | 是 | 会话唯一标识 |
| » msgContent | body | string | 是 | 提问内容 |
| » msgType | body | string | 是 | 消息类型 |
| » delayInMs | body | number | 否 | 吐字间隔,默认20ms |
| » stream | body | boolean | 否 | 是否流式,默认是 |
| » files | body | string(binary) | 否 | none |
| » promptParamValues | body | array | 否 | name:变量名称 value:变量值 type:变量类型 text-文本 string-段落 radio-单选 |
返回示例
该接口使用sse技术开发(具体细节可查阅网上教程),通过服务器与客户端的http长连接,根据传递的delayInMs间隔返回消息,每次返回的消息格式为json
样例数据:
| 字段 | 描述 | 备注 |
|---|---|---|
| sessionSn | 会话唯一标识 | |
| msgSn | 消息唯一标识 | |
| source | 消息来源:user用户 bot机器人 system系统 | |
| msgTime | 消息发送时间 | |
| content | 消息体 | |
| content.answer | 消息内容 |
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393977001,"time":"2024/06/26 17:26:17","content":{"answer":"","steps":[{"status":0,"stage":"初始化","messages":["正在初始化"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393977657,"time":"2024/06/26 17:26:17","content":{"answer":"","steps":[{"status":0,"stage":"模型调用","messages":["正在调用大模型"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393979434,"time":"2024/06/26 17:26:19","content":{"answer":"","steps":[{"status":1,"stage":"思考分析","messages":["模型选择调用:音频解析"],"loading":false},{"status":0,"stage":"使用技能: 音频解析","messages":["{\"32c1a97037\":\"abc170706cab4983ad380ca0b8a9a085/b1cb083863ca45a5820fadf5762fda4f\"}"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}
data:{"code":0,"success":true,"data":{"msgSn":"2553e22c-f0a7-4e4d-845f-e8c793911d6b","msgTime":1719393983021,"time":"2024/06/26 17:26:23","content":{"answer":"","steps":[{"status":1,"stage":"思考分析","messages":["模型选择调用:音频解析"],"loading":false},{"status":1,"stage":"使用技能: 音频解析","messages":["{\"音频\":\"abc170706cab4983ad380ca0b8a9a085/b1cb083863ca45a5820fadf5762fda4f\"}"],"loading":false},{"status":1,"stage":"观察结果","messages":["{\"errorMessage\":\"语音识别:文件不存在\"}"],"loading":false},{"status":0,"stage":"模型调用","messages":["正在调用大模型"],"loading":true}],"functionCalled":null,"outputs":null,"answerPreview":null}},"message":"操作成功"}