Skip to content

Flask API allowing programmatic usage of ChatGPT 3.5 with custom data

Notifications You must be signed in to change notification settings

ethan-id/GPT-Connector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT Connector

GPT Connector is a Flask API that let's you programmatically use ChatGPT on your own data.

It has been containerized with Docker, and deployed to Google Cloud Run for usage in my other projects, specifically BizGlimpse

Features

  • Place your own data into data/data.txt, for it to be build into the Docker image and the chatbot will constantly be aware of it.
  • Send POST requests to the API with an additional_data member of the body, which the chatbot will be made aware of.

Local Installation

Run these to install the necessary libraries

pip install langchain-community openai chromadb tiktoken unstructured
pip install "unstructured[pdf]"

Create and modify .env to use your own OpenAI API key. E.G. OPENAI_API=myapikey

Docker

docker build -t image-name .
docker run -p 5000:5000 image-name

May have to adjust ports in the command above and the dockerfile to run the API locally

Docker Deployment

docker tag local_tag google-cloud-repo-url/local_tag:latest
docker push google-cloud-repo-url/local_tag:latest

If you are using a Mac running ARM architecture and attempting to deploy the container to a service like Google Cloud Run, you should use this build command instead:

docker build --platform linux/amd64 -t image-name .

Sending Requests to the Flask API:

curl -X POST http://localhost:5000/query -H "Content-Type: application/json" -d '{"question":"How old is my dog?", "chat_history": [], "additional_data", "My dog is 12 years old."}'

Credits

Inspiration and some of the original Source Code is from this YouTube Video and this github repo.

About

Flask API allowing programmatic usage of ChatGPT 3.5 with custom data

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 78.2%
  • Dockerfile 21.8%