This directory contains a Python script that implements a conversational retrieval system using LangChain and OpenAI's API. The script allows users to query a collection of documents and receive responses based on the retrieved information.
- Load documents from a specified directory.
- Create and persist a vector store index for efficient querying.
- Engage in conversational interactions, maintaining chat history.
- Easily exit the program.
- Python 3.7+
- Required packages:
openailangchainchromadb
You can install the required packages using pip:
pip install openai langchain chromadb- Clone the Repository:
git clone https://github.com/king04aman/custom-gpt.git cd your_repository - Set the OpenAI API Key:
Replace
your_api_key_herein the script with your actual OpenAI API key. You can also set the environment variable directly in your terminal:export OPENAI_API_KEY="your_api_key_here"
- Prepare Your Data:
Place your documents in a folder named
data/. The script will load all documents from this directory.
Run the script from the command line:
python main.pyYou can provide an initial query as a command line argument:
python main.py "Your initial query here"If no initial query is provided, the script will prompt you to enter queries interactively. Type your question and press Enter to get a response. Type quit, q, or exit to exit the program.
- Set the
PERSISTvariable toTruein the script to enable saving the vector store index to disk for reuse in future sessions. - The index will be saved in a directory named
persist/.
Prompt (type 'quit' to exit): What is the significance of data persistence?
Response: [Your response here based on the documents]This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to submit issues or pull requests. Contributions are welcome!