前提条件
以下示例需要boto3 库。
示例
下面的代理将使用 AWS Lambda 列出我们 AWS 账户中的所有 Lambda 函数,并调用一个特定的 Lambda 函数。cookbook/tools/aws_lambda_tools.py
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
boto3 库。
pip install openai boto3
from agno.agent import Agent
from agno.tools.aws_lambda import AWSLambdaTools
# 创建一个包含 AWSLambdaTool 的 Agent
agent = Agent(
tools=[AWSLambdaTools(region_name="us-east-1")],
name="AWS Lambda Agent",
show_tool_calls=True,
)
# 示例 1:列出所有 Lambda 函数
agent.print_response("List all Lambda functions in our AWS account", markdown=True)
# 示例 2:调用一个特定的 Lambda 函数
agent.print_response("Invoke the 'hello-world' Lambda function with an empty payload", markdown=True)
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
region_name | str | "us-east-1" | Lambda 函数所在的 AWS 区域名称。 |
| 函数 | 描述 |
|---|---|
list_functions | 列出 AWS 账户中所有可用的 Lambda 函数。 |
invoke_function | 使用可选的 payload 调用一个特定的 Lambda 函数。接受 function_name 和可选的 payload 参数。 |