上传文件
步骤 1: 获取文件上传 url
请求
请求头
Authorization: AgentWeave用户访问令牌 或者 Api密钥
请求体
- request_data (必需):
- agent_id (必需)
- file_name (必需)
- file_size (必需)
- file_type (必需): 文件的 MIME 类型, 示例, application/pdf, image/png.
- hash (必需): 文件的 sha256.
- category (必需): "chat"
- thread_id (可选): thread 保存了您之前的对话, 如果开启新对话则留空, 所有之后的消息必须包含之前返回的
thread_id来保证上下文的一致性. - owner_type (可选): "org" 或 "user". 如果不提供, 默认为"user".
- org_id (可选): 如果
owner_type="org",org_id必须提供.
- request_type (必需): "upload_file"
请求体示例
{
"request_data": {
"agent_id": "open_chat_openai_c533c890-c1f0-444c-9bab-15cbae364a92",
"file_name": "name.png",
"file_type": "image/png",
"file_size": 910882,
"hash": "c46f6a4ad7869d4b5a84fa12511a762ff9dc68f63e0d596511c13270bd830545",
"category": "chat"
},
"request_type": "upload_file"
}
响应
- data:
- id: 文件id.
- upload: 上传文件的 url, 在步骤 2 中使用这个变量.
- public: 直接访问文件的 url.
- thread_id: 这个文件所属的 thread, thread 保存了您之前的对话.
- result:
- code: 若成功则返回 201000, 其余表示失败.
- message: "Successfully." 或者错误信息.
步骤 2: 向智能体上传文件
请求
PUT upload
请求头
Content-Type: 文件的MIME类型.
请求体
file