向量存储文件批次
Beta
向量存储文件批次表示将多个文件添加到向量存储的操作。
相关指南: 文件搜索
创建向量存储文件批次
Beta
创建一个向量存储文件批次。
路径参数
参数名称 | 类型 | 必需 | 描述 |
---|---|---|---|
vector_store_id | string | 必需 | 向量存储的ID,用于创建文件批次。 |
请求体
参数名称 | 类型 | 必需 | 描述 |
---|---|---|---|
file_ids | array | 必需 | 向量存储应使用的文件 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_id | string | 必需 | 向量存储的ID,文件批次属于该存储。 |
batch_id | string | 必需 | 要检索的文件批次的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_id | string | 必需 | 向量存储的ID,文件批次属于该存储。 |
batch_id | string | 必需 | 要取消的文件批次的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_id | string | 必需 | 向量存储的ID,文件属于该存储。 |
batch_id | string | 必需 | 文件批次的ID,文件属于该批次。 |
查询参数
参数名称 | 类型 | 必需 | 默认值 | 描述 |
---|---|---|---|---|
limit | integer | 可选 | 20 | 返回对象的数量限制。限制范围为1到100,默认值为20。 |
order | string | 可选 | desc | 按对象的created_at 时间戳排序。asc 表示升序,desc 表示降序。 |
after | string | 可选 | 无 | 用于分页的游标。after 是一个对象ID,定义您在列表中的位置。例如,如果您进行一次列表请求并接收到100个对象,最后一个是obj_foo,您可以在后续调用中包括after=obj_foo以获取列表的下一页。 |
before | string | 可选 | 无 | 用于分页的游标。before 是一个对象ID,定义您在列表中的位置。例如,如果您进行一次列表请求并接收到100个对象,最后一个是obj_foo,您可以在后续调用中包括before=obj_foo以获取列表的上一页。 |
filter | string | 可选 | 无 | 按文件状态过滤。可选值:in_progress 、completed 、failed 、cancelled 。 |
返回值
返回向量存储文件对象列表。
示例请求
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
附加到向量存储的一批文件。
参数
参数名称 | 类型 | 描述 |
---|---|---|
id | string | 标识符,可在API端点中引用。 |
object | string | 对象类型,始终为 vector_store.file_batch 。 |
created_at | integer | 创建向量存储文件批次的Unix时间戳(以秒为单位)。 |
vector_store_id | string | 文件附加到的向量存储的ID。 |
status | string | 向量存储文件批次的状态,可以是 in_progress 、completed 、cancelled 或 failed 。 |
file_counts | object | 文件数量统计信息。 |
file_counts 对象属性
属性名称 | 类型 | 描述 |
---|---|---|
in_progress | integer | 正在处理中的文件数量。 |
completed | integer | 已完成的文件数量。 |
failed | integer | 处理失败的文件数量。 |
cancelled | integer | 被取消的文件数量。 |
total | integer | 总文件数量。 |
示例对象
{
"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
}
}