From 4c804715318cc4cbb0de071426d5b93d85f38539 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Wed, 10 Jul 2024 08:41:18 +0100 Subject: [PATCH 1/2] fix(vectorStores): correctly handle missing `files` in `uploadAndPoll()` (#926) --- src/resources/beta/vector-stores/file-batches.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/resources/beta/vector-stores/file-batches.ts b/src/resources/beta/vector-stores/file-batches.ts index 890a92190..e4a5c46fe 100644 --- a/src/resources/beta/vector-stores/file-batches.ts +++ b/src/resources/beta/vector-stores/file-batches.ts @@ -155,19 +155,22 @@ export class FileBatches extends APIResource { { files, fileIds = [] }: { files: Uploadable[]; fileIds?: string[] }, options?: Core.RequestOptions & { pollIntervalMs?: number; maxConcurrency?: number }, ): Promise { - if (files === null || files.length == 0) { - throw new Error('No files provided to process.'); + if (files == null || files.length == 0) { + throw new Error( + `No \`files\` provided to process. If you've already uploaded files you should use \`.createAndPoll()\` instead`, + ); } const configuredConcurrency = options?.maxConcurrency ?? 5; - //We cap the number of workers at the number of files (so we don't start any unnecessary workers) + + // We cap the number of workers at the number of files (so we don't start any unnecessary workers) const concurrencyLimit = Math.min(configuredConcurrency, files.length); const client = this._client; const fileIterator = files.values(); const allFileIds: string[] = [...fileIds]; - //This code is based on this design. The libraries don't accommodate our environment limits. + // This code is based on this design. The libraries don't accommodate our environment limits. // https://stackoverflow.com/questions/40639432/what-is-the-best-way-to-limit-concurrency-when-using-es6s-promise-all async function processFiles(iterator: IterableIterator) { for (let item of iterator) { @@ -176,10 +179,10 @@ export class FileBatches extends APIResource { } } - //Start workers to process results + // Start workers to process results const workers = Array(concurrencyLimit).fill(fileIterator).map(processFiles); - //Wait for all processing to complete. + // Wait for all processing to complete. await allSettledWithThrow(workers); return await this.createAndPoll(vectorStoreId, { From cf7da2ba056b1d6cc16dd41e0b414bc915c3a4f9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 07:41:38 +0000 Subject: [PATCH 2/2] release: 4.52.5 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 2 +- package.json | 2 +- scripts/build-deno | 2 +- src/version.ts | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d998f5422..8fe5ee19c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.52.4" + ".": "4.52.5" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 592724a41..cf1796bd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.52.5 (2024-07-10) + +Full Changelog: [v4.52.4...v4.52.5](https://github.com/openai/openai-node/compare/v4.52.4...v4.52.5) + +### Bug Fixes + +* **vectorStores:** correctly handle missing `files` in `uploadAndPoll()` ([#926](https://github.com/openai/openai-node/issues/926)) ([945fca6](https://github.com/openai/openai-node/commit/945fca646b02b52bbc9163cb51f5d87e7db8afd6)) + ## 4.52.4 (2024-07-08) Full Changelog: [v4.52.3...v4.52.4](https://github.com/openai/openai-node/compare/v4.52.3...v4.52.4) diff --git a/README.md b/README.md index b2f6d0ce4..1e8a544ee 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You can import in Deno via: ```ts -import OpenAI from 'https://deno.land/x/openai@v4.52.4/mod.ts'; +import OpenAI from 'https://deno.land/x/openai@v4.52.5/mod.ts'; ``` diff --git a/package.json b/package.json index c104fef39..d8c6dc739 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.52.4", + "version": "4.52.5", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/scripts/build-deno b/scripts/build-deno index 577844cbe..bd1e495d3 100755 --- a/scripts/build-deno +++ b/scripts/build-deno @@ -16,7 +16,7 @@ This is a build produced from https://github.com/openai/openai-node – please g Usage: \`\`\`ts -import OpenAI from "https://deno.land/x/openai@v4.52.4/mod.ts"; +import OpenAI from "https://deno.land/x/openai@v4.52.5/mod.ts"; const client = new OpenAI(); \`\`\` diff --git a/src/version.ts b/src/version.ts index d3f41b987..b1bb67f20 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.52.4'; // x-release-please-version +export const VERSION = '4.52.5'; // x-release-please-version