Skip to content

Amazon Bedrock playlist flow #7358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
24f40b5
work on python hello bedrock example
AWSChris Jan 24, 2025
65ae500
fixed metadata
AWSChris Jan 24, 2025
11462df
removed AWS reference
AWSChris Jan 24, 2025
81e943e
reformatted string
AWSChris Jan 24, 2025
7bbb1a7
updated readme
AWSChris Jan 24, 2025
f93e0b0
updated readme
AWSChris Jan 24, 2025
2ba04d9
updated readme
AWSChris Jan 24, 2025
9fb3e7d
updated readme
AWSChris Jan 24, 2025
7944fe8
ran writeme script to update bedrock readme
AWSChris Jan 25, 2025
17f5a18
removed region declaration
AWSChris Jan 27, 2025
f0098bb
Merge branch 'awsdocs:main' into main
AWSChris Jan 28, 2025
6e564f8
Merge branch 'awsdocs:main' into main
AWSChris Jan 30, 2025
65c627c
Merge branch 'awsdocs:main' into main
AWSChris Jan 31, 2025
d90d701
Merge branch 'awsdocs:main' into main
AWSChris Feb 12, 2025
05cfaac
Merge branch 'awsdocs:main' into main
AWSChris Feb 13, 2025
8c5e8a9
Merge branch 'awsdocs:main' into main
AWSChris Feb 22, 2025
dd1f4d9
Merge branch 'awsdocs:main' into main
AWSChris Mar 3, 2025
a5ca8b2
Merge branch 'awsdocs:main' into main
AWSChris Mar 21, 2025
2ce3337
Merge branch 'awsdocs:main' into main
AWSChris Mar 26, 2025
048a4c4
added flow example files
Apr 2, 2025
fd6b163
flows examples
Apr 3, 2025
e75243e
work on clean up
Apr 4, 2025
7ace2b8
simplified clean up
Apr 4, 2025
60c338c
various clean up
AWSChris Apr 7, 2025
beecdf2
Merge branch 'main' into playlist-flow
AWSChris Apr 7, 2025
e347884
Update python/example_code/bedrock-agent/README.md
AWSChris Apr 15, 2025
5670430
Update python/example_code/bedrock-agent/flows/flow-conversation.py
AWSChris Apr 15, 2025
5486d4f
Update python/example_code/bedrock-agent/test/test_playlist_flow.py
AWSChris Apr 15, 2025
b8b8850
Merge branch 'main' into playlist-flow
AWSChris Apr 15, 2025
d3d8a85
work on list flows calling code
AWSChris Apr 15, 2025
51f23de
list flows example
AWSChris Apr 15, 2025
6e2c843
updated readme for list flows example
AWSChris Apr 15, 2025
374c464
fixed broken snippet name
AWSChris Apr 17, 2025
f7acedc
Merge branch 'main' into playlist-flow
rlhagerm Apr 18, 2025
bb3d18b
Metadata fixes.
rlhagerm Apr 18, 2025
12ecb00
Merge branch 'playlist-flow' of https://github.com/AWSChris/aws-doc-s…
rlhagerm Apr 18, 2025
c945f6a
Yaml updates.
rlhagerm Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
work on clean up
  • Loading branch information
Christopher Rees authored and Christopher Rees committed Apr 4, 2025
commit e75243ec74a1aee4cf3e918d96d991735f6f995a
39 changes: 32 additions & 7 deletions python/example_code/bedrock-agent/flows/playlist_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,16 @@ def delete_role_resources(bedrock_agent_client,
flow_alias (str): The alias of the flow.
"""

delete_flow_alias(bedrock_agent_client, flow_id, flow_alias)
delete_flow_version(bedrock_agent_client,
if flow_id is not None:
if flow_alias is not None:
delete_flow_alias(bedrock_agent_client, flow_id, flow_alias)
if flow_version is not None:
delete_flow_version(bedrock_agent_client,
flow_id, flow_version)
delete_flow(bedrock_agent_client, flow_id)
delete_flow_role(iam_client, role_name)
delete_flow(bedrock_agent_client, flow_id)

if role_name is not None:
delete_flow_role(iam_client, role_name)

# snippet-end:[python.example_code.bedrock-agent-runtime.flow_delete_resources]

Expand All @@ -351,6 +356,11 @@ def main():
bedrock_agent_client = session.client('bedrock-agent')
bedrock_client = session.client('bedrock')
iam_client = session.client('iam')

role_name = None
flow_id = None
flow_version = None
flow_alias = None

prompt_model_id = "amazon.nova-pro-v1:0"

Expand All @@ -367,7 +377,7 @@ def main():

# Create the flow.
response = create_playlist_flow(
bedrock_agent_client, flow_name, flow_description, role_arn, prompt_model_id)
bedrock_agent_client, flow_name, flow_description, "role_arn", prompt_model_id)
flow_id = response.get('id')

if flow_id:
Expand Down Expand Up @@ -406,12 +416,27 @@ def main():
delete_flow(bedrock_agent_client, flow_id)
delete_flow_role(iam_client, role_name)
else:
print("Couldn't create flow. Deleting role.")
delete_flow_role(iam_client, role_name)
print("Couldn't create flow. Deleting resources")
#delete_flow_role(iam_client, role_name)
delete_role_resources(bedrock_agent_client,
iam_client,
role_name,
flow_id,
flow_version,
flow_alias)
print("Done")

except Exception as e:
print(f"Fatal error: {str(e)}")

finally:
delete_role_resources(bedrock_agent_client,
iam_client,
role_name,
flow_id,
flow_version,
flow_alias)



if __name__ == "__main__":
Expand Down