client icon indicating copy to clipboard operation
client copied to clipboard

[Bug]: \OpenAI\Resources\VectorStoresFileBatches::cancel should POST, missing `cancel` path component

Open jhariani opened this issue 2 years ago • 0 comments

Description

If you attempt to use \OpenAI\Resources\VectorStoresFileBatches::cancel to cancel a vector store file batch, the OAI API will return this error:

Invalid method for URL (DELETE /v1/vector_stores/vs_id/file_batches/vsfb_id)

This is because the payload is constructed with this HTTP method and URL pattern:

$payload = Payload::delete("vector_stores/$vectorStoreId/file_batches", $fileBatchId);

Per the OAI cancel batch documentation it should POST to cancel the batch, and construct the URL with this pattern:

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

Solution: Change this to use the Payload's cancel helper method:

$payload = Payload::cancel("vector_stores/$vectorStoreId/file_batches", $fileBatchId);

Steps To Reproduce

  1. Create a file$file = app(\OpenAI\Client::class)->files()->upload($data);
  2. Create a vector store file batch $batch = app(\OpenAI\Client::class)->vectorStores()->batches()->create($vectorStoreId, ['file_ids' => [$file->id]);
  3. Cancel it with app((\OpenAI\Client::class)->vectorStores()->batches()->cancel($vectorStoreId, $batch->id)
Screenshot 2024-06-20 at 1 39 56 PM

OpenAI PHP Client Version

v0.10.1

PHP Version

8.2.17

Notes

No response

jhariani avatar Jun 20 '24 17:06 jhariani