This is beta software that generates un-auth'd API gateway endpoints which use OpenAI APIs. Do not share those endpoints with anyone. For now, I encourage you to destroy the infra after use. Command below.
TODO: add auth
TODO: add github action(s)
TODO: add message queue + trigger
- AWS Account
- AWS CLI - Installation Guide
- Node.js (version 14 or higher) - Installation Guide
- Python (version 3.9 or higher) - Installation Guide
- AWS CDK - Install the AWS CDK by
running
npm install -g aws-cdk
- OpenAI API Key - detailed instructions at the bottom of README
$ git clone https://github.com/pkarl/lambda-openai-bootstrap.git`
$ cd lambda-openai-bootstrap
python -m venv .venv
source .venv/bin/activate # For Linux/macOS
Windows:
.venv\Scripts\activate
pip install -r requirements.txt
cd layer
pip install -r requirements.txt -t python
cd ..
aws configure
# Follow the prompts to input your ...
# AWS Access Key ID,
# AWS Secret Access Key,
# Default region name,
# and Default output format
In the /lambda
directory, modify the lambda_function_chat.py
or add
additional lambda_function_[custom name here].py
files to use the
desired OpenAI APIs. Update the lambda_openai_bootstrap/lambda_openai_bootstrap_stack.py
file accordingly (search
for PUT ADDITIONAL LAMBDA FUNCTIONS HERE
...).
export OPENAPI_KEY=AA-0000000000000000000000000000000000000000000
This will run cdk commands to simulate a build and generate cloudformation templates (and will reveal nasty bugs along the way).
python app.py
cdk bootstrap
cdk deploy
After the deployment is complete, you will see the API Gateway URL(s) in the terminal output. Use these URLs to make HTTP requests and test the Lambda functions.
ex:
$ http post https://000000000A.execute-api.us-east-1.amazonaws.com/prod/ prompt="what's a good compliment for an ugly person?" -v
👆 uses httpie (https://httpie.io/)
When you no longer need the resources, run the following command to delete them:
cdk destroy
idk, file an issue or leave a comment to get this party started.
Follow these steps to obtain your OpenAI API keys:
-
Sign up for an OpenAI account:
If you don't already have an account, sign up for an OpenAI account by visiting the OpenAI website and clicking on the "Sign up" button.
-
Log in to your OpenAI account:
Log in to your OpenAI account by visiting the OpenAI website and clicking on the "Log in" button.
-
Navigate to the API keys page:
Once logged in, click on your profile icon in the top right corner and select "API keys" from the dropdown menu.
-
Generate a new API key:
On the API keys page, click on the "Create" button to generate a new API key. A unique key will be generated, and you can provide a description (optional) to help you remember its purpose.
Note: Keep your API key secret and never share it publicly. It's essential to treat your API keys like passwords, as they grant access to