本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
先决条件
在使用 AgentCore 优化功能之前,请确保满足以下条件。
要求和支持的框架
推荐和 A/B 测试的代理要求与 AgentCore 评估相同:
-
在 AgentCore Runtime 上部署且启用了可观测性的代理,或者使用配置了可AgentCore 观测性的受支持框架构建的代理。有关支持的框架和工具库的更多信息,请参阅支持的代理框架。
-
中启用了交易搜索 CloudWatch。
-
CloudWatch 日志中包含遥测数据的代理会话。调用您的代理并等待 2-5 分钟 CloudWatch 以接收遥测数据,然后开始推荐或测试。 A/B
软件开发工具包和 CLI 要求
-
AgentCore CLI:通过运行安装最新版本
agentcore update。 -
AWS SDK (boto3):Python 3.10 或更高版本。使用安装或升级
pip install --upgrade boto3。 -
AgentCore SDK:如果使用
bedrock-agentcore-sdk-python,则需要 1.8 或更高版本。
IAM 权限
以下 IAM 策略授予所有三种优化功能的权限:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "ConfigurationBundles", "Effect": "Allow", "Action": [ "bedrock-agentcore:CreateConfigurationBundle", "bedrock-agentcore:GetConfigurationBundle", "bedrock-agentcore:GetConfigurationBundleVersion", "bedrock-agentcore:ListConfigurationBundles", "bedrock-agentcore:ListConfigurationBundleVersions", "bedrock-agentcore:UpdateConfigurationBundle", "bedrock-agentcore:DeleteConfigurationBundle" ], "Resource": "arn:aws:bedrock-agentcore:*:*:configuration-bundle/*" }, { "Sid": "Recommendations", "Effect": "Allow", "Action": [ "bedrock-agentcore:StartRecommendation", "bedrock-agentcore:GetRecommendation", "bedrock-agentcore:ListRecommendations", "bedrock-agentcore:DeleteRecommendation" ], "Resource": "arn:aws:bedrock-agentcore:*:*:recommendation/*" }, { "Sid": "ABTesting", "Effect": "Allow", "Action": [ "bedrock-agentcore:CreateABTest", "bedrock-agentcore:GetABTest", "bedrock-agentcore:ListABTests", "bedrock-agentcore:UpdateABTest", "bedrock-agentcore:DeleteABTest" ], "Resource": "arn:aws:bedrock-agentcore:*:*:ab-test/*" }, { "Sid": "CloudWatchLogs", "Effect": "Allow", "Action": [ "logs:GetLogEvents", "logs:FilterLogEvents", "logs:StartQuery", "logs:GetQueryResults" ], "Resource": "arn:aws:logs:*:*:log-group:/aws/bedrock-agentcore/runtimes/*" } ] }