-
Notifications
You must be signed in to change notification settings - Fork 645
Claude/configure llama local ai 011 cv5d q jn6 v yp dc cabn ex xf #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
37-AN
wants to merge
3
commits into
airweave-ai:main
Choose a base branch
from
37-AN:claude/configure-llama-local-ai-011CV5dQJn6VYpDcCabnExXf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| # Quick Start: Local Llama with Ollama | ||
|
|
||
| ## What Was Done | ||
|
|
||
| Your Airweave system has been configured to use **local Llama models** via Ollama instead of cloud AI providers. This gives you: | ||
|
|
||
| ✅ **Zero cost** - No API charges | ||
| ✅ **Complete privacy** - Data never leaves your servers | ||
| ✅ **Offline capable** - No internet required | ||
| ✅ **Full control** - Choose your own models | ||
|
|
||
| ## 🚀 Quick Start (3 Commands) | ||
|
|
||
| ### 1. Start Services with Ollama | ||
|
|
||
| ```bash | ||
| cd docker | ||
| docker-compose --profile local-llm up -d | ||
| ``` | ||
|
|
||
| This starts all Airweave services + Ollama. | ||
|
|
||
| ### 2. Pull the AI Models | ||
|
|
||
| ```bash | ||
| # Pull LLM model (~40GB, takes 10-30 minutes) | ||
| docker exec -it airweave-ollama ollama pull llama3.3:70b | ||
|
|
||
| # Pull embedding model (~300MB, takes 1-2 minutes) | ||
| docker exec -it airweave-ollama ollama pull nomic-embed-text | ||
| ``` | ||
|
|
||
| **For testing/lower hardware**, use smaller models: | ||
| ```bash | ||
| docker exec -it airweave-ollama ollama pull llama3.2:3b | ||
| docker exec -it airweave-ollama ollama pull nomic-embed-text | ||
| ``` | ||
|
|
||
| ### 3. Verify Setup | ||
|
|
||
| ```bash | ||
| # Check models are installed | ||
| docker exec -it airweave-ollama ollama list | ||
|
|
||
| # Test generation | ||
| curl http://localhost:11434/api/generate -d '{ | ||
| "model": "llama3.3:70b", | ||
| "prompt": "Say hello!", | ||
| "stream": false | ||
| }' | ||
|
|
||
| # Check Airweave logs | ||
| docker logs airweave-backend | grep -i ollama | ||
| ``` | ||
|
|
||
| You should see: | ||
| ``` | ||
| [OllamaProvider] Connected to Ollama at http://ollama:11434 | ||
| [OllamaProvider] Using LLM model: llama3.3:70b | ||
| [OllamaProvider] Using embedding model: nomic-embed-text | ||
| ``` | ||
|
|
||
| ## ✅ That's It! | ||
|
|
||
| Your Airweave system is now using local AI. All search queries, embeddings, and AI operations will use your local Llama models. | ||
|
|
||
| ## 📊 System Requirements | ||
|
|
||
| **Minimum (for testing):** | ||
| - CPU: 4+ cores | ||
| - RAM: 8GB | ||
| - Disk: 50GB free | ||
| - Model: llama3.2:3b | ||
|
|
||
| **Recommended (for production):** | ||
| - CPU: 8+ cores | ||
| - RAM: 16GB+ | ||
| - GPU: NVIDIA RTX 3090 or better (24GB VRAM) | ||
| - Disk: 100GB+ free | ||
| - Model: llama3.3:70b | ||
|
|
||
| ## 🔧 Configuration Files Changed | ||
|
|
||
| | File | What Changed | | ||
| |------|--------------| | ||
| | `docker/docker-compose.yml` | Added Ollama service with `local-llm` profile | | ||
| | `backend/airweave/search/providers/ollama.py` | New provider implementation | | ||
| | `backend/airweave/search/factory.py` | Integrated Ollama provider | | ||
| | `backend/airweave/search/defaults.yml` | Set Ollama as primary provider | | ||
| | `backend/airweave/core/config.py` | Added `OLLAMA_BASE_URL` setting | | ||
| | `.env.example` | Added Ollama configuration | | ||
|
|
||
| ## 🎯 Provider Priority | ||
|
|
||
| Airweave will try providers in this order: | ||
|
|
||
| 1. **Ollama (local)** ← Your local models | ||
| 2. Cerebras (cloud) ← Fallback if Ollama down | ||
| 3. Groq (cloud) ← Second fallback | ||
| 4. OpenAI (cloud) ← Final fallback | ||
|
|
||
| To force **local-only** mode, remove cloud API keys from `.env`: | ||
| ```bash | ||
| # Comment these out in .env | ||
| # OPENAI_API_KEY=... | ||
| # GROQ_API_KEY=... | ||
| # CEREBRAS_API_KEY=... | ||
| ``` | ||
|
|
||
| ## 🖥️ GPU Acceleration (Optional) | ||
|
|
||
| For 10x faster inference, enable GPU support: | ||
|
|
||
| 1. Install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) | ||
|
|
||
| 2. Uncomment GPU section in `docker/docker-compose.yml`: | ||
| ```yaml | ||
| ollama: | ||
| deploy: | ||
| resources: | ||
| reservations: | ||
| devices: | ||
| - driver: nvidia | ||
| count: 1 | ||
| capabilities: [gpu] | ||
| ``` | ||
|
|
||
| 3. Restart: | ||
| ```bash | ||
| docker-compose --profile local-llm down | ||
| docker-compose --profile local-llm up -d | ||
| ``` | ||
|
|
||
| 4. Verify: | ||
| ```bash | ||
| docker exec -it airweave-ollama nvidia-smi | ||
| ``` | ||
|
|
||
| ## 📖 Model Options | ||
|
|
||
| ### Text Generation (LLM) | ||
|
|
||
| | Model | Size | RAM Needed | Best For | | ||
| |-------|------|------------|----------| | ||
| | `llama3.2:3b` | 4GB | 8GB | Testing, low hardware | | ||
| | `llama3.1:8b` | 8GB | 16GB | Balanced performance | | ||
| | `llama3.3:70b` | 40GB | 64GB or 24GB VRAM | Production quality | | ||
|
|
||
| ### Embeddings | ||
|
|
||
| | Model | Dimensions | Best For | | ||
| |-------|------------|----------| | ||
| | `nomic-embed-text` | 768 | General purpose (default) | | ||
| | `all-minilm` | 384 | Faster, less accurate | | ||
| | `mxbai-embed-large` | 1024 | More accurate | | ||
|
|
||
| Change models by editing `backend/airweave/search/defaults.yml`: | ||
|
|
||
| ```yaml | ||
| ollama: | ||
| llm: | ||
| name: "llama3.2:3b" # Change this | ||
| embedding: | ||
| name: "nomic-embed-text" # Change this | ||
| ``` | ||
|
|
||
| ## 🐛 Troubleshooting | ||
|
|
||
| **"Connection refused"** | ||
| ```bash | ||
| # Check Ollama is running | ||
| docker ps | grep ollama | ||
|
|
||
| # Restart if needed | ||
| docker-compose --profile local-llm restart ollama | ||
| ``` | ||
|
|
||
| **"Model not found"** | ||
| ```bash | ||
| # Pull the model | ||
| docker exec -it airweave-ollama ollama pull llama3.3:70b | ||
| ``` | ||
|
|
||
| **Slow responses** | ||
| - Use smaller model (`llama3.2:3b`) | ||
| - Enable GPU acceleration (see above) | ||
| - Check CPU/RAM usage: `docker stats` | ||
|
|
||
| **Out of memory** | ||
| - Use smaller model | ||
| - Increase Docker memory limit | ||
| - Add more RAM or use GPU | ||
|
|
||
| ## 📚 Full Documentation | ||
|
|
||
| See `docs/LOCAL_LLAMA_SETUP.md` for: | ||
| - Detailed architecture explanation | ||
| - Advanced configuration | ||
| - Production deployment guide | ||
| - Security & privacy considerations | ||
| - Cost comparison vs cloud AI | ||
| - Performance benchmarks | ||
|
|
||
| ## 🎉 Summary | ||
|
|
||
| You now have a **fully local AI system** running in Docker! | ||
|
|
||
| **What happens now:** | ||
| - All embeddings → Local Llama models | ||
| - All text generation → Local Llama models | ||
| - All reranking → Local Llama models | ||
| - Zero API costs ✅ | ||
| - Complete data privacy ✅ | ||
| - Offline capable ✅ | ||
|
|
||
| **Next steps:** | ||
| 1. Start using Airweave normally - it will automatically use local AI | ||
| 2. Monitor performance with `docker logs -f airweave-backend` | ||
| 3. Tune models in `defaults.yml` based on your needs | ||
| 4. Enable GPU for faster inference (optional) | ||
|
|
||
| Questions? Check `docs/LOCAL_LLAMA_SETUP.md` or the [Ollama docs](https://ollama.ai/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
View Feedback
Prompt for AI agents
```text Address the following comment on backend/airweave/search/factory.py at line 687: This change introduces a new Ollama provider, but `.cursor/rules/search-module.mdc` still documents only Cerebras, OpenAI, Groq, and Cohere. Please update the Cursor rule to include Ollama’s capabilities, configuration keys (e.g., `OLLAMA_BASE_URL`), and operation preferences so Cursor users get accurate guidance. (Based on your team's feedback about verifying Cursor rules per provider.) @@ -678,6 +680,11 @@ def _init_all_providers_for_operation( + ctx.logger.debug( + f"[Factory] Attempting to initialize OllamaProvider for {operation_name}" + ) + provider = OllamaProvider(base_url=api_key, model_spec=model_spec, ctx=ctx) if provider: ```