AWS SDK 예제 GitHub 리포지토리에 더 많은 AWS문서 SDK 예제가 있습니다.
AWS SDK와 함께 CreateFlow사용
다음 코드 예시는 CreateFlow의 사용 방법을 보여 줍니다.
작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.
- Python
-
- SDK for Python (Boto3)
-
GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.
Amazon Bedrock 흐름을 생성합니다.
def create_flow(client, flow_name, flow_description, role_arn, flow_def):
"""
Creates an Amazon Bedrock flow.
Args:
client: Amazon Bedrock agent boto3 client.
flow_name (str): The name for the new flow.
role_arn (str): The ARN for the IAM role that use flow uses.
flow_def (json): The JSON definition of the flow that you want to create.
Returns:
dict: The response from CreateFlow.
"""
try:
logger.info("Creating flow: %s.", flow_name)
response = client.create_flow(
name=flow_name,
description=flow_description,
executionRoleArn=role_arn,
definition=flow_def
)
logger.info("Successfully created flow: %s. ID: %s",
flow_name,
{response['id']})
return response
except ClientError as e:
logger.exception("Client error creating flow: %s", {str(e)})
raise
except Exception as e:
logger.exception("Unexepcted error creating flow: %s", {str(e)})
raise