文档

Thread

更新时间:
一键部署

本文档主要基于当前Dashscope的Thread 类所具备的各类可被开发者使用的API 文档。

函数名

类型

Create

创建thread 类

retrieve

检索thread 类

modify

修改thread类

delete

删除thread 类


1. Create

1.1 代码示例

curl --location 'https://dashscope.aliyuncs.com/api/v1/threads' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>' \
--data '""'

curl --location 'https://dashscope.aliyuncs.com/api/v1/threads' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>' \
--data '{
    "messages": [
        {
            "role": "user",
            "content": "你好"
        }
    ]
}'

1.2 输入参数解释

输入参数名字

输入参数的描述

参数类型

是否必须

Messages

thread 所传入的message

Message 类

metadata

thread使用的名字

str

1.3 输出参数解释

{
    "id": "thread_e99a9fe7-0433-426f-98ad-a5139c36579c",
    "object": "thread",
    "created_at": 1711448377850,
    "metadata": {},
    "request_id": "dd9489ec-dbdb-95d4-9ff8-cfe29b61db27"
}

输出thread类,并包含除了用户输入以外参数的其他额外字段:

  • id :thread id

  • request_id :请求id

2. retrieve

2.1 代码示例

curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_c7ebb0ca-2e4f-43e5-b223-6e1f8c6fccc7' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>'

2.2 输入参数解释

输入参数名字

输入参数的描述

参数类型

是否必须

thread_id

待检索的thread_id

str

2.3 输出参数解释

{
    "id": "thread_c7ebb0ca-2e4f-43e5-b223-6e1f8c6fccc7",
    "object": "thread",
    "created_at": 1711507920700,
    "metadata": {},
    "request_id": "4d4e73ad-15fb-96ac-9262-0643a0fdb5ca"
}

输出检索到的thread类,并包含除了用户输入以外参数的其他额外字段:

  • id :thread_id

  • request_id :请求id

3. modify

3.1 代码示例

curl --location 'https://dashscope.aliyuncs.com/api/v1/threads/thread_c7ebb0ca-2e4f-43e5-b223-6e1f8c6fccc7' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>' \
--data '{
    "metadata": {
        "modified": "true",
        "user": "abc123"
    }
}'

3.2 输入参数解释

输入参数名字

输入参数的描述

参数类型

是否必须

thread_id

待检索的thread_id

str

metadata

thread使用的名字

dict

3.3 输出参数解释

{
    "id": "thread_c7ebb0ca-2e4f-43e5-b223-6e1f8c6fccc7",
    "object": "thread",
    "created_at": 1711507920700,
    "metadata": {
        "modified": "true",
        "user": "abc123"
    },
    "request_id": "a9ad63fa-b884-94be-9ec6-5000882de3c4"
}

输出检索到的thread类,并包含除了用户输入以外参数的其他额外字段:

  • id :thread_id

  • request_id :请求id

4. delete

4.1 代码示例

curl --location --request DELETE 'https://dashscope.aliyuncs.com/api/v1/threads/thread_c7ebb0ca-2e4f-43e5-b223-6e1f8c6fccc7' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-dashscope-api-key>'

4.2 输入参数解释

输入参数名字

输入参数的描述

参数类型

是否必须

thread

待检索的thread id

str

4.3 输出参数解释

{
    "id": "thread_c7ebb0ca-2e4f-43e5-b223-6e1f8c6fccc7",
    "object": "thread.deleted",
    "deleted": true,
    "request_id": "b4edb7b8-5855-9787-b5c3-0374ee2b3b2c"
}

输出删除thread后的状态


  • 本页导读 (1)
文档反馈