Skip to main content

FastAPI Middleware for Agents for Amazon Bedrock. Use with AWS Lambda Web Adapter.

Project description

FastAPI Middleware for "Agents for Amazon Bedrock"

This is FastAPI Middleware for "Agents for Amazon Bedrock". Use with AWS Lambda Web Adapter.

Agents for Amazon Bedrock requires:

  • Lambda function that defines the business logic for the action that your agent will carry out.
  • OpenAPI schema with the API description, structure, and parameters for the action group.

By using this middleware, you can create Lambda as a FastAPI. OpenAPI schemas can also be easily generated.

How to install

pip install lwa-fastapi-middleware-bedrock-agent

How to use

from bedrock_agent.middleware import BedrockAgentMiddleware
from fastapi import FastAPI

app = FastAPI(
    description="This agent allows you to query the information.",
)
app.add_middleware(BedrockAgentMiddleware)

If you specified AWS_LWA_PASS_THROUGH_PATH, add the pass_through_path parameter. (Default is "/events")

app.add_middleware(BedrockAgentMiddleware, pass_through_path="/pass_through_path")

Example

Examples are located in the example directory

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page