The chatbot now uses Ollama (local AI) as the first preference, with Gemini API as a fallback. This means you can run the AI chatbot completely offline and locally!
macOS:
brew install ollama
# Or download from: https://ollama.ai/downloadLinux:
curl -fsSL https://ollama.ai/install.sh | shWindows: Download the installer from: https://ollama.ai/download
ollama serveThis will start Ollama on http://localhost:11434 (default port).
Pull a model that supports your languages (English, Hindi, Kannada):
# Recommended: Llama 3.2 (good multilingual support)
ollama pull llama3.2
# Alternative options:
# ollama pull llama3.1
# ollama pull mistral
# ollama pull qwen2.5The .env file already has default settings:
OLLAMA_MODEL=llama3.2
OLLAMA_URL=http://localhost:11434
You can change these if needed:
- OLLAMA_MODEL: The model name you pulled (e.g.,
llama3.2,llama3.1,mistral) - OLLAMA_URL: The URL where Ollama is running (default:
http://localhost:11434)
After setting up Ollama, restart your Flask application:
python app.py-
First Attempt: The chatbot tries to use Ollama (local)
- If Ollama is running and the model is available, it uses it
- Fast, private, and works offline!
-
Fallback: If Ollama is not available, it falls back to Gemini API
- Requires
GEMINI_API_KEYin.env - Works over the internet
- Requires
-
Final Fallback: If both fail, it uses rule-based responses
- Answers basic questions using farm data
- No AI, but still helpful
-
Make sure Ollama is running:
ollama serve
-
Test if the model is available:
ollama run llama3.2 "Hello, how are you?" -
Open the dashboard and try the chatbot
- It should use Ollama automatically!
- Make sure Ollama is running:
ollama serve - Check if it's on the correct port:
http://localhost:11434 - Verify the model is pulled:
ollama list
- Pull the model:
ollama pull llama3.2 - Check available models:
ollama list - Update
OLLAMA_MODELin.envto match your model name
- Try a smaller/faster model:
ollama pull llama3.2:1b(1B parameter version) - Or use a more powerful model if you have the resources
- Try a different model with better multilingual support:
ollama pull qwen2.5(good for Asian languages)ollama pull mistral(good multilingual support)
| Model | Size | Speed | Multilingual | Best For |
|---|---|---|---|---|
| llama3.2 | ~2GB | Fast | Good | General use, English |
| llama3.2:1b | ~700MB | Very Fast | Good | Quick responses |
| qwen2.5 | ~2GB | Fast | Excellent | Hindi, Kannada, Asian languages |
| mistral | ~4GB | Medium | Excellent | Best multilingual support |
✅ Privacy: All processing happens locally
✅ Offline: Works without internet
✅ Free: No API costs
✅ Fast: No network latency
✅ Customizable: Use any model you want
Need help? Check the main README.md or open an issue on the project repository.