File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -400,6 +400,11 @@ export async function generateEmbeddings(
400400 if ( embeddingModel . startsWith ( 'ollama/' ) ) {
401401 const modelName = embeddingModel . slice ( 7 )
402402 const baseUrl = getOllamaBaseUrl ( ollamaBaseUrl )
403+ if ( ! isAllowedOllamaUrl ( baseUrl ) ) {
404+ throw new Error (
405+ `Ollama base URL "${ baseUrl } " is not allowed. Must point to localhost, a private IP address, or host.docker.internal.`
406+ )
407+ }
403408 logger . info ( `Using Ollama (${ baseUrl } ) for embedding generation with model ${ modelName } ` )
404409
405410 // Use pre-queried context length if provided, otherwise query it
@@ -509,6 +514,11 @@ export async function generateSearchEmbedding(
509514 if ( embeddingModel . startsWith ( 'ollama/' ) ) {
510515 const modelName = embeddingModel . slice ( 7 )
511516 const baseUrl = getOllamaBaseUrl ( ollamaBaseUrl )
517+ if ( ! isAllowedOllamaUrl ( baseUrl ) ) {
518+ throw new Error (
519+ `Ollama base URL "${ baseUrl } " is not allowed. Must point to localhost, a private IP address, or host.docker.internal.`
520+ )
521+ }
512522 logger . info ( `Using Ollama (${ baseUrl } ) for search embedding with model ${ modelName } ` )
513523 const embeddings = await retryWithExponentialBackoff (
514524 ( ) => callOllamaEmbeddingAPI ( [ query ] , modelName , baseUrl ) ,
You can’t perform that action at this time.
0 commit comments