diff --git a/docs/configuration.md b/docs/configuration.md index dadf6015..c03640af 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -129,9 +129,11 @@ This is useful for: - Testing with different configurations - Applications that need multiple clients with different configurations -## API Keys +## Environment Variables -API keys are configured through **environment variables**, not in the YAML file. +API keys and some provider settings are configured through **environment variables**, not in the YAML file. + +### API Keys ```bash # OpenAI @@ -147,6 +149,13 @@ export VOYAGE_API_KEY=your-key-here export CO_API_KEY=your-key-here ``` +### Provider Configuration + +```bash +# Ollama base URL (defaults to http://localhost:11434) +export OLLAMA_BASE_URL=http://localhost:11434 +``` + ## File Monitoring Set directories to monitor for automatic indexing: @@ -171,6 +180,23 @@ embeddings: vector_dim: 1024 ``` +The Ollama base URL can be configured via environment variable or config file: + +```bash +# Via environment variable (recommended) +export OLLAMA_BASE_URL=http://localhost:11434 +``` + +Or in your config file: + +```yaml +providers: + ollama: + base_url: http://localhost:11434 +``` + +If neither is set, it defaults to `http://localhost:11434`. + ### VoyageAI If you want to use VoyageAI embeddings you will need to install `haiku.rag` with the VoyageAI extras: @@ -236,7 +262,17 @@ Configure which LLM provider to use for question answering. Any provider and mod qa: provider: ollama model: gpt-oss +``` +The Ollama base URL can be configured via the `OLLAMA_BASE_URL` environment variable, config file, or defaults to `http://localhost:11434`: + +```bash +export OLLAMA_BASE_URL=http://localhost:11434 +``` + +Or in your config file: + +```yaml providers: ollama: base_url: http://localhost:11434 diff --git a/src/haiku/rag/config/models.py b/src/haiku/rag/config/models.py index 3bcc59d1..faa70c84 100644 --- a/src/haiku/rag/config/models.py +++ b/src/haiku/rag/config/models.py @@ -46,7 +46,11 @@ class ProcessingConfig(BaseModel): class OllamaConfig(BaseModel): - base_url: str = "http://localhost:11434" + base_url: str = Field( + default_factory=lambda: __import__("os").environ.get( + "OLLAMA_BASE_URL", "http://localhost:11434" + ) + ) class VLLMConfig(BaseModel):