A modern, intelligent agriculture chatbot powered by LlamaIndex and Ollama that provides farmers and agriculture enthusiasts with comprehensive information about farming practices, weather updates, and market prices.
- Agriculture Knowledge Base: Vector-based retrieval from agricultural documents and farmer handbooks
- Real-time Weather Updates: Get current weather conditions for any location using OpenWeatherMap API
- Market Data Integration: Access live mandi prices from e-NAM (National Agriculture Market) platform
- Intelligent Agent: ReAct agent that can reason about which tools to use based on user queries
- User-friendly Interface: Streamlit-based web interface for easy interaction
- Multi-modal Responses: Combines document retrieval, summarization, and real-time data
The chatbot uses a modern agentic AI architecture with:
- LlamaIndex: For document indexing and retrieval
- Ollama: Local LLM (Qwen 3:1.7b) for reasoning and response generation
- ChromaDB: Vector database for storing document embeddings
- Streamlit: Web-based user interface
- spaCy: Natural language processing for entity extraction
- HuggingFace Embeddings: Sentence transformers for semantic search
- Python 3.8+
- Ollama: Install and run Ollama locally
# Install Ollama from https://ollama.ai/ # Pull the required model ollama pull qwen3:1.7b 
- spaCy English Model:
python -m spacy download en_core_web_md 
- 
Clone the repository: git clone https://github.com/Horizon733/Agentic-AI-demo.git cd Agentic-AI-demo
- 
Install dependencies: pip install -r requirements.txt 
- 
Configure API Keys: - Get your OpenWeatherMap API key from openweathermap.org
- Update OPENWEATHER_API_KEYinutils.py:
 OPENWEATHER_API_KEY = "your-actual-api-key-here" 
- 
Prepare Documents (Optional): - Place your agriculture-related PDF documents in the docs/folder
- The system comes with a sample farmerbook.pdf
 
- Place your agriculture-related PDF documents in the 
- 
Initialize Vector Database: python populate_db.py 
- 
Start Ollama (if not running): ollama serve 
- 
Launch the Streamlit app: streamlit run agent.py 
- 
Open your browser and navigate to http://localhost:8501
- Weather: "What's the weather in Mumbai?"
- Agriculture: "What fertilizer should I use for rice cultivation?"
- Market Data: "Show me today's mandi prices"
- Combined: "What's the weather in Delhi and what crops can I grow there?"
├── agent.py                 # Main Streamlit application with ReAct agent
├── utils.py                 # Utility functions for weather, market data, and indexing
├── populate_db_doc.py      # Script to populate vector database from documents
├── requirements.txt        # Python dependencies
├── docs/                   # Agriculture documents folder
│   └── farmerbook.pdf     # Sample agriculture handbook
├── chroma/                # ChromaDB vector store (auto-generated)
└── storage/              # LlamaIndex storage (auto-generated)
The chatbot uses Qwen 3:1.7b by default. You can change the model in agent.py:
llm = Ollama(model="qwen3:1.7b", request_timeout=60)Uses HuggingFace sentence-transformers for embeddings:
embed_model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")ChromaDB settings can be modified in utils.py:
CHROMA_DB_DIR = "chroma"The agent has access to four main tools:
- WeatherTool: Provides real-time weather information for any location
- ENAMTool: Fetches current market prices from e-NAM platform
- docs_vector_query: Searches agriculture knowledge base using vector similarity
- docs_summary: Summarizes agriculture-related information when needed
- Weather Data: OpenWeatherMap API
- Market Data: e-NAM (enam.gov.in) trade details API
- Agriculture Knowledge: PDF documents in the docs/folder
- Web Sources: Can be populated using populate_db.pyfor web scraping
- Current Weather: https://api.openweathermap.org/data/2.5/weather
- Geocoding: http://api.openweathermap.org/geo/1.0/direct
- Trade Details: https://enam.gov.in/capoaservices/tradedetails
- Fork the repository
- Create a feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
This project is open source and available under the MIT License.
- LlamaIndex for the powerful RAG framework
- Ollama for local LLM inference
- OpenWeatherMap for weather data
- e-NAM for agriculture market data
- HuggingFace for embedding models
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our community discussions
- Add more agriculture data sources
- Implement crop recommendation system
- Add multilingual support
- Integration with IoT sensors for real-time farm data
- Mobile app development
- Voice interface support
Made with ❤️ for the farming community