From 2ad6f78261486505b7ad94a36dc1361c199f3edf Mon Sep 17 00:00:00 2001 From: Chen Ding Date: Tue, 16 Apr 2024 22:49:21 -0700 Subject: [PATCH 1/3] add list batch --- openapi.yaml | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 22107971..f03a30a8 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2413,6 +2413,79 @@ paths: "batch_description": "Nightly eval job", } } + get: + operationId: listBatches + tags: + - Batch + summary: List your organization's batches. + parameters: + - in: query + name: after + required: false + schema: + type: string + description: Identifier for the last batch from the previous pagination request. + - name: limit + in: query + description: Number of batches to retrieve. + required: false + schema: + type: integer + default: 20 + responses: + '200': + description: Batch listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ListBatchesResponse' + x-oaiMeta: + name: List batch + group: batch + returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects. + examples: + request: + curl: | + curl https://api.openai.com/v1/batches?limit=2 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + response: &batch_object | + { + "object": "list", + "data": [ + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly job", + } + }, + { ... }, + ], + "has_more": true + } /batches/{batch_id}: get: @@ -12587,6 +12660,22 @@ components: name: The request output object example: | {"id": "batch_req_wnaDys", "custom_id": "request-2", "response": {"status_code": 200, "request_id": "req_c187b3", "body": {"id": "chatcmpl-9758Iw", "object": "chat.completion", "created": 1711475054, "model": "gpt-3.5-turbo", "choices": [{"index": 0, "message": {"role": "assistant", "content": "2 + 2 equals 4."}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 24, "completion_tokens": 15, "total_tokens": 39}, "system_fingerprint": null}}, "error": null} + ListBatchesResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/Batch" + has_more: + type: boolean + object: + type: string + enum: [list] + required: + - object + - data + - has_more security: - ApiKeyAuth: [] @@ -12725,6 +12814,9 @@ x-oaiMeta: - type: endpoint key: cancelBatch path: cancel + - type: endpoint + key: listBatches + path: list - type: object key: Batch path: object From 55a63a4c3d1921d807856055e0f589de939977b0 Mon Sep 17 00:00:00 2001 From: Chen Ding Date: Tue, 16 Apr 2024 23:34:33 -0700 Subject: [PATCH 2/3] address comment --- openapi.yaml | 954 ++++++++++++++++++++++++++------------------------- 1 file changed, 481 insertions(+), 473 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index f03a30a8..6fbb2573 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2322,294 +2322,6 @@ paths: "has_more": true } - /batches: - post: - summary: Creates and executes a batch from an uploaded file of requests - operationId: createBatch - tags: - - Batch - requestBody: - required: true - content: - application/json: - schema: - type: object - required: - - input_file_id - - endpoint - - completion_window - properties: - input_file_id: - type: string - description: | - The ID of an uploaded file that contains requests for the new batch. - - See [upload file](/docs/api-reference/files/create) for how to upload a file. - - Your input file must be formatted as a JSONL file, and must be uploaded with the purpose `batch`. - endpoint: - type: string - enum: ["/v1/chat/completions"] - description: The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported. - completion_window: - type: string - enum: ["24h"] - description: The time frame within which the batch should be processed. Currently only `24h` is supported. - metadata: - type: object - additionalProperties: - type: string - description: Optional custom metadata for the batch. - nullable: true - responses: - "200": - description: Batch created successfully. - content: - application/json: - schema: - $ref: "#/components/schemas/Batch" - x-oaiMeta: - name: Create batch - group: batch - returns: The created [Batch](/docs/api-reference/batch/object) object. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "input_file_id": "file-abc123", - "endpoint": "/v1/chat/completions", - "completion_window": "24h" - }' - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "validating", - "output_file_id": null, - "error_file_id": null, - "created_at": 1711471533, - "in_progress_at": null, - "expires_at": null, - "finalizing_at": null, - "completed_at": null, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 0, - "completed": 0, - "failed": 0 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - get: - operationId: listBatches - tags: - - Batch - summary: List your organization's batches. - parameters: - - in: query - name: after - required: false - schema: - type: string - description: Identifier for the last batch from the previous pagination request. - - name: limit - in: query - description: Number of batches to retrieve. - required: false - schema: - type: integer - default: 20 - responses: - '200': - description: Batch listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ListBatchesResponse' - x-oaiMeta: - name: List batch - group: batch - returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches?limit=2 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" - response: &batch_object | - { - "object": "list", - "data": [ - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly job", - } - }, - { ... }, - ], - "has_more": true - } - - /batches/{batch_id}: - get: - operationId: retrieveBatch - tags: - - Batch - summary: Retrieves a batch. - parameters: - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the batch to retrieve. - responses: - "200": - description: Batch retrieved successfully. - content: - application/json: - schema: - $ref: "#/components/schemas/Batch" - x-oaiMeta: - name: Retrieve batch - group: batch - returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches/batch_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - response: &batch_object | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - - /batches/{batch_id}/cancel: - post: - operationId: cancelBatch - tags: - - Batch - summary: Cancels an in-progress batch. - parameters: - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the batch to cancel. - responses: - "200": - description: Batch is cancelling. Returns the cancelling batch's details. - content: - application/json: - schema: - $ref: "#/components/schemas/Batch" - x-oaiMeta: - name: Cancel batch - group: batch - returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches/batch_abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -X POST - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/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", - } - } - /models: get: operationId: listModels @@ -6541,23 +6253,170 @@ paths: from openai import OpenAI client = OpenAI() - vector_store_file_batch = client.beta.vector_stores.fileBatches.create( - vector_store_id="vs_abc123", - file_ids=["file-abc123", "file-abc456"] + vector_store_file_batch = client.beta.vector_stores.fileBatches.create( + vector_store_id="vs_abc123", + file_ids=["file-abc123", "file-abc456"] + ) + print(vector_store_file_batch) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const myVectorStoreFileBatch = await openai.beta.vector_stores.fileBatches.create( + "vs_abc123", + { + file_ids: ["file-abc123", "file-abc456"] + } + ); + console.log(myVectorStoreFileBatch); + } + + main(); + response: | + { + "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, + } + } + + /vector_stores/{vector_store_id}/file_batches/{batch_id}: + get: + operationId: getVectorStoreFileBatch + tags: + - Vector Stores + summary: Retrieves a vector store file batch. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: The ID of the vector store that the file batch belongs to. + - in: path + name: batch_id + required: true + schema: + type: string + example: vsfb_abc123 + description: The ID of the file batch being retrieved. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreFileBatchObject" + x-oaiMeta: + name: Retrieve vector store file batch + group: vector_stores + beta: true + returns: The [vector store file batch](/docs/api-reference/vector-stores/batch-object) object. + examples: + request: + curl: | + 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" + python: | + from openai import OpenAI + client = OpenAI() + + vector_store_file_batch = client.vector_stores.fileBatches.retrieve( + vector_store_id="vs_abc123", + batch_id="vsfb_abc123" + ) + print(vector_store_file_batch) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStoreFileBatch = await openai.vectorStores.fileBatches.retrieve( + "vs_abc123", + "vsfb_abc123" + ); + console.log(vectorStoreFileBatch); + } + + main(); + response: | + { + "id": "vsfb_abc123", + "object": "vector_store.file_batch", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + } + + /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel: + post: + operationId: cancelVectorStoreFileBatch + tags: + - Vector Stores + summary: Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store that the file batch belongs to. + - in: path + name: batch_id + required: true + schema: + type: string + description: The ID of the file batch to cancel. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreFileBatchObject" + x-oaiMeta: + name: Cancel vector store file batch + group: vector_stores + beta: true + returns: The modified vector store file batch object. + examples: + request: + curl: | + 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 + python: | + from openai import OpenAI + client = OpenAI() + + deleted_vector_store_file_batch = client.vector_stores.fileBatches.cancel( + vector_store_id="vs_abc123", + file_batch_id="vsfb_abc123" ) - print(vector_store_file_batch) + print(deleted_vector_store_file_batch) node.js: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const myVectorStoreFileBatch = await openai.beta.vector_stores.fileBatches.create( + const deletedVectorStoreFileBatch = await openai.vector_stores.fileBatches.cancel( "vs_abc123", - { - file_ids: ["file-abc123", "file-abc456"] - } + "vsfb_abc123" ); - console.log(myVectorStoreFileBatch); + console.log(deletedVectorStoreFileBatch); } main(); @@ -6567,53 +6426,81 @@ paths: "object": "vector_store.file_batch", "created_at": 1699061776, "vector_store_id": "vs_abc123", - "status": "in_progress", + "status": "cancelling", "file_counts": { - "in_progress": 1, - "completed": 1, + "in_progress": 12, + "completed": 3, "failed": 0, "cancelled": 0, - "total": 0, + "total": 15, } } - /vector_stores/{vector_store_id}/file_batches/{batch_id}: + /vector_stores/{vector_store_id}/file_batches/{batch_id}/files: get: - operationId: getVectorStoreFileBatch + operationId: listFilesInVectorStoreBatch tags: - Vector Stores - summary: Retrieves a vector store file batch. + summary: Returns a list of vector store files in a batch. parameters: - - in: path - name: vector_store_id + - name: vector_store_id + in: path + description: The ID of the vector store that the files belong to. required: true schema: type: string - example: vs_abc123 - description: The ID of the vector store that the file batch belongs to. - - in: path - name: batch_id + - name: batch_id + in: path + description: The ID of the file batch that the files belong to. required: true schema: type: string - example: vsfb_abc123 - description: The ID of the file batch being retrieved. + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + - name: filter + in: query + description: "Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`." + schema: + type: string + enum: ["in_progress", "completed", "failed", "cancelled"] responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileBatchObject" + $ref: "#/components/schemas/ListVectorStoreFilesResponse" x-oaiMeta: - name: Retrieve vector store file batch + name: List vector store files in a batch group: vector_stores beta: true - returns: The [vector store file batch](/docs/api-reference/vector-stores/batch-object) object. + returns: A list of [vector store file](/docs/api-reference/vector-stores/file-object) objects. examples: request: curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ + 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" @@ -6621,219 +6508,334 @@ paths: from openai import OpenAI client = OpenAI() - vector_store_file_batch = client.vector_stores.fileBatches.retrieve( + vector_store_files = client.vector_stores.fileBatches.files.list( vector_store_id="vs_abc123", batch_id="vsfb_abc123" ) - print(vector_store_file_batch) + print(vector_store_files) node.js: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const vectorStoreFileBatch = await openai.vectorStores.fileBatches.retrieve( + const vectorStoreFiles = await openai.vectorStores.fileBatches.files.list( "vs_abc123", "vsfb_abc123" ); - console.log(vectorStoreFileBatch); + console.log(vectorStoreFiles); } main(); response: | { - "id": "vsfb_abc123", - "object": "vector_store.file_batch", - "created_at": 1699061776, - "vector_store_id": "vs_abc123" + "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 + } + + /batches: + post: + summary: Creates and executes a batch from an uploaded file of requests + operationId: createBatch + tags: + - Batch + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - input_file_id + - endpoint + - completion_window + properties: + input_file_id: + type: string + description: | + The ID of an uploaded file that contains requests for the new batch. + + See [upload file](/docs/api-reference/files/create) for how to upload a file. + + Your input file must be formatted as a JSONL file, and must be uploaded with the purpose `batch`. + endpoint: + type: string + enum: ["/v1/chat/completions"] + description: The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported. + completion_window: + type: string + enum: ["24h"] + description: The time frame within which the batch should be processed. Currently only `24h` is supported. + metadata: + type: object + additionalProperties: + type: string + description: Optional custom metadata for the batch. + nullable: true + responses: + '200': + description: Batch created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Batch' + x-oaiMeta: + name: Create batch + group: batch + returns: The created [Batch](/docs/api-reference/batch/object) object. + examples: + request: + curl: | + curl https://api.openai.com/v1/batches \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' + response: | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "validating", + "output_file_id": null, + "error_file_id": null, + "created_at": 1711471533, + "in_progress_at": null, + "expires_at": null, + "finalizing_at": null, + "completed_at": null, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 0, + "completed": 0, + "failed": 0 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } + get: + operationId: listBatches + tags: + - Batch + summary: List your organization's batches. + parameters: + - in: query + name: after + required: false + schema: + type: string + description: *pagination_after_param_description + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + responses: + '200': + description: Batch listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ListBatchesResponse' + x-oaiMeta: + name: List batch + group: batch + returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects. + examples: + request: + curl: | + curl https://api.openai.com/v1/batches?limit=2 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + response: | + { + "object": "list", + "data": [ + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly job", + } + }, + { ... }, + ], + "first_id": "batch_abc123", + "last_id": "batch_abc456", + "has_more": true } - /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel: - post: - operationId: cancelVectorStoreFileBatch + /batches/{batch_id}: + get: + operationId: retrieveBatch tags: - - Vector Stores - summary: Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + - Batch + summary: Retrieves a batch. parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - description: The ID of the vector store that the file batch belongs to. - in: path name: batch_id required: true schema: type: string - description: The ID of the file batch to cancel. + description: The ID of the batch to retrieve. responses: - "200": - description: OK + '200': + description: Batch retrieved successfully. content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileBatchObject" + $ref: '#/components/schemas/Batch' x-oaiMeta: - name: Cancel vector store file batch - group: vector_stores - beta: true - returns: The modified vector store file batch object. + name: Retrieve batch + group: batch + returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. examples: request: curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ + curl https://api.openai.com/v1/batches/batch_abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -X POST - python: | - from openai import OpenAI - client = OpenAI() - - deleted_vector_store_file_batch = client.vector_stores.fileBatches.cancel( - vector_store_id="vs_abc123", - file_batch_id="vsfb_abc123" - ) - print(deleted_vector_store_file_batch) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const deletedVectorStoreFileBatch = await openai.vector_stores.fileBatches.cancel( - "vs_abc123", - "vsfb_abc123" - ); - console.log(deletedVectorStoreFileBatch); - } - - main(); - response: | + response: &batch_object | { - "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, + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", } } - /vector_stores/{vector_store_id}/file_batches/{batch_id}/files: - get: - operationId: listFilesInVectorStoreBatch + /batches/{batch_id}/cancel: + post: + operationId: cancelBatch tags: - - Vector Stores - summary: Returns a list of vector store files in a batch. + - Batch + summary: Cancels an in-progress batch. parameters: - - name: vector_store_id - in: path - description: The ID of the vector store that the files belong to. - required: true - schema: - type: string - - name: batch_id - in: path - description: The ID of the file batch that the files belong to. + - in: path + name: batch_id required: true schema: type: string - - name: limit - in: query - description: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - schema: - type: string - - name: filter - in: query - description: "Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`." - schema: - type: string - enum: ["in_progress", "completed", "failed", "cancelled"] + description: The ID of the batch to cancel. responses: - "200": - description: OK + '200': + description: Batch is cancelling. Returns the cancelling batch's details. content: application/json: schema: - $ref: "#/components/schemas/ListVectorStoreFilesResponse" + $ref: '#/components/schemas/Batch' x-oaiMeta: - name: List vector store files in a batch - group: vector_stores - beta: true - returns: A list of [vector store file](/docs/api-reference/vector-stores/file-object) objects. + name: Cancel batch + group: batch + returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. examples: request: curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ + curl https://api.openai.com/v1/batches/batch_abc123/cancel \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - vector_store_files = client.vector_stores.fileBatches.files.list( - vector_store_id="vs_abc123", - batch_id="vsfb_abc123" - ) - print(vector_store_files) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const vectorStoreFiles = await openai.vectorStores.fileBatches.files.list( - "vs_abc123", - "vsfb_abc123" - ); - console.log(vectorStoreFiles); - } - - main(); + -X POST response: | { - "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 + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/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", + } } components: @@ -12667,6 +12669,12 @@ components: type: array items: $ref: "#/components/schemas/Batch" + first_id: + type: string + example: "batch_abc123" + last_id: + type: string + example: "batch_abc456" has_more: type: boolean object: From 906e9e711437c4d011cba2e163c945ba94ba586e Mon Sep 17 00:00:00 2001 From: Chen Ding Date: Wed, 17 Apr 2024 11:01:12 -0700 Subject: [PATCH 3/3] merge --- openapi.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 6fbb2573..c9d6c4ac 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -6588,12 +6588,12 @@ paths: description: Optional custom metadata for the batch. nullable: true responses: - '200': + "200": description: Batch created successfully. content: application/json: schema: - $ref: '#/components/schemas/Batch' + $ref: "#/components/schemas/Batch" x-oaiMeta: name: Create batch group: batch @@ -6659,12 +6659,12 @@ paths: type: integer default: 20 responses: - '200': + "200": description: Batch listed successfully. content: application/json: schema: - $ref: '#/components/schemas/ListBatchesResponse' + $ref: "#/components/schemas/ListBatchesResponse" x-oaiMeta: name: List batch group: batch @@ -6729,12 +6729,12 @@ paths: type: string description: The ID of the batch to retrieve. responses: - '200': + "200": description: Batch retrieved successfully. content: application/json: schema: - $ref: '#/components/schemas/Batch' + $ref: "#/components/schemas/Batch" x-oaiMeta: name: Retrieve batch group: batch @@ -6790,12 +6790,12 @@ paths: type: string description: The ID of the batch to cancel. responses: - '200': + "200": description: Batch is cancelling. Returns the cancelling batch's details. content: application/json: schema: - $ref: '#/components/schemas/Batch' + $ref: "#/components/schemas/Batch" x-oaiMeta: name: Cancel batch group: batch @@ -12662,6 +12662,7 @@ components: name: The request output object example: | {"id": "batch_req_wnaDys", "custom_id": "request-2", "response": {"status_code": 200, "request_id": "req_c187b3", "body": {"id": "chatcmpl-9758Iw", "object": "chat.completion", "created": 1711475054, "model": "gpt-3.5-turbo", "choices": [{"index": 0, "message": {"role": "assistant", "content": "2 + 2 equals 4."}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 24, "completion_tokens": 15, "total_tokens": 39}, "system_fingerprint": null}}, "error": null} + ListBatchesResponse: type: object properties: