diff --git a/surfsense_backend/.env.example b/surfsense_backend/.env.example index b7e580a66..c711fd0b5 100644 --- a/surfsense_backend/.env.example +++ b/surfsense_backend/.env.example @@ -132,3 +132,6 @@ UVICORN_LOG_LEVEL=info # UVICORN_UDS="" # UVICORN_FD="" # UVICORN_ROOT_PATH="" + +# Ollama Configuration +# OLLAMA_BASE_URL=http://host.docker.internal:11434 diff --git a/surfsense_backend/app/config/__init__.py b/surfsense_backend/app/config/__init__.py index f279f2708..5aca49a30 100644 --- a/surfsense_backend/app/config/__init__.py +++ b/surfsense_backend/app/config/__init__.py @@ -163,6 +163,7 @@ class Config: # Azure OpenAI credentials from environment variables AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT") AZURE_OPENAI_API_KEY = os.getenv("AZURE_OPENAI_API_KEY") + OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL") # Pass Azure credentials to embeddings when using Azure OpenAI embedding_kwargs = {} @@ -170,6 +171,8 @@ class Config: embedding_kwargs["azure_endpoint"] = AZURE_OPENAI_ENDPOINT if AZURE_OPENAI_API_KEY: embedding_kwargs["azure_api_key"] = AZURE_OPENAI_API_KEY + if OLLAMA_BASE_URL: + embedding_kwargs["base_url"] = OLLAMA_BASE_URL embedding_model_instance = AutoEmbeddings.get_embeddings( EMBEDDING_MODEL,