Krishi Sahayak

June 21, 2026 · View on GitHub

Krishi Sahayak

AI Agriculture Assistant for Indian Farmers

Python Flask Groq License Deploy uv

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.


Krishi Sahayak — Web Interface


Features

FeatureDescription
Text ChatAsk any agriculture question and get expert answers
Image DiagnosisUpload a crop photo → AI identifies diseases, pests & deficiencies
Voice InputSpeak in English, Hindi, or Hinglish via Groq Whisper
Voice OutputBot reads answers aloud using Groq Orpheus TTS
Conversation MemoryRemembers your chat context (Redis, with in-memory fallback)
Prompt Caching50% cost savings — cached prefixes across requests
Dark/Light ThemeGlassmorphism UI with one-click theme toggle
MultilingualResponds in English, Hindi, or Hinglish

Krishi Sahayak — Voice Chat on Mobile


Tech Stack

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

Quick Start

Prerequisites

1. Clone & Install

git clone https://github.com/mohammed97ashraf/LLM_Agri_Bot.git
cd LLM_Agri_Bot
uv sync

2. Configure

cp .env.example LLM_Agri_Bot/.env

Edit LLM_Agri_Bot/.env and add your Groq API key:

GROQ_API_KEY=gsk_your_key_here

3. Run

uv run python LLM_Agri_Bot/run.py

Open http://127.0.0.1:5000


Environment Variables

Copy .env.example to LLM_Agri_Bot/.env and configure:

VariableRequiredDefaultDescription
GROQ_API_KEYYesYour Groq API key (get one)
LLM_MODELNoopenai/gpt-oss-120bText LLM model
LLM_VISION_MODELNometa-llama/llama-4-scout-17b-16e-instructVision LLM model
LLM_TEMPERATURENo0.3Model temperature (0–2)
LLM_MAX_TOKENSNo2048Max response tokens
STT_MODELNowhisper-large-v3-turboSpeech-to-text model
TTS_MODELNocanopylabs/orpheus-v1-englishText-to-speech model
TTS_VOICENoautumnTTS voice name
REDIS_HOSTNolocalhostRedis host (optional — falls back to memory)
REDIS_PORTNo6379Redis port
REDIS_SSLNofalseEnable Redis SSL
FLASK_SECRET_KEYYes*dev-secret-keyFlask session secret (*required in production)
FLASK_DEBUGNotrueEnable debug mode

Project Structure

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

Deployment

  1. Push your code to GitHub
  2. Go to render.comNewWeb Service
  3. Connect your GitHub repo
  4. Render auto-detects render.yaml and Dockerfile
  5. Add your GROQ_API_KEY (and other env vars) in the Render dashboard
  6. Click Deploy

Docker

docker build -t krishi-sahayak .
docker run -p 10000:10000 --env-file LLM_Agri_Bot/.env krishi-sahayak

API Reference

MethodEndpointDescription
GET/Chat interface
POST/chatSend text, image, or audio — returns AI response
POST/chat/clearClear conversation history
GET/healthHealth check (Redis status)
GET/robots.txtSearch engine crawl rules
GET/sitemap.xmlXML sitemap
GET/llms.txtAI crawler disclosure
GET/.well-known/llms.txtAI crawler disclosure (well-known path)

How It Works

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

Contributing

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-feature

License

MIT License — see LICENSE


Built with care for Indian farmers

By Mohammed Ashraf · GitHub · LinkedIn