Skip to content

Horizon733/Agentic-AI-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌾 Agentic AI Agriculture Chatbot

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.

🚀 Features

  • 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

🏗️ Architecture

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

📦 Installation

Prerequisites

  1. Python 3.8+
  2. Ollama: Install and run Ollama locally
    # Install Ollama from https://ollama.ai/
    # Pull the required model
    ollama pull qwen3:1.7b
  3. spaCy English Model:
    python -m spacy download en_core_web_md

Setup

  1. Clone the repository:

    git clone https://github.com/Horizon733/Agentic-AI-demo.git
    cd Agentic-AI-demo
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure API Keys:

    • Get your OpenWeatherMap API key from openweathermap.org
    • Update OPENWEATHER_API_KEY in utils.py:
    OPENWEATHER_API_KEY = "your-actual-api-key-here"
  4. Prepare Documents (Optional):

    • Place your agriculture-related PDF documents in the docs/ folder
    • The system comes with a sample farmerbook.pdf
  5. Initialize Vector Database:

    python populate_db.py

🎯 Usage

Running the Chatbot

  1. Start Ollama (if not running):

    ollama serve
  2. Launch the Streamlit app:

    streamlit run agent.py
  3. Open your browser and navigate to http://localhost:8501

Example Queries

  • 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?"

📁 Project Structure

├── 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)

🔧 Configuration

Model Configuration

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)

Embedding Model

Uses HuggingFace sentence-transformers for embeddings:

embed_model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")

Vector Store Configuration

ChromaDB settings can be modified in utils.py:

CHROMA_DB_DIR = "chroma"

🛠️ Available Tools

The agent has access to four main tools:

  1. WeatherTool: Provides real-time weather information for any location
  2. ENAMTool: Fetches current market prices from e-NAM platform
  3. docs_vector_query: Searches agriculture knowledge base using vector similarity
  4. docs_summary: Summarizes agriculture-related information when needed

🔄 Data Sources

  • 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.py for web scraping

🚦 API Endpoints

OpenWeatherMap API

  • Current Weather: https://api.openweathermap.org/data/2.5/weather
  • Geocoding: http://api.openweathermap.org/geo/1.0/direct

e-NAM API

  • Trade Details: https://enam.gov.in/capoaservices/tradedetails

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is open source and available under the MIT License.

🙏 Acknowledgments

  • 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

📞 Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Join our community discussions

🔮 Future Enhancements

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages