A Retrieval-Augmented Generation (RAG) chatbot for answering agricultural queries using local LLMs (Ollama), ChromaDB for vector search, and a FastAPI web interface.
- Local LLMs: Uses Ollama to run models like Gemma, Llama locally
- Vector Search: Stores and retrieves agricultural Q&A using ChromaDB and embeddings
- Web Interface: User-friendly chat interface built with FastAPI and Jinja2 templates
- Privacy-Preserving: All data and models run locally
agrichat-annam/
├── .env # Environment config (used in backend)
├── docker-compose.yml # Runs frontend and backend together
├── render.yaml # Render deployment settings
├── README.md
│
├── agrichat-backend/ # FastAPI Backend with RAG pipelines
│ ├── app.py
│ ├── backendRequirements.txt
│ └── RAGpipelinev3/ # Main RAG pipeline (embedding, retrieval, LLM)
│ ├── main.py
│ ├── creating_database.py
│ ├── ollama_embedding.py
│ ├── chromaDb/
│ ├── Data/
│ └── Gemini_based_processing/ # Gemini-based RAG variant
│ ├── main.py
│ ├── creating_database.py
│ └── chromaDb/
│
├── agrichat-frontend/ # Static frontend (HTML, JS, CSS)
│ ├── index.html
│ ├── script.js
│ ├── style.css
│ └── Dockerfile
│
├── nginx/ # NGINX config for containerized frontend
│ └── default.confLinux: curl -fsSL https://ollama.com/install.sh | sh
text
Windows/Mac:
Download installer from ollama.ai
Verify Installation: ollama --version
text
ollama pull gemma:1b ollama pull nomic-embed-text
text
pip install langchain chromadb pandas fastapi uvicorn python-multipart markdown
text
- Place your Q&A CSV in the
data/directory - Ensure CSV has columns:
questionsandanswers
python creating_database.py
text
uvicorn app:app --reload --port 8000
text Visit http://localhost:8000
- Converts CSV Q&A data into vector embeddings
- Uses
OllamaEmbeddingswrapper for text embeddings - Stores documents in ChromaDB using
ChromaDBBuilder
ChromaQueryHandlerclass handles:- Vector similarity search
- Result reranking
- LLM prompt construction
- Response generation via Ollama API
- FastAPI server with two endpoints:
GET /: Renders chat interfacePOST /query: Processes user questions
- Converts markdown responses to HTML
- Start Ollama server: ollama serve
text
- Launch application(from agrichat-backend directory): uvicorn app:app --reload --port 8000
text
- Access chat interface at
http://localhost:8000
| Issue | Solution |
|---|---|
| Ollama not running | Run ollama serve in separate terminal |
| Model not found | Verify with ollama list and pull required models |
| ChromaDB path errors | Use absolute paths for Windows systems |
| Low memory errors | Use smaller models like gemma:1b |
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request