Prerequisites

The following example requires the boto3 library.

pip install openai boto3

Example

The following agent will use AWS Lambda to list all Lambda functions in our AWS account and invoke a specific Lambda function.

cookbook/tools/aws_lambda_tools.py

from phi.agent import Agent
from phi.tools.aws_lambda import AWSLambdaTool


# Create an Agent with the AWSLambdaTool
agent = Agent(
    tools=[AWSLambdaTool(region_name="us-east-1")],
    name="AWS Lambda Agent",
    show_tool_calls=True,
)

# Example 1: List all Lambda functions
agent.print_response("List all Lambda functions in our AWS account", markdown=True)

# Example 2: Invoke a specific Lambda function
agent.print_response("Invoke the 'hello-world' Lambda function with an empty payload", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
region_namestr"us-east-1"AWS region name where Lambda functions are located.

Toolkit Functions

FunctionDescription
list_functionsLists all Lambda functions available in the AWS account.
invoke_functionInvokes a specific Lambda function with an optional payload. Takes function_name and optional payload parameters.

Information