This is a sample project, based on https://github.com/vsenger/quarkus-bedrock, that demonstrates how to access Amazon Bedrock from a Quarkus application deployed on AWS Lambda.
To deploy this demo you need:
- Access to an AWS account
- Apache Maven
- Quarkus
- The AWS SAM CLI
To build the application, execute the following command in the quarkus-bedrock-demo
directory:
quarkus build
To deploy the application, execute the following command in the quarkus-bedrock-demo
directory:
sam deploy --guided
Note: You can accept all default settings, except the following two:
- AWS Region must be set a region that supports Bedrock, e.g. us-east-1.
- QuarkusBedrock has no authentication. Is this okay? must be answered with
[Y]
.
Setting default arguments for 'sam deploy'
=========================================
...
AWS Region []: us-east-1
...
QuarkusBedrock has no authentication. Is this okay? [y/N]: Y
...
After successful deployment, you will see the generated output:
CloudFormation outputs from deployed stack
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Outputs
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key QuarkusBedrock
Description URL for application
Value https://URL_PREFIX.execute-api.us-east-1.amazonaws.com/
----------------------------------------------------------------------------
Successfully created/updated stack - quarkus-bedrock-demo in us-east-1
Note: Replace URL_PREFIX.execute-api.us-east-1.amazonaws.com
with the actual URL that has been returned during the deployment.
To send a prompt to the currently active model, use the following endpoint:
https://URL_PREFIX.execute-api.us-east-1.amazonaws.com/bedrock/prompt?p=YOUR_PROMPT
Example:
https://URL_PREFIX.execute-api.us-east-1.amazonaws.com/bedrock/prompt?p=Hello, how are you?
To check which model is currently active, use the following endpoint:
https://URL_PREFIX.execute-api.us-east-1.amazonaws.com/bedrock/llm
To change the active model, use the following endpoint:
https://URL_PREFIX.execute-api.us-east-1.amazonaws.com/bedrock/llm/set?model=NEW_MODEL
Example:
https://URL_PREFIX.execute-api.us-east-1.amazonaws.com/bedrock/llm/set?model=anthropic.claude-instant-v1
The following models are currently available as part of this app:
anthropic.claude-v1
anthropic.claude-instant-v1
anthropic.claude-v2
To delete the SAM application, navigate to the quarkus-bedrock
directory, execute the following command, and answer "y" to all prompts:
sam delete