update
This commit is contained in:
@@ -15,6 +15,21 @@ OLLAMA_MODEL=phi3:latest
|
||||
|
||||
## ✅ How to Change the Model
|
||||
|
||||
### Important Note
|
||||
|
||||
✅ **The model IS automatically checked and downloaded on startup**
|
||||
|
||||
The `ollama-setup` service runs on every `docker-compose up` and:
|
||||
- Checks if the model specified in `.env` exists
|
||||
- Downloads it if missing
|
||||
- Skips download if already present
|
||||
|
||||
This means you can simply:
|
||||
1. Change `OLLAMA_MODEL` in `.env`
|
||||
2. Run `docker-compose up -d`
|
||||
3. Wait for download (if needed)
|
||||
4. Done!
|
||||
|
||||
### Step 1: Update .env File
|
||||
|
||||
Edit `backend/.env` and change the `OLLAMA_MODEL` value:
|
||||
@@ -30,22 +45,38 @@ OLLAMA_MODEL=mistral:7b
|
||||
OLLAMA_MODEL=your-custom-model:latest
|
||||
```
|
||||
|
||||
### Step 2: Restart Services
|
||||
|
||||
The model will be automatically downloaded on startup:
|
||||
### Step 2: Restart Services (Model Auto-Downloads)
|
||||
|
||||
**Option A: Simple restart (Recommended)**
|
||||
```bash
|
||||
# Stop services
|
||||
docker-compose down
|
||||
|
||||
# Start services (model will be pulled automatically)
|
||||
# Restart all services
|
||||
docker-compose up -d
|
||||
|
||||
# Watch the download progress
|
||||
# Watch the model check/download
|
||||
docker-compose logs -f ollama-setup
|
||||
```
|
||||
|
||||
**Note:** First startup with a new model takes 2-10 minutes depending on model size.
|
||||
The `ollama-setup` service will:
|
||||
- Check if the new model exists
|
||||
- Download it if missing (2-10 minutes)
|
||||
- Skip download if already present
|
||||
|
||||
**Option B: Manual pull (if you want control)**
|
||||
```bash
|
||||
# Pull the model manually first
|
||||
./pull-ollama-model.sh
|
||||
|
||||
# Then restart
|
||||
docker-compose restart crawler backend
|
||||
```
|
||||
|
||||
**Option C: Full restart**
|
||||
```bash
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
**Note:** Model download takes 2-10 minutes depending on model size.
|
||||
|
||||
## Supported Models
|
||||
|
||||
@@ -264,3 +295,68 @@ A: 5-10GB for small models, 50GB+ for large models. Plan accordingly.
|
||||
- [OLLAMA_SETUP.md](OLLAMA_SETUP.md) - Ollama installation & configuration
|
||||
- [GPU_SETUP.md](GPU_SETUP.md) - GPU acceleration setup
|
||||
- [AI_NEWS_AGGREGATION.md](AI_NEWS_AGGREGATION.md) - AI features overview
|
||||
|
||||
|
||||
## Complete Example: Changing from phi3 to llama3
|
||||
|
||||
```bash
|
||||
# 1. Check current model
|
||||
curl -s http://localhost:5001/api/ollama/models | python3 -m json.tool
|
||||
# Shows: "current_model": "phi3:latest"
|
||||
|
||||
# 2. Update .env file
|
||||
# Edit backend/.env and change:
|
||||
# OLLAMA_MODEL=llama3:8b
|
||||
|
||||
# 3. Pull the new model
|
||||
./pull-ollama-model.sh
|
||||
# Or manually: docker-compose exec ollama ollama pull llama3:8b
|
||||
|
||||
# 4. Restart services
|
||||
docker-compose restart crawler backend
|
||||
|
||||
# 5. Verify the change
|
||||
curl -s http://localhost:5001/api/ollama/models | python3 -m json.tool
|
||||
# Shows: "current_model": "llama3:8b"
|
||||
|
||||
# 6. Test performance
|
||||
curl -s http://localhost:5001/api/ollama/test | python3 -m json.tool
|
||||
# Should show improved quality with llama3
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Change Model Workflow
|
||||
|
||||
```bash
|
||||
# 1. Edit .env
|
||||
vim backend/.env # Change OLLAMA_MODEL
|
||||
|
||||
# 2. Pull model
|
||||
./pull-ollama-model.sh
|
||||
|
||||
# 3. Restart
|
||||
docker-compose restart crawler backend
|
||||
|
||||
# 4. Verify
|
||||
curl http://localhost:5001/api/ollama/test
|
||||
```
|
||||
|
||||
### Common Commands
|
||||
|
||||
```bash
|
||||
# List downloaded models
|
||||
docker-compose exec ollama ollama list
|
||||
|
||||
# Pull a specific model
|
||||
docker-compose exec ollama ollama pull mistral:7b
|
||||
|
||||
# Remove a model
|
||||
docker-compose exec ollama ollama rm phi3:latest
|
||||
|
||||
# Check current config
|
||||
curl http://localhost:5001/api/ollama/config
|
||||
|
||||
# Test performance
|
||||
curl http://localhost:5001/api/ollama/test
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user