RagBot is an AI-powered chatbot that provides information and assistance to users based on a predefined context. It uses Streamlit for the user interface, Langchain for document processing and retrieval, and Hugging Face Transformers for sentence embeddings.
- Answers user questions based on predefined question-answer pairs
- Handles out-of-scope questions by generating responses using LLMs and context from a JSON file
- Utilizes sentence embeddings to find the most relevant question-answer pair
- Provides a user-friendly interface using Streamlit
Before running RagBot, ensure that you have the following:
- Python 3.7 or higher
- An OpenAI API key
-
Clone the repository:
git clone https://github.com/codexnyctis/ragBot -
Navigate to the project directory:
cd ragBot -
Install the required dependencies:
pip install -r requirements.txt -
Create a
.envfile in the project directory and add your OpenAI API key:OPENAI_API_KEY=your-api-key
-
Prepare your data/OR use the example data:
- Create a
data.jsonfile in the project directory. - The file should contain an array of objects, where each object represents a question-answer pair in the following format:
[ { "question": "What is RagBot?", "answer": "RagBot is an AI-powered chatbot that provides information and assistance based on predefined context." }, ... ]
- Create a
-
Run the Streamlit app:
streamlit run ragBot.py -
Open the provided URL in your web browser.
-
Enter your question in the chat input field and press Enter.
-
RagBot will provide a response based on the provided context:
- If the question is similar to one of the predefined questions in
data.json, the corresponding answer will be displayed. - If the question is out-of-scope (i.e., not similar to any predefined question), RagBot will generate a response using the LLMs and the context from
data.json.
- If the question is similar to one of the predefined questions in
- To modify RagBot's behavior or add more functionality, you can update the code in
ragBot.py. - To change the predefined questions and answers, modify the
data.jsonfile. - You can customize the LLMs and models used by modifying the relevant code sections in
ragBot.py.