Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jhariani opened this issue Jun 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jhariani
Copy link

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 jhariani added the bug Something isn't working label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant