A simple API project that interacts with OpenAI's ChatGPT model to create, read, update, and delete files. This project utilizes Django for the backend and OpenAI's API for generating content based on user input.
- Create Files: Store text content based on user prompts.
- Read Files: Retrieve a list of stored files.
- Update Files: Modify existing files with new content.
- Delete Files: Remove files from the database.
- OpenAI Integration: Generate content using the GPT-3.5-turbo model.
- Python 3.x
- Django
- OpenAI Python library
- Requests library
- Python-dotenv
-
Clone the repository:
git clone <repository-url> cd GPT_CRUD_API
-
Create and activate a virtual environment:
python -m venv .venv .venv\Scripts\activate # For Windows source .venv/bin/activate # For macOS/Linux
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and add your OpenAI API key:OPENAI_API_KEY=your_api_key_here
Run the application:
python chatgpt_file_api.py
When prompted, enter your command to interact with the API.
The application handles various errors that may occur during API interactions, including:
- Rate limit errors
- API connection errors
- General exceptions
Feel free to submit pull requests or open issues if you have suggestions or improvements.
This project is licensed under the MIT License.