A simple Flask API for interacting with OpenAI's GPT-3 model using CRUD operations.
- Python 3.x
- Flask
- OpenAI Python library
- Clone the Repository:
git clone cd
- Set Up a Virtual Environment (Recommended):
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
- Install Required Packages:
pip install -r requirements.txt
- Set Your OpenAI API Key:
- Open
app.py
and replace the placeholder API key with your actual OpenAI API key.
- Run the Flask App:
python app.py
- Create a new prompt:
- Endpoint:
/create_prompt
- Method:
POST
- Body:
{ "prompt": "Your prompt here" }
- Response: The index of the stored prompt.
- Get a response for a prompt by its index:
- Endpoint:
/get_response/<prompt_index>
- Method:
GET
- Response: The GPT-3 model's response.
- Update an existing prompt:
- Endpoint:
/update_prompt/<prompt_index>
- Method:
PUT
- Body:
{ "new_prompt": "Your updated prompt here" }
- Response: A success or error message.