Skip to content

usman19953/open-ai-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Flask API

A simple Flask API for interacting with OpenAI's GPT-3 model using CRUD operations.

Prerequisites

  • Python 3.x
  • Flask
  • OpenAI Python library

Getting Started

  1. Clone the Repository:

git clone cd

  1. Set Up a Virtual Environment (Recommended):

python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate

  1. Install Required Packages:

pip install -r requirements.txt

  1. Set Your OpenAI API Key:
  • Open app.py and replace the placeholder API key with your actual OpenAI API key.
  1. Run the Flask App:

python app.py

API Endpoints

  1. Create a new prompt:
  • Endpoint: /create_prompt
  • Method: POST
  • Body:
    {
      "prompt": "Your prompt here"
    }
  • Response: The index of the stored prompt.
  1. Get a response for a prompt by its index:
  • Endpoint: /get_response/<prompt_index>
  • Method: GET
  • Response: The GPT-3 model's response.
  1. Update an existing prompt:
  • Endpoint: /update_prompt/<prompt_index>
  • Method: PUT
  • Body:
    {
      "new_prompt": "Your updated prompt here"
    }
  • Response: A success or error message.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages