將 GetFlowVersion 與 AWS SDK 搭配使用
以下程式碼範例顯示如何使用 GetFlowVersion。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- Python
-
- 適用於 Python (Boto3) 的 SDK
-
取得 Amazon Bedrock 流程的版本。
def get_flow_version(client, flow_id, flow_version):
"""
Gets information about a version of an Amazon Bedrock flow.
Args:
client: Amazon Bedrock agent boto3 client.
flow_id (str): The identifier of the flow.
flow_version (str): The flow version of the flow.
Returns:
dict: The response from the call to GetFlowVersion.
"""
try:
logger.info("Deleting flow version for flow: %s.", flow_id)
# Call GetFlowVersion operation
response = client.get_flow_version(
flowIdentifier=flow_id,
flowVersion=flow_version
)
logging.info("Successfully got flow version %s information for flow %s.",
flow_version,
flow_id)
return response
except ClientError as e:
logging.exception("Client error getting flow version: %s", str(e))
raise
except Exception as e:
logging.exception("Unexpected error getting flow version: %s", str(e))
raise
如需完整的 AWS SDK 開發人員指南和程式碼範例清單,請參閱 使用 Amazon Bedrock 搭配 AWS SDK。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。