@@ -155,19 +155,22 @@ export class FileBatches extends APIResource {
155155 { files, fileIds = [ ] } : { files : Uploadable [ ] ; fileIds ?: string [ ] } ,
156156 options ?: Core . RequestOptions & { pollIntervalMs ?: number ; maxConcurrency ?: number } ,
157157 ) : 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+ ) ;
160162 }
161163
162164 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)
164167 const concurrencyLimit = Math . min ( configuredConcurrency , files . length ) ;
165168
166169 const client = this . _client ;
167170 const fileIterator = files . values ( ) ;
168171 const allFileIds : string [ ] = [ ...fileIds ] ;
169172
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.
171174 // https://stackoverflow.com/questions/40639432/what-is-the-best-way-to-limit-concurrency-when-using-es6s-promise-all
172175 async function processFiles ( iterator : IterableIterator < Uploadable > ) {
173176 for ( let item of iterator ) {
@@ -176,10 +179,10 @@ export class FileBatches extends APIResource {
176179 }
177180 }
178181
179- //Start workers to process results
182+ // Start workers to process results
180183 const workers = Array ( concurrencyLimit ) . fill ( fileIterator ) . map ( processFiles ) ;
181184
182- //Wait for all processing to complete.
185+ // Wait for all processing to complete.
183186 await allSettledWithThrow ( workers ) ;
184187
185188 return await this . createAndPoll ( vectorStoreId , {
0 commit comments