File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -452,7 +452,20 @@ export async function generateSearchEmbedding(
452452 const modelName = embeddingModel . slice ( 7 )
453453 const baseUrl = getOllamaBaseUrl ( ollamaBaseUrl )
454454 logger . info ( `Using Ollama (${ baseUrl } ) for search embedding with model ${ modelName } ` )
455- const embeddings = await callOllamaEmbeddingAPI ( [ query ] , modelName , baseUrl )
455+ const embeddings = await retryWithExponentialBackoff (
456+ ( ) => callOllamaEmbeddingAPI ( [ query ] , modelName , baseUrl ) ,
457+ {
458+ maxRetries : 3 ,
459+ initialDelayMs : 1000 ,
460+ maxDelayMs : 10000 ,
461+ retryCondition : ( error : unknown ) => {
462+ if ( error instanceof EmbeddingAPIError ) {
463+ return error . status === 429 || error . status >= 500
464+ }
465+ return isRetryableError ( error )
466+ } ,
467+ }
468+ )
456469 return embeddings [ 0 ]
457470 }
458471
You can’t perform that action at this time.
0 commit comments