Skip to content

k-hui/chatgpt-aws-lambda

Repository files navigation

ChatGPT with AWS Lambda

Getting Started

Create a new virtual environment

python -m venv venv
soruce venv/bin/activate

Install the requirements

pip install -r requirements.txt

Make a copy of the example environment variables file

cp .env.example .env

Add your API key to the newly created .env file

Run the app

uvicorn main:app --reload

FastAPI Installation

pip install fastapi
pip install "uvicorn[standard]"
pip install mangum

sls plugin install -n serverless-python-requirements

Run the api server

# without serverless  offline
uvicorn main:app --reload
# with serverless offline
sls offline --noPrependStageInUrl

Test

sh test.sh

# example 1
curl -d '{"prompt":"Hello, how are you today?"}' \
  -H "Content-Type: application/json" \
  -X POST http://localhost:3000

# example 2
curl -d '{"prompt":"Hello, how are you today?","model":"text-davinci-002","temperature":0.5}' \
  -H "Content-Type: application/json" \
  -X POST http://localhost:3000

About

ChatGPT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors