Live Demo → llm-agri-bot.onrender.com
An AI-powered agriculture chatbot that helps Indian farmers with crop advice, pest control, soil health, weather, and government schemes — using text, voice, and image analysis.
| Feature | Description |
|---|---|
| Text Chat | Ask any agriculture question and get expert answers |
| Image Diagnosis | Upload a crop photo → AI identifies diseases, pests & deficiencies |
| Voice Input | Speak in English, Hindi, or Hinglish via Groq Whisper |
| Voice Output | Bot reads answers aloud using Groq Orpheus TTS |
| Conversation Memory | Remembers your chat context (Redis, with in-memory fallback) |
| Prompt Caching | 50% cost savings — cached prefixes across requests |
| Dark/Light Theme | Glassmorphism UI with one-click theme toggle |
| Multilingual | Responds in English, Hindi, or Hinglish |
| Backend | Python 3.11+, Flask, Groq SDK |
| Frontend | HTML5, CSS3 (Glassmorphism), jQuery |
| LLM | openai/gpt-oss-120b (text), meta-llama/llama-4-scout-17b-16e-instruct (vision) |
| Speech | Groq Whisper whisper-large-v3-turbo (STT), Groq Orpheus canopylabs/orpheus-v1-english (TTS) |
| Memory | Redis (with automatic in-memory fallback) |
| Deploy | Render, Docker, Gunicorn |
- Python 3.11+
- uv package manager
- Groq API key (free tier available)
git clone https://github.com/mohammed97ashraf/LLM_Agri_Bot.git
cd LLM_Agri_Bot
uv synccp .env.example LLM_Agri_Bot/.envEdit LLM_Agri_Bot/.env and add your Groq API key:
GROQ_API_KEY=gsk_your_key_hereuv run python LLM_Agri_Bot/run.pyCopy .env.example to LLM_Agri_Bot/.env and configure:
| Variable | Required | Default | Description |
|---|---|---|---|
GROQ_API_KEY |
Yes | — | Your Groq API key (get one) |
LLM_MODEL |
No | openai/gpt-oss-120b |
Text LLM model |
LLM_VISION_MODEL |
No | meta-llama/llama-4-scout-17b-16e-instruct |
Vision LLM model |
LLM_TEMPERATURE |
No | 0.3 |
Model temperature (0–2) |
LLM_MAX_TOKENS |
No | 2048 |
Max response tokens |
STT_MODEL |
No | whisper-large-v3-turbo |
Speech-to-text model |
TTS_MODEL |
No | canopylabs/orpheus-v1-english |
Text-to-speech model |
TTS_VOICE |
No | autumn |
TTS voice name |
REDIS_HOST |
No | localhost |
Redis host (optional — falls back to memory) |
REDIS_PORT |
No | 6379 |
Redis port |
REDIS_SSL |
No | false |
Enable Redis SSL |
FLASK_SECRET_KEY |
Yes* | dev-secret-key |
Flask session secret (*required in production) |
FLASK_DEBUG |
No | true |
Enable debug mode |
LLM_Agri_Bot/
├── app/
│ ├── __init__.py # App factory (create_app)
│ ├── config.py # Environment-based configuration
│ ├── routes/
│ │ ├── main.py # Index page, robots.txt, sitemap, llms.txt
│ │ └── chat.py # Chat API (text, voice, image)
│ ├── services/
│ │ ├── llm_service.py # Groq LLM + vision + prompt caching
│ │ ├── memory_service.py # Redis + in-memory fallback
│ │ ├── stt_service.py # Groq Whisper STT
│ │ ├── tts_service.py # Groq Orpheus TTS
│ │ └── prompt_manager.py # XML + CoT system prompt
│ ├── static/
│ │ ├── css/style.css # Glassmorphism UI (dark/light)
│ │ ├── js/chat.js # Chat logic, image upload, voice
│ │ └── images/ # Favicon
│ └── templates/
│ └── index.html # Main template (SEO + JSON-LD)
├── Sample_image/ # Screenshots for README
├── llms.txt # AI crawler disclosure
├── .env.example # Environment template
├── gunicorn.conf.py # Production Gunicorn config
├── Dockerfile # Docker deployment
├── render.yaml # Render blueprint
├── run.py # Dev entry point
├── pyproject.toml # uv / project config
└── requirements.txt # pip fallback
- Push your code to GitHub
- Go to render.com → New → Web Service
- Connect your GitHub repo
- Render auto-detects
render.yamlandDockerfile - Add your
GROQ_API_KEY(and other env vars) in the Render dashboard - Click Deploy
docker build -t krishi-sahayak .
docker run -p 10000:10000 --env-file LLM_Agri_Bot/.env krishi-sahayak| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Chat interface |
POST |
/chat |
Send text, image, or audio — returns AI response |
POST |
/chat/clear |
Clear conversation history |
GET |
/health |
Health check (Redis status) |
GET |
/robots.txt |
Search engine crawl rules |
GET |
/sitemap.xml |
XML sitemap |
GET |
/llms.txt |
AI crawler disclosure |
GET |
/.well-known/llms.txt |
AI crawler disclosure (well-known path) |
User sends message (text / image / voice)
│
▼
┌─────────────────────────────────────────┐
│ Flask Backend │
│ ├── Text? → Groq LLM (gpt-oss-120b) │
│ ├── Image? → Llama 4 Scout (vision) │
│ └── Voice? → Whisper STT → LLM → TTS │
│ │
│ Memory: Redis (or in-memory fallback) │
│ Cache: Groq automatic prompt caching │
└─────────────────────────────────────────┘
│
▼
Response with text + optional voice audio
Contributions welcome! See CONTRIBUTING.md.
git checkout -b feature/your-feature
uv sync
# make changes
git commit -m "Add your feature"
git push origin feature/your-featureMIT License — see LICENSE
Built with care for Indian farmers
By Mohammed Ashraf · GitHub · LinkedIn

