@@ -155,19 +155,22 @@ export class FileBatches extends APIResource {
155
155
{ files, fileIds = [ ] } : { files : Uploadable [ ] ; fileIds ?: string [ ] } ,
156
156
options ?: Core . RequestOptions & { pollIntervalMs ?: number ; maxConcurrency ?: number } ,
157
157
) : Promise < VectorStoreFileBatch > {
158
- if ( files === null || files . length == 0 ) {
159
- throw new Error ( 'No files provided to process.' ) ;
158
+ if ( files == null || files . length == 0 ) {
159
+ throw new Error (
160
+ `No \`files\` provided to process. If you've already uploaded files you should use \`.createAndPoll()\` instead` ,
161
+ ) ;
160
162
}
161
163
162
164
const configuredConcurrency = options ?. maxConcurrency ?? 5 ;
163
- //We cap the number of workers at the number of files (so we don't start any unnecessary workers)
165
+
166
+ // We cap the number of workers at the number of files (so we don't start any unnecessary workers)
164
167
const concurrencyLimit = Math . min ( configuredConcurrency , files . length ) ;
165
168
166
169
const client = this . _client ;
167
170
const fileIterator = files . values ( ) ;
168
171
const allFileIds : string [ ] = [ ...fileIds ] ;
169
172
170
- //This code is based on this design. The libraries don't accommodate our environment limits.
173
+ // This code is based on this design. The libraries don't accommodate our environment limits.
171
174
// https://stackoverflow.com/questions/40639432/what-is-the-best-way-to-limit-concurrency-when-using-es6s-promise-all
172
175
async function processFiles ( iterator : IterableIterator < Uploadable > ) {
173
176
for ( let item of iterator ) {
@@ -176,10 +179,10 @@ export class FileBatches extends APIResource {
176
179
}
177
180
}
178
181
179
- //Start workers to process results
182
+ // Start workers to process results
180
183
const workers = Array ( concurrencyLimit ) . fill ( fileIterator ) . map ( processFiles ) ;
181
184
182
- //Wait for all processing to complete.
185
+ // Wait for all processing to complete.
183
186
await allSettledWithThrow ( workers ) ;
184
187
185
188
return await this . createAndPoll ( vectorStoreId , {
0 commit comments