8000 GitHub - raj921/ragchatbot
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

raj921/ragchatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8000  

Repository files navigation

RAG-based Q&A Chatbot

This project is a web application that allows users to upload documents and perform question-answering (Q&A) using Retrieval-Augmented Generation (RAG). The application is built using Django (backend), React (frontend), Postgres with pgvector (vector database), Docker, and the OpenAI API for embeddings and LLM.

Features

  • Document Upload: Upload PDF documents. The application extracts text and splits it into chunks.
  • Embedding Generation: Generates embeddings for text chunks using OpenAI's text-embedding-ada-002.
  • Vector Storage: Stores embeddings in Postgres using the pgvector extension for similarity search.
  • Query-based Retrieval: Searches for relevant text chunks based on a user query and augments the query for LLM.
  • Chatbot Interface: A React-based chatbot interface for asking questions and receiving responses.
  • Containerized: Uses Docker and docker-compose for containerization.

Prerequisites

  • Docker
  • Docker Compose
  • OpenAI API Key

Setup and Run

  1. Clone the repository:

    git clone <repository_url>
    cd <repository_directory>
  2. Set up environment variables: Create a .env file in the root directory and add your OpenAI API key:

    OPENAI_API_KEY=your_openai_api_key_here
    
  3. Build and start the containers:

    docker-compose up --build
  4. Access the application:

Usage

  1. Open the application in your browser at http://localhost:3000
  2. Use the upload form to add PDF documents
  3. Once documents are uploaded, use the chatbot interface to ask questions
  4. The system will retrieve relevant context from the uploaded documents and generate answers

Project Structure

project/
├── backend/
│   ├── Dockerfile
│   ├── requirements.txt
│   ├── init-db/
│   │   └── init.sql
│   ├── manage.py
│   ├── project/
│   │   ├── settings.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   └── app/
│       ├── models.py
│       ├── urls.py
│       └── views.py
├── frontend/
│   ├── Dockerfile
│   ├── package.json
│   └── src/
│       ├── App.js
│       ├── index.js
│       └── components/
│           ├── FileUpload.js
│           └── Chatbot.js
├── docker-compose.yml
└── README.md

Notes

  • Ensure you have a valid OpenAI API key
  • The system uses the following OpenAI models:
    • text-embedding-ada-002 for generating embeddings
    • gpt-3.5-turbo for generating answers
  • The pgvector extension is automatically enabled in the Postgres database
  • The application uses a simple chunking strategy based on word count
  • Similarity search threshold can be adjusted in the backend code

Development

  • Backend development server runs on port 8000
  • Frontend development server runs on port 3000
  • Postgres database runs on port 5432

Security Notes

This is a development setup. For production:

  • Use proper authentication
  • Implement rate limiting
  • Set up HTTPS
  • Use secure database credentials
  • Implement proper error handling
  • Add logging
  • Add input validation
  • Add CSRF protection

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0