工具服务
所有工具服务接口都需要有效的访问令牌。请在请求头中包含Bearer令牌。
工具服务概述
工具服务提供多种辅助功能:
- 语音转换(文本转语音、语音识别)
- 向量数据库操作(搜索、增删改查)
- 主页内容管理
- 外脑分析工具
语音服务
语音服务支持文本转语音功能。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| convId | string | 是 | 对话ID |
| msgId | string | 是 | 消息ID |
POST /tool/speech
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"convId": "conv123",
"msgId": "msg456"
}
返回的音频数据为base64编码的MP3格式。支持中文语音合成,使用标准女声。
向量数据库工具
向量数据库功能
提供完整的向量数据库操作接口,支持:
- 数据检索和向量搜索
- 数据的增删改查
- 批量操作
- 条件过滤
获取数据列表
获取指定数据库的数据列表。路径参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| className | string | 是 | 数据库名称 |
查询参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| limit | number | 否 | 返回数量 |
| skip | number | 否 | 跳过数量 |
| where | object | 否 | 查询条件 |
GET /tool/vdb/wainao_chat?limit=10&skip=0
Authorization: Bearer YOUR_TOKEN
获取单条数据
/tool/vdb/{className}/{id}
获取指定ID的数据详情。路径参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| className | string | 是 | 数据库名称 |
| id | string | 是 | 数据ID |
GET /tool/vdb/wainao_chat/doc123
Authorization: Bearer YOUR_TOKEN
创建数据
创建新的向量数据。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| content | string | 是 | 内容文本 |
| tags | array | 否 | 标签列表 |
| metadata | object | 否 | 元数据 |
POST /tool/vdb/wainao_chat
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"content": "新的文档内容",
"tags": ["AI", "新文档"],
"metadata": {
"author": "用户名",
"createTime": "2024-01-10"
}
}
更新数据
/tool/vdb/{className}/{id}
更新指定ID的数据。路径参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| className | string | 是 | 数据库名称 |
| id | string | 是 | 数据ID |
PATCH /tool/vdb/wainao_chat/doc789
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"content": "更新后的文档内容",
"tags": ["AI", "更新文档"]
}
删除数据
/tool/vdb/{className}/{id}
删除指定ID的数据。路径参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| className | string | 是 | 数据库名称 |
| id | string | 是 | 数据ID |
DELETE /tool/vdb/wainao_chat/doc789
Authorization: Bearer YOUR_TOKEN
向量搜索
/tool/vdb/{className}/vector
基于内容进行向量相似度搜索。路径参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| className | string | 是 | 数据库名称 |
请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| content | string | 是 | 搜索内容 |
| query | object | 否 | 查询条件 |
POST /tool/vdb/wainao_chat/vector
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"content": "查找相似的AI文档",
"query": {
"filter": {
"tags": ["AI"]
},
"limit": 10
}
}
向量搜索支持基于内容的相似度匹配,可以通过query参数进行精确过滤。
错误码说明
| 错误码 | 说明 |
|---|
| 400 | 请求参数错误 |
| 404 | 数据不存在 |
| 422 | 数据处理错误 |
| 500 | 服务器错误 |
地址解析工具
地址文本智能解析服务。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| address | string | 是 | 地址文本 |
POST /tool/home/address
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"address": "张三 13800138000 浙江省杭州市西湖区文三路 443号"
}
支持智能识别收件人姓名、电话号码、省市区及详细地址。
OAuth认证服务
匿名认证
/tool/home/oauth/anonymous
创建匿名用户并获取访问令牌。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| anonymous | string | 是 | 匿名标识符 |
| passwd | string | 是 | 密码 |
POST /tool/home/oauth/anonymous
Content-Type: application/json
{
"anonymous": "anon_123",
"passwd": "password123"
}
匿名用户令牌有效期为1小时,刷新令牌有效期为30天。
授权码换取令牌
使用授权码获取访问令牌。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| code | string | 是 | 授权码 |
| client_id | string | 是 | 客户端ID |
POST /tool/home/oauth/token
Content-Type: application/x-www-form-urlencoded
{
"grant_type": "authorization_code",
"code": "auth_code_123",
"client_id": "client_123"
}
刷新访问令牌
使用刷新令牌获取新的访问令牌。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| grant_type | string | 是 | refresh_token |
| refresh_token | string | 是 | 刷新令牌 |
| client_id | string | 是 | 客户端ID |
POST /tool/home/oauth/rtoken
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer OLD_ACCESS_TOKEN
{
"grant_type": "refresh_token",
"refresh_token": "ryJxx...",
"client_id": "client_123"
}
刷新令牌仅可使用一次,使用后会自动失效并生成新的刷新令牌。
OAuth错误码说明
| 错误码 | 说明 |
|---|
| 400 | 请求参数错误 |
| 401 | 未授权或令牌无效 |
| 403 | 权限不足 |
| 500 | 服务器错误 |