向量存储文件批次

Beta

向量存储文件批次表示将多个文件添加到向量存储的操作。

相关指南: 文件搜索

创建向量存储文件批次

Beta

创建一个向量存储文件批次。

路径参数

参数名称类型必需描述
vector_store_idstring必需向量存储的ID,用于创建文件批次。

请求体

参数名称类型必需描述
file_idsarray必需向量存储应使用的文件 ID列表。对可以访问文件的工具(如file_search)很有用。

返回值

返回一个向量存储文件批次对象。

示例请求

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"]
    }'

示例响应

{
  "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
  }
}

获取向量存储文件批次

Beta

检索向量存储文件批次。

路径参数

参数名称类型必需描述
vector_store_idstring必需向量存储的ID,文件批次属于该存储。
batch_idstring必需要检索的文件批次的ID。

返回值

返回向量存储文件批次对象。

示例请求

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"

示例响应

{
  "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
  }
}

取消向量存储文件批次

Beta

取消向量存储文件批次。该操作会尽快尝试取消该批次中的文件处理。

路径参数

参数名称类型必需描述
vector_store_idstring必需向量存储的ID,文件批次属于该存储。
batch_idstring必需要取消的文件批次的ID。

返回值

返回修改后的向量存储文件批次对象。

示例请求

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

示例响应

{
  "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
  }
}

列出批次中的向量存储文件

Beta

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

路径参数

参数名称类型必需描述
vector_store_idstring必需向量存储的ID,文件属于该存储。
batch_idstring必需文件批次的ID,文件属于该批次。

查询参数

参数名称类型必需默认值描述
limitinteger可选20返回对象的数量限制。限制范围为1到100,默认值为20。
orderstring可选desc按对象的created_at时间戳排序。asc表示升序,desc表示降序。
afterstring可选用于分页的游标。after是一个对象ID,定义您在列表中的位置。例如,如果您进行一次列表请求并接收到100个对象,最后一个是obj_foo,您可以在后续调用中包括after=obj_foo以获取列表的下一页。
beforestring可选用于分页的游标。before是一个对象ID,定义您在列表中的位置。例如,如果您进行一次列表请求并接收到100个对象,最后一个是obj_foo,您可以在后续调用中包括before=obj_foo以获取列表的上一页。
filterstring可选按文件状态过滤。可选值:in_progresscompletedfailedcancelled

返回值

返回向量存储文件对象列表。

示例请求

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"

示例响应

{
  "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
}

向量存储文件批次对象

Beta

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

参数

参数名称类型描述
idstring标识符,可在API端点中引用。
objectstring对象类型,始终为 vector_store.file_batch
created_atinteger创建向量存储文件批次的Unix时间戳(以秒为单位)。
vector_store_idstring文件附加到的向量存储的ID。
statusstring向量存储文件批次的状态,可以是 in_progresscompletedcancelledfailed
file_countsobject文件数量统计信息。

file_counts 对象属性

属性名称类型描述
in_progressinteger正在处理中的文件数量。
completedinteger已完成的文件数量。
failedinteger处理失败的文件数量。
cancelledinteger被取消的文件数量。
totalinteger总文件数量。

示例对象

{
  "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
  }
}

Was this page helpful?