本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
CreateAgentActionGroup
搭配 AWS SDK 使用
下列程式碼範例示範如何使用 CreateAgentActionGroup
。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- Python
-
- SDK for Python (Boto3)
-
建立客服人員動作群組。
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
如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱 搭配 AWS SDK 使用 Amazon Bedrock。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。