Batch 批处理
Batch 批处理
注意:1、建议batch的结果数据尽快取,openai可能政策变化
2、建议每个批次的数据量不要太大,文件过大比如几个G可能会下载不成功。
1. Create batch
input_file_id
(string,必填)
包含新批次请求的已上传文件的 ID。
有关如何上传文件的信息,请参阅上传文件。
您的输入文件必须采用 JSONL 文件格式,并且必须与目的批次一起上传。该文件最多可包含 50,000 个请求,大小最大可达 100 MB。endpoint
(string,必填)
用于批次中所有请求的端点。目前支持 /v1/chat/completions、/v1/embeddings 和 /v1/completions。请注意,/v1/embeddings 批次还限制批次中所有请求的最多 50,000 个嵌入输入。completion_window
(object,选填)
应处理批次的时间范围。Currently only 24h is supported.metadata
(string,选填,Defaults to null)
批次的可选自定义元数据。
示例.
2. Retrieve batch
batch_id
(string,必填)
要检索的批次的 ID。
示例.
3. Cancel batch
batch_id
(string,必填)
取消正在进行的批次。
示例.
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-abc123",
"completion_window": "24h",
"status": "cancelling",
"output_file_id": null,
"error_file_id": null,
"created_at": 1711471533,
"in_progress_at": 1711471538,
"expires_at": 1711557933,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": 1711475133,
"cancelled_at": null,
"request_counts": {
"total": 100,
"completed": 23,
"failed": 1
},
"metadata": {
"customer_id": "user_123456789",
"batch_description": "Nightly eval job",
}
}
4. List batch
after
(string,选填)
用于分页的光标。 after 是定义您在列表中位置的对象 ID。例如,如果您发出列表请求并收到 100 个以 obj_foo 结尾的对象,则后续调用可以包含 after=obj_foo 以获取列表的下一页。limit
(integer,选填,Defaults to 20)
要返回的对象数量的限制。限制范围可以在 1 到 100 之间,默认值为 20。
示例.
修改于 2024-06-11 08:32:47