Skip to content

[Submission] chakradhar(team:Knight shades) RAG AppMain

LEELA CHAKRADHAR K requested to merge Chakradhar_01/kishan-ai:main into main

🌾 KisanAI — AI Farmer Support Chatbot

An intelligent RAG-powered chatbot that answers farming questions from your own agricultural PDF documents.

Python Streamlit FAISS License


📋 Table of Contents


Features

Feature Description
🌿 Crop Guidance Disease identification & treatment recommendations
🧪 Fertilizers NPK recommendations, organic options
🐛 Pest Control Integrated pest management advice
🌦️ Weather Tips Seasonal and weather-aware suggestions
🪱 Soil Health pH, organic matter, irrigation tips
🏛️ Govt Schemes PM-KISAN, Fasal Bima, KCC details
🌐 Multi-language Hindi, Telugu, Tamil, Punjabi, Marathi
📂 PDF Upload Index your own agricultural documents

🏗️ Architecture

User Question


Streamlit UI (app.py)


Embed Question ──── SentenceTransformers (all-MiniLM-L6-v2)


FAISS Similarity Search ──── vectorstore/faiss.index


Top-K Relevant Chunks ──── vectorstore/chunks.pkl


Prompt Engineering + Context Injection


HuggingFace Inference API (Mistral-7B)


Grounded Agricultural Answer → Streamlit Chat UI

🚀 Quick Start

1. Clone & Enter

git clone https://github.com/yourname/kisanai.git
cd kisanai

2. Create Virtual Environment

python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Set API Token (optional but recommended)

cp .env.example .env
# Edit .env and add your Hugging Face token:
# HF_API_TOKEN=hf_your_token_here

🆓 Get a free Hugging Face token at https://huggingface.co/settings/tokens
The app works without a token (returns context excerpts), but LLM answers require it.

5. Add Agricultural PDFs

Place your PDF files in data/agricultural_pdfs/:

data/agricultural_pdfs/
├── crop_diseases_manual.pdf
├── fertilizer_guide.pdf
├── pm_kisan_scheme.pdf
└── soil_health_handbook.pdf

6. Run the App

streamlit run app.py

Open http://localhost:8501 in your browser.

7. Build Knowledge Base

  1. Go to 📂 Upload Documents in the sidebar
  2. Upload your PDFs (or they're already in the data/ folder)
  3. Click ️ Build Knowledge Base
  4. Return to 🏠 Home & Chat and start asking questions!

📁 Project Structure

kisanai/
├── app.py                          # Main Streamlit application
├── .env.example                    # Environment variable template
├── .streamlit/
│   └── config.toml                 # Streamlit theme configuration
├── assets/                         # Static assets (logos, images)
├── data/
│   └── agricultural_pdfs/          # Place your PDF files here
├── vectorstore/                    # Auto-generated FAISS index
│   ├── faiss.index
│   └── chunks.pkl
├── utils/
│   ├── __init__.py
│   ├── pdfloader.py                # PDF text extraction + chunking
│   ├── embedding.py                # SentenceTransformers + FAISS
│   └── retrieval.py                # Semantic search + HF API calls
├── requirements.txt
└── README.md

👥 Team Roles

Member Role Files
Member 1 Frontend / UI app.py, .streamlit/
Member 2 PDF Processing utils/pdfloader.py, data/
Member 3 Embeddings / FAISS utils/embedding.py, vectorstore/
Member 4 LLM / RAG Pipeline utils/retrieval.py
Member 5 Testing / Deployment requirements.txt, README.md, CI

️ Configuration

Variable File Description
HF_API_TOKEN .env HuggingFace API token
CHUNK_SIZE utils/pdfloader.py Characters per chunk (default 800)
CHUNK_OVERLAP utils/pdfloader.py Overlap between chunks (default 150)
TOP_K utils/retrieval.py Retrieved chunks per query (default 5)
HF_MODEL utils/retrieval.py HuggingFace model to use

🌐 Deployment

Streamlit Community Cloud (Recommended — Free)

  1. Push to GitHub
  2. Go to https://share.streamlit.io
  3. Connect your repo, set main file as app.py
  4. Add HF_API_TOKEN in Secrets (Settings → Secrets)
  5. Deploy!

Local Docker

FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
docker build -t kisanai .
docker run -p 8501:8501 --env-file .env kisanai

📞 Support Resources

  • Kisan Call Centre: 1800-180-1551 (toll-free, 24×7)
  • PM-KISAN Helpline: 155261
  • ICAR Website: https://icar.org.in

Built with ️ for India's 140 million farming families.

Merge request reports

Loading