矢量存储文件批处理
试用版

向量存储文件批次表示将多个文件添加到向量存储的作。 相关指南: 文件搜索source

创建矢量存储文件批处理
试用版

POST https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches

创建向量存储文件批处理。source

路径参数

要为其创建 File Batch 的向量存储的 ID。source

请求正文

矢量存储应使用的文件 ID 列表。适用于以下工具file_search可以访问文件。source

用于对文件进行分块的分块策略。如果未设置,将使用auto策略。source

示例请求
1
2
3
4
5
6
7
curl https://api.openai.com/v1/vector_stores/vs_abc123/file_batches \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -H "Content-Type: application/json \
    -H "OpenAI-Beta: assistants=v2" \
    -d '{
      "file_ids": ["file-abc123", "file-abc456"]
    }'
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "in_progress",
  "file_counts": {
    "in_progress": 1,
    "completed": 1,
    "failed": 0,
    "cancelled": 0,
    "total": 0,
  }
}

检索向量存储文件批处理
试用版

获取 https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}

检索向量存储文件批次。source

路径参数

文件批次所属的向量存储的 ID。source

正在检索的文件批处理的 ID。source

示例请求
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "in_progress",
  "file_counts": {
    "in_progress": 1,
    "completed": 1,
    "failed": 0,
    "cancelled": 0,
    "total": 0,
  }
}

取消向量存储文件批处理
试用版

post https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel

取消矢量存储文件批处理。这将尝试尽快取消此批处理中的文件的处理。source

路径参数

文件批次所属的向量存储的 ID。source

要取消的文件批次的 ID。source

返回

修改后的 vector store file 批处理对象。source

示例请求
1
2
3
4
5
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2" \
  -X POST
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "cancelling",
  "file_counts": {
    "in_progress": 12,
    "completed": 3,
    "failed": 0,
    "cancelled": 0,
    "total": 15,
  }
}

批量列出向量存储文件
试用版

获取 https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files

返回批量向量存储文件的列表。source

路径参数

文件所属的矢量存储的 ID。source

文件所属的文件批次的 ID。source

查询参数

要返回的对象数量限制。Limit 的范围可以介于 1 和 100 之间,默认值为 20。source

created_at对象的时间戳。asc对于升序和desc以降序排列。source

用于分页的游标。after是定义您在列表中的位置的对象 ID。例如,如果您发出列表请求并收到 100 个对象,以 obj_foo 结尾,则您的后续调用可以包含 after=obj_foo 以便获取列表的下一页。source

用于分页的游标。before是定义您在列表中的位置的对象 ID。例如,如果您发出一个列表请求并收到 100 个对象,以 obj_foo 开头,则您的后续调用可以包含 before=obj_foo 以便获取列表的上一页。source

按文件状态筛选。其中之一in_progress,completed,failed,cancelled.source

返回

矢量存储文件对象的列表。source

示例请求
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "object": "list",
  "data": [
    {
      "id": "file-abc123",
      "object": "vector_store.file",
      "created_at": 1699061776,
      "vector_store_id": "vs_abc123"
    },
    {
      "id": "file-abc456",
      "object": "vector_store.file",
      "created_at": 1699061776,
      "vector_store_id": "vs_abc123"
    }
  ],
  "first_id": "file-abc123",
  "last_id": "file-abc456",
  "has_more": false
}

向量存储文件批处理对象
试用版

附加到向量存储的一批文件。source

标识符,可在 API 终端节点中引用。source

对象类型,始终为vector_store.file_batch.source

创建向量存储文件批处理时的 Unix 时间戳(以秒为单位)。source

向量存储文件批处理的状态,可以是in_progress,completed,cancelledfailed.source

OBJECT 向量存储文件批处理对象
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_123",
  "object": "vector_store.files_batch",
  "created_at": 1698107661,
  "vector_store_id": "vs_abc123",
  "status": "completed",
  "file_counts": {
    "in_progress": 0,
    "completed": 100,
    "failed": 0,
    "cancelled": 0,
    "total": 100
  }
}