This project implements a chatbot for customers using Retrieval-Augmented Generation (RAG). The chatbot allows users to ask questions about uploaded documents or general information by integrating FastAPI for the backend, Streamlit for the frontend, and LangChain for the RAG pipeline. The project also uses Docker for containerization and supports deployment on AWS EC2 with a CI/CD pipeline.
- Upload Documents: Admins can upload files (PDF, text, or images) to enhance the chatbot's knowledge base.
- Question Answering: Users can ask questions, and the chatbot retrieves relevant document chunks using Pinecone, generates embeddings using OpenAI, and provides context-aware answers.
- Streamlit UI: Interactive user and admin interfaces for uploading files and interacting with the chatbot.
- API-Based Backend: FastAPI endpoints for managing data and handling chatbot queries.
- Containerized Deployment: Dockerized services for backend and frontend.
- Clone the Repository
git clone [email protected]:umarsaeedcheema/ResolveAI.git
cd ResolveAI- Create a virtual environment
python3 -m venv rag-bot
source rag-bot/bin/activate # For Linux/macOS
rag-bot\Scripts\activate # For Windows- Install Required Packages
Go into app and streamlit_ui folders and run :
pip install -r requirements.txt- Setup API Keys
Copy .env.example to .env
cp .env.example .envAdd the following API Keys to the env
openai_api_key=your_openai_api_key_here
pinecone_api_key=your_pinecone_api_key_here
pinecone_environment=your_pinecone_environment_here
pinecone_index_name=your_pinecone_index_name_here- Run Locally
Backend:
uvicorn app:app --host 0.0.0.0 --port 8000 --reloadFrontend:
streamlit run streamlit_app/main.py- Run with Docker
Build and start the containers:
docker-compose up --build- Access the services:
-
Backend: http://localhost:8000
-
Frontend: http://localhost:8501
- Add Data
- Endpoint: POST /add_data
- Description: Uploads a file (PDF, text, or image) and adds its content to Pinecone after preprocessing and chunking.
- Query Chatbot
- Endpoint: POST /query
- Description: Accepts a user query, retrieves relevant content from Pinecone, and generates a response using OpenAI GPT.
project_root/
├── app/
│ ├── app.py # FastAPI app entry point
│ ├── config.py # Configuration (environment variables, API keys)
│ ├── routes/ # API route files
│ │ ├── add_data.py # Endpoint for uploading and processing files
│ │ └── rag_workflow.py# Endpoint for query handling and RAG pipeline
│ └── logs/ # Logs for monitoring
│ └── Dockerfile # Dockerfile for backend
| └── requirements.txt # Python dependencies
├── streamlit_app/
│ ├── main.py # Streamlit user interface
│ └── Dockerfile # Dockerfile for frontend
| └── requirements.txt # Python dependencies
├── docker-compose.yml # Docker Compose configuration for multi-service setup
├── .env # Environment variables (API keys)
├── .gitignore # Ignore files for version control
└── README.md # Project documentation
-
Admins upload files (PDFs, text, or images) via the Streamlit admin page or POST /add_data endpoint.
-
Files are preprocessed, chunked, and stored in Pinecone with metadata.
-
Users enter queries via the Streamlit chatbot page or POST /query endpoint.
-
Pinecone retrieves relevant chunks, and OpenAI GPT generates a context-aware response.
- The Streamlit app interacts with the FastAPI backend using REST APIs.
-
Add support for more file types.
-
Enhance the admin interface with file management capabilities.