GithubHelp home page GithubHelp logo

aiamond_gptbackend's Introduction

AIamond GPT Backend

This is a Serverless application that uses AWS Lambda and the OpenAI GPT model. The main purpose is to provide a FLASK API BACKEND to be used in a private app / webui to talk to OpenAIs GPT4Turbo model.

Prerequisites

You will need an OpenAI Account with payments to use the GPT4. You could use the free version, but you have to change the environment vars to both use GPT3.

  • Node.js and npm
  • Python 3.11
  • Serverless Framework
  • AWS CLI
  • Git

Installation

Three environment vars are needed:

OPENAI_API_KEY=.....
GPT3_MODEL=gpt-3.5-turbo
GPT4_MODEL=gpt-4-turbo
git clone https://github.com/Kipperlenny/aiamond_gptbackend.git
cd aiamond_gptbackend
npm install -g serverless
pip install -r requirements.txt
npx dotenv -e .env -- serverless deploy

Usage

After deploying, you can call your API Gateway endpoint with a POST request to interact with the GPT model. You need to authenticate with the AWS IAM User created during serverless deployment (get the access data from aws console!).

This Flask application provides the following endpoints:

Start Conversation

Endpoint: /start_conversation

Method: POST

Data Params: title (optional)

Success Response: {"conversation_id": "<conversation_id>"} with HTTP status 201

Description: Starts a new conversation and returns its ID.

Add to Conversation

Endpoint: /add_to_conversation

Method: POST

Data Params: conversation_id (optional), question

Success Response: {"response": "", "conversation_id": "<conversation_id>"} with HTTP status 200

Description: Adds a question to a conversation and returns the assistant's response.

List Conversations

Endpoint: /list_conversations

Method: GET

Success Response: A list of conversations with their IDs and titles, with HTTP status 200

Description: Returns a list of all conversations.

Get Conversation

Endpoint: /get_conversation/<conv_id>

Method: GET

URL Params: conv_id

Success Response: The conversation history, with HTTP status 200

Error Response: {"error": "Conversation not found"} with HTTP status 404

Description: Returns the history of a conversation.

Delete Conversation

Endpoint: /delete_conversation/<conv_id>

Method: DELETE

URL Params: conv_id

Success Response: {"message": "Conversation deleted"} with HTTP status 200

Error Response: {"error": "Conversation not found"} with HTTP status 404

Description: Deletes a conversation.

Please note that all data sent and received is in JSON format.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GPL 3.0

aiamond_gptbackend's People

Contributors

kipperlenny avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.