- A basic serverless API for interacting with the Phidata Agent
- The conversation gets stored in a DynamoDB table
- AWS Secrets Manager to store the OpenAI API Key
- AWS Lambda to run the Phidata Agent
- AWS API Gateway to expose the API
- AWS Account
- Install NodeJS 18+
- Install Python 3.10+
- Install AWS CLI
- Authenticate AWS CLI
- OpenAI API Key
- Install CDK CLI
- Change directory to phidata-agent-serverless-api-basic
cd phidata-agent-serverless-api-basic
- Add .env file from .env-template and add your OpenAI API Key
cp .env-template .env
- Install dependencies
npm install
- Bootstrap the stack
cdk bootstrap
- Deploy the stack
cdk deploy
Once you've completed testing, you can remove the deployed resources by destroying the stack
cdk destroy
- Get the API URL from the output of the cdk deploy command
PhidataAgentServerlessApiBasicStack.HttpAPIUrl = https://1djpu9.execute-api.us-east-1.amazonaws.com/
- Change directory to phidata-agent-serverless-api-basic/test
cd test
- Create a test/.env file from test/.env-template
cp .env-template .env
- Paste the URL into the test/.env file
AWS_API_GATEWAY_URL=https://1djpu9.execute-api.us-east-1.amazonaws.com
- Create a virtual environment and install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Run the test
python test.py
The cdk.json
file tells the CDK Toolkit how to execute your app.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testsnpx cdk deploy
deploy this stack to your default AWS account/regionnpx cdk diff
compare deployed stack with current statenpx cdk synth
emits the synthesized CloudFormation template