Skip to content

albinjojo/agrowbot-RAG

Repository files navigation

Agrowbot

Lightweight retrieval-augmented QA helper for rice pest control guidance using FAISS and OpenAI chat completions.

Features

  • Builds embeddings from local PDF references with all-MiniLM-L6-v2 and stores them in FAISS.
  • Serves concise, context-grounded answers via OpenAI chat completions.
  • Robust voice interaction loop for interactive questioning.

Project structure

  • agri.index, chunks.pkl: FAISS index and serialized text chunks generated by index.py.
  • index.py: PDF ingestion, chunking (500-word windows), embedding, and index build script.
  • app.py: Runtime retrieval and Q&A loop backed by OpenAI with per-session chat memory.
  • requirements.txt: Python dependencies.

Prerequisites

  • Python 3.10+ recommended.
  • OpenAI API key (set as OPENAI_API_KEY). Optional OPENAI_MODEL overrides the default model.
  • Source PDFs placed alongside the scripts (filenames in index.py).

Setup

  1. Create and activate a virtual environment.
  2. Install deps: pip install -r requirements.txt.
  3. Create a .env file in the project root:
    OPENAI_API_KEY=your-key-here

Build the index

Run after placing the PDF files listed in index.py in the project root:

python index.py

Artifacts produced:

  • agri.index (FAISS index)
  • chunks.pkl (serialized text chunks)

Run the Q&A loop

python app.py

Type a question; enter exit or press Enter on an empty line to quit.

Notes

  • Responses strip asterisks and return 2-3 concise bullet phrases when context is available.
  • If the question is off-topic, the app replies with: I am sorry, I don't have the information to answer that question.
  • Retrieval uses top-3 chunks; adjust k in retrieve() if you need more or fewer.

to activate virtual env .\venv\Scripts\activate

About

agrowbot RAG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors