A Python-based chatbot that answers questions about the content of a JSON file using the ChatGPT API.
The Chatbot is a tool that allows users to ask questions about the content of a JSON file. It utilizes the ChatGPT API to process the user's input, extract relevant information from the JSON data, and provide appropriate responses. The chatbot aims to provide a convenient way to retrieve specific information from a structured JSON file.
The chatbot is available in two versions:
- Command-line interface (CLI) version
- Web-based version using Flask and jQuery
- Integration with the ChatGPT API for natural language processing
- Parsing and querying JSON data to provide relevant answers
- Handling of edge cases and error scenarios
- Extensible architecture for future enhancements
-
Clone the repository:
git clone https://github.com/simonpainter/chatbot.git -
Navigate to the project directory:
cd chatbot -
(Optional) Create a virtual environment:
python -m venv venv source venv/bin/activate -
Install the required dependencies:
pip install -r requirements.txt -
Obtain an API key from OpenAI and set the
OPENAI_API_KEYenvironment variable with your API key.
-
Prepare your JSON file containing the data you want to query. Place the file in the project directory and name it
data.json. -
Run the chatbot:
python chatbot.py -
Enter your questions or queries when prompted. The chatbot will process your input and provide relevant answers based on the content of the JSON file.
-
Type
quitorexitto terminate the chatbot.
-
Prepare your JSON file containing the data you want to query. Place the file in the project directory and name it
data.json. -
Run the Flask app:
python app.py -
Open a web browser and go to
http://localhost:5000to access the chatbot interface. -
Enter your questions or queries in the chat input field and click the "Send" button or press Enter. The chatbot will process your input and display the relevant answers in the chat history.
-
To terminate the Flask app, press
Ctrl + Cin the terminal where the app is running.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request. Make sure to follow the existing code style and include appropriate tests.
This project is licensed under the MIT License.