- A basic serverless API for interacting with the Phidata Agent using AWS Bedrock
- The conversation gets stored in a DynamoDB table
- AWS Bedrock as the LLM Provider
- AWS Lambda to run the Phidata Agent
- AWS API Gateway to expose the API
- AWS Account
- AWS Bedrock
- You will need to request access to AWS Bedrock, if you haven't already.
- Specifically request access for Claude 3.5 Sonnet.
- Install NodeJS 18+
- Install Python 3.10+
- Install AWS CLI
- Authenticate AWS CLI
- Install CDK CLI
- Change directory to phidata-agent-serverless-api-bedrock
cd phidata-agent-serverless-api-bedrock
- 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
PhidataBedrockAgentServerlessApiStack.HttpAPIUrl = https://1djpu9.execute-api.us-east-1.amazonaws.com/
- Change directory to phidata-agent-serverless-api-bedrock/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