The LLM Chat RAG (Retriever-Augmented Generation) is a web application that allows you to interact with documents stored in a ChromaDB database using OpenAI's GPT-4o-mini model. This system provides a way to query documents for relevant information, retrieve context, and generate AI-driven responses based on that context.
- Retriever-Augmented Generation (RAG): Retrieve context from a database and use it to generate more accurate and informative responses.
- OpenAI GPT-4o-mini Model: Uses OpenAI's GPT-4o-mini to generate answers based on the retrieved context.
- ChromaDB Integration: Uses ChromaDB for efficient document retrieval and context management.
- Web-based UI: Interact with the system through a user-friendly web interface.
- Python 3.x: Ensure Python 3.6 or later is installed.
- OpenAI API Key: You must have an OpenAI API key to use the GPT model.
- ChromaDB: A local or cloud-based ChromaDB instance for document storage and retrieval.
Install required dependencies via pip:
pip install -r requirements.txtSet the following environment variables:
OPENAI_API_KEY=your_openai_api_key
CHROMA_DB_PATH=./chroma_db # (Optional) Path to the ChromaDB persistent databaseFor example, on Linux or macOS:
export OPENAI_API_KEY="your_openai_api_key"
export CHROMA_DB_PATH="./chroma_db"On Windows:
set OPENAI_API_KEY=your_openai_api_key
set CHROMA_DB_PATH=.\chroma_dbTo start the web application, run the following command:
python3 main.pyThen open your browser and navigate to the local URL (e.g., http://localhost:5000) to access the chat interface.
If you need to set up the ChromaDB collection before running the application, run:
python3 main.py --setupThis will initialize the ChromaDB collection with OpenAI embeddings.
Once the application is running, the web UI will present you with:
- An input field to type your query.
- A display area to show the generated response along with the sources used.
- Navigation options to access additional functionalities (e.g., viewing past interactions).
- ChromaDB Setup: On running the script, it will either set up a new ChromaDB collection or connect to an existing one containing document embeddings.
- Retriever-Augmented Generation (RAG): When a user submits a question via the web UI, the system retrieves relevant documents from ChromaDB and uses the retrieved context along with OpenAI's GPT model to generate an answer.
- Response Generation: The generated response is displayed on the web page, along with any sources used.
- Navigate to your web browser (e.g., http://localhost:5000).
- Type your question in the provided input field and submit.
- View the generated response along with any source references.
To contribute to this project, feel free to fork the repository, make changes, and create pull requests.
This project is licensed under the GNU General Public License - see the LICENSE file for details.