Message
本文档主要基于当前Dashscope的Message 类所具备的各类可被开发者使用的API文档。
函数名 | 类型 |
Create | 创建message 类 |
retrieve | 检索message 类 |
modify | 修改message类 |
delete | 删除message 类 |
1. Create Message
1.1 代码示例
curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_e99a9fe7-0433-426f-98ad-a5139c36579c/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>' \
--data '{
"role": "user",
"content": "你是谁",
"metadata": {}
}'
1.2 输入参数解释
输入参数名字 | 输入参数的描述 | 参数类型 | 是否必须 |
thread id | message 所传入的thread id | str | 是 |
content | message的具体信息 | str | 是 |
role | 传入信息的角色。目前只支持role = “user" | str | 否 |
file_ids | message 可以使用的文件id。目前最大只支持?个文件。 | str | 否 |
metadata | 其他相关信息 | str | 否 |
1.3 输出参数解释
{
"id": "message_f1933671-19e1-4162-ad25-7326165123e1",
"object": "thread.message",
"created_at": 1711508433283,
"thread_id": "thread_e99a9fe7-0433-426f-98ad-a5139c36579c",
"assistant_id": "",
"run_id": "",
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "你是谁",
"annotations": []
}
}
],
"file_ids": [],
"metadata": {},
"from": "",
"name": "",
"plugin_call": {},
"tool_calls": [],
"status": {},
"request_id": "b3ad40b9-f052-9665-a064-dab11c34625f"
}
输出message类,并包含除了用户输入以外参数的其他额外字段:
id :message id
request_id :请求id
2. message list
2.1 代码示例
curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_e99a9fe7-0433-426f-98ad-a5139c36579c/messages?limit=2&order=desc' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>'
2.2 输入参数解释
输入参数名字 | 输入参数的描述 | 参数类型 | 是否必须 |
thread id | message 所传入的thread id | str | 是 |
limit | 创建message的数量 | int | 否 |
order | 按照创建时间升序或降序 | str | 否(默认为“desc") |
2.3 输出参数解释
{
"object": "list",
"data": [
{
"id": "message_f1933671-19e1-4162-ad25-7326165123e1",
"object": "thread.message",
"created_at": 1711508433283,
"thread_id": "thread_e99a9fe7-0433-426f-98ad-a5139c36579c",
"assistant_id": "",
"run_id": "",
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "你是谁",
"annotations": []
}
}
],
"file_ids": [],
"metadata": {},
"from": "",
"name": "",
"plugin_call": {},
"tool_calls": [],
"status": {}
}
],
"first_id": "message_f1933671-19e1-4162-ad25-7326165123e1",
"last_id": "message_f1933671-19e1-4162-ad25-7326165123e1",
"has_more": false,
"request_id": "78f7d607-4a9a-90c6-8040-d3f81c84d60a"
}
输出List message类,并包含除了用户输入以外参数的其他额外字段:
多个message 组成的列表
3. list message file
3.1 代码示例
用于创建可附在message 内部的文件列表(file list)
curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_e99a9fe7-0433-426f-98ad-a5139c36579c/messages/message_ea26d29d-4509-490e-98e9-9f6238bd821b/files?limit=2&order=desc' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>'
3.2 输入参数解释
输入参数名字 | 输入参数的描述 | 参数类型 | 是否必须 |
thread id | message 所传入的thread id | str | 是 |
message id | 创建的message file所隶属的message id | str | 是 |
limit | 创建message file的数量 | int | 否 |
order | 按照创建时间升序或降序 | str | 否(默认为“desc") |
3.3 输出参数解释
{
"object": "list",
"data": [
{
"id": "file-abc123",
"object": "thread.message.file",
"created_at": 1711508622608,
"message_id": "message_ea26d29d-4509-490e-98e9-9f6238bd821b"
}
],
"first_id": "file-abc123",
"last_id": "file-abc123",
"has_more": false,
"request_id": "5e9f2b36-9aa7-9242-b86b-36b8f3a95bd9"
}
输出list message file 类,并包含除了用户输入以外参数的其他额外字段:
多个message file类组成
request_id :请求id
4. retrieve message
4.1 代码示例
curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_e99a9fe7-0433-426f-98ad-a5139c36579c/messages/message_ea26d29d-4509-490e-98e9-9f6238bd821b' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>'
4.2 输入参数解释
输入参数名字 | 输入参数的描述 | 参数类型 | 是否必须 |
thread id | 待检索的message 所传入的thread id | str | 是 |
message_id | 待检索的message_id | str | 是 |
4.3 输出参数解释
{
"id": "message_ea26d29d-4509-490e-98e9-9f6238bd821b",
"object": "thread.message",
"created_at": 1711508622598,
"thread_id": "thread_e99a9fe7-0433-426f-98ad-a5139c36579c",
"assistant_id": "",
"run_id": "",
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "你好",
"annotations": []
}
}
],
"file_ids": [
"file-abc123"
],
"metadata": {},
"from": "",
"name": "",
"plugin_call": {},
"tool_calls": [],
"status": {},
"request_id": "4d5ce962-91c3-9edb-87f7-00bbf985135e"
}
输出检索到的message类,并包含除了用户输入以外参数的其他额外字段:
id :message_id
request_id :请求id
5. retrieve message file
5.1 代码示例
curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_e99a9fe7-0433-426f-98ad-a5139c36579c/messages/message_ea26d29d-4509-490e-98e9-9f6238bd821b/files/file-abc123' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>'
5.2 输入参数解释
输入参数名字 | 输入参数的描述 | 参数类型 | 是否必须 |
thread id | 待检索的message 所传入的thread id | str | 是 |
message_id | 待检索的message file 所隶属的message id | str | 是 |
file_id | 待检索的message file id | str | 是 |
5.3 输出参数解释
{
"id": "file-abc123",
"object": "thread.message.file",
"created_at": 1711508622608,
"message_id": "message_ea26d29d-4509-490e-98e9-9f6238bd821b",
"request_id": "04ac8567-aef9-9f11-b83f-131e735e6ff8"
}
输出检索到的message file类,并包含除了用户输入以外参数的其他额外字段:
id :file_ id
request_id :请求id
6. modify message
6.1 代码示例
curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_e99a9fe7-0433-426f-98ad-a5139c36579c/messages/message_ea26d29d-4509-490e-98e9-9f6238bd821b' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>' \
--data '{
"metadata": {
"modified": "true",
"user": "abc123"
}
}'
6.2 输入参数解释
输入参数名字 | 输入参数的描述 | 参数类型 | 是否必须 |
thread_id | 待修改的thread_id | str | 是 |
message_id | 待修改的message_id | str | 是 |
metadata | dict |
6.3 输出参数解释
{
"id": "message_ea26d29d-4509-490e-98e9-9f6238bd821b",
"object": "thread.message",
"created_at": 1711508622598,
"thread_id": "thread_e99a9fe7-0433-426f-98ad-a5139c36579c",
"assistant_id": "",
"run_id": "",
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "你好",
"annotations": []
}
}
],
"file_ids": [
"file-abc123"
],
"metadata": {
"modified": "true",
"user": "abc123"
},
"from": "",
"name": "",
"plugin_call": {},
"tool_calls": [],
"status": {},
"request_id": "7877b011-cb94-9df1-9add-dc42b7d611f6"
}
输出修改后message类,并包含除了用户输入以外参数的其他额外字段:
id :message_id
request_id :请求id
- 本页导读 (1)