Project Type: Academic / Proof-of-Concept
A standalone Python Flask web app that replicates basic ChatGPT functionality using the OpenAI API. Users can input prompts and receive AI-generated responses in real time.
- Flask-based web UI mimics ChatGPT interactions.
- Requires a valid OpenAI (ChatGPT) API key stored securely—not hard-coded.
- Supports conversational prompts and displays AI-generated replies in a clean interface.
- Implements best practices with a separate configuration file for sensitive data.
- Python 3.8 or newer
- Paid OpenAI subscription with an API key (set via environment variable or config file)
.
├── app.py # Flask server with main routes
├── config.py # Reads OpenAI API key securely
├── templates/
│ └── index.html # Chat interface
├── static/ # CSS/JS assets (if any)
├── requirements.txt # Python dependencies
└── README.md # This documentation
---
## Setup & Usage
1. Clone the repository:
```bash
git clone <repo-url>
cd GENAI_CHATGPTCLONE
2. Install dependencies:
```bash
pip install -r requirements.txt
3. Set your OpenAI API key (in config.py or as env variable):
'''bash
export OPENAI_API_KEY="sk-..."
4. Start the Flask app:
'''bash
python app.py
5. Open the browser at http://127.0.0.1:5000/
---
## How It Works
1. User inputs a prompt in the web interface.
2. The back-end Flask route forwards the prompt to OpenAI’s ChatGPT API.
3. The API response is returned and displayed to the user.
4. Designed for educational purposes—demonstrates how to integrate a basic LLM interface.
---
## Configuration Practice
1. config.py or environment variables securely store the API key.
2. No sensitive data is exposed or hard-coded in the codebase.
---
## Next Steps (Future Enhancements)
1. Add chat history persistence (user sessions and past interactions)
2. Style UI for better usability and responsiveness
3. Implement rate limiting or usage analytics
---
## Disclaimer
This project is for educational purposes only and is not intended for production use. You must have a valid OpenAI API key to run it.
---