CreateAgentActionGroup与 AWS SDK 或 CLI 配合使用 - Amazon Bedrock

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

CreateAgentActionGroup与 AWS SDK 或 CLI 配合使用

以下代码示例演示了如何使用 CreateAgentActionGroup

操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:

Python
SDK for Python (Boto3)
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

创建代理操作组。

def create_agent_action_group( self, name, description, agent_id, agent_version, function_arn, api_schema ): """ Creates an action group for an agent. An action group defines a set of actions that an agent should carry out for the customer. :param name: The name to give the action group. :param description: The description of the action group. :param agent_id: The unique identifier of the agent for which to create the action group. :param agent_version: The version of the agent for which to create the action group. :param function_arn: The ARN of the Lambda function containing the business logic that is carried out upon invoking the action. :param api_schema: Contains the OpenAPI schema for the action group. :return: Details about the action group that was created. """ try: response = self.client.create_agent_action_group( actionGroupName=name, description=description, agentId=agent_id, agentVersion=agent_version, actionGroupExecutor={"lambda": function_arn}, apiSchema={"payload": api_schema}, ) agent_action_group = response["agentActionGroup"] except ClientError as e: logger.error(f"Error: Couldn't create agent action group. Here's why: {e}") raise else: return agent_action_group
  • 有关 API 的详细信息,请参阅适用CreateAgentActionGroupPython 的AWS SDK (Boto3) API 参考

有关 S AWS DK 开发者指南和代码示例的完整列表,请参阅将此服务与 AWS SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。