Skip to content

Commit ff05605

Browse files
committed
Update bedrock-agent writeme using writeme.py and manually moving paragraphs in incorrect segments to correct custom blocks. Some information was lost, for list flows, which does not have a current scenario in metadata.
1 parent 6b87901 commit ff05605

File tree

1 file changed

+70
-72
lines changed

1 file changed

+70
-72
lines changed

python/example_code/bedrock-agent/README.md

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22

33
## Overview
44

5-
Shows how to use the AWS SDK for Python (Boto3) to work with Amazon Bedrock agents, flows, and managed prompts.
5+
Shows how to use the AWS SDK for Python (Boto3) to work with Amazon Bedrock Agents.
66

77
<!--custom.overview.start-->
88
<!--custom.overview.end-->
99

1010
_Amazon Bedrock Agents offer you the ability to build and configure autonomous agents in your application._
1111

12-
13-
1412
## ⚠ Important
1513

16-
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
17-
* Running the tests might result in charges to your AWS account.
18-
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
19-
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
14+
- Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
15+
- Running the tests might result in charges to your AWS account.
16+
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
17+
- This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
2018

2119
<!--custom.important.start-->
2220
<!--custom.important.end-->
@@ -43,47 +41,46 @@ Code excerpts that show you how to call individual service functions.
4341
- [CreateAgent](bedrock_agent_wrapper.py#L32)
4442
- [CreateAgentActionGroup](bedrock_agent_wrapper.py#L61)
4543
- [CreateAgentAlias](bedrock_agent_wrapper.py#L96)
44+
- [CreateFlow](flows/flow.py#L18)
45+
- [CreateFlowAlias](flows/flow_alias.py#L15)
46+
- [CreateFlowVersion](flows/flow_version.py#L18)
47+
- [CreateKnowledgeBase](knowledge_bases/knowledge_base.py#L29)
48+
- [CreatePrompt](prompts/prompt.py#L18)
49+
- [CreatePromptVersion](prompts/prompt.py#L84)
4650
- [DeleteAgent](bedrock_agent_wrapper.py#L118)
4751
- [DeleteAgentAlias](bedrock_agent_wrapper.py#L139)
52+
- [DeleteFlow](flows/flow.py#L155)
53+
- [DeleteFlowAlias](flows/flow_alias.py#L98)
54+
- [DeleteFlowVersion](flows/flow_version.py#L91)
55+
- [DeleteKnowledgeBase](knowledge_bases/knowledge_base.py#L165)
56+
- [DeletePrompt](prompts/prompt.py#L159)
4857
- [GetAgent](bedrock_agent_wrapper.py#L161)
58+
- [GetFlow](flows/flow.py#L192)
59+
- [GetFlowVersion](flows/flow_version.py#L54)
60+
- [GetKnowledgeBase](knowledge_bases/knowledge_base.py#L86)
61+
- [GetPrompt](prompts/prompt.py#L124)
4962
- [ListAgentActionGroups](bedrock_agent_wrapper.py#L208)
5063
- [ListAgentKnowledgeBases](bedrock_agent_wrapper.py#L237)
5164
- [ListAgents](bedrock_agent_wrapper.py#L185)
65+
- [ListFlowAliases](flows/flow_alias.py#L132)
66+
- [ListFlowVersions](flows/flow_version.py#L128)
67+
- [ListFlows](flows/flow.py#L229)
68+
- [ListKnowledgeBases](knowledge_bases/knowledge_base.py#L195)
69+
- [ListPrompts](prompts/prompt.py#L191)
5270
- [PrepareAgent](bedrock_agent_wrapper.py#L266)
53-
- [InvokeFlow](flows/run_flow.py#L23)
54-
- [CreateFlow](flows/flow.py#L18)
55-
- [PrepareFlow](flows/flow.py#L58)
71+
- [PrepareFlow](flows/flow.py#L58)
5672
- [UpdateFlow](flows/flow.py#L112)
57-
- [DeleteFlow](flows/flow.py#L156)
58-
- [GetFlow](flows/flow.py#L192)
59-
- [ListFlows](flows/flow.py#L229)
60-
- [CreateFlowVersion](flows/flow_version.py#L18)
61-
- [GetFlowVersion](flows/flow_version.py#L54)
62-
- [DeleteFlowVersion](flows/flow_version.py#L91)
63-
- [ListFlowVersions](flows/flow_version.py#L128)
64-
- [CreateFlowAlias](flows/flow_alias.py#L15)
65-
- [UpdateFlowAlias](flows/flow_alias.py#L55)
66-
- [DeleteFlowAlias](flows/flow_alias.py#L98)
67-
- [ListFlowAliases](flows/flow_alias.py#L132)
68-
- [FlowConversation](flows/flow-conversation.py)
69-
- [CreatePrompt](prompts/prompt.py#L32)
70-
- [CreatePromptVersion](prompts/prompt.py#L61)
71-
- [GetPrompt](prompts/prompt.py#L71)
72-
- [DeletePrompt](prompts/prompt.py#L154)
73-
- [ListPrompts](prompts/prompt.py#L187)
74-
75-
76-
73+
- [UpdateFlowAlias](flows/flow_alias.py#L55)
74+
- [UpdateKnowledgeBase](knowledge_bases/knowledge_base.py#L116)
7775

7876
### Scenarios
7977

8078
Code examples that show you how to accomplish a specific task by calling multiple
8179
functions within the same service.
8280

83-
- [Create and invoke an agent](scenario_get_started_with_agents.py)
8481
- [Create and invoke a flow](flows/playlist_flow.py)
8582
- [Create and invoke a managed prompt](prompts/scenario_get_started_with_prompts.py)
86-
83+
- [Create and invoke an agent](scenario_get_started_with_agents.py)
8784

8885
<!--custom.examples.start-->
8986
<!--custom.examples.end-->
@@ -92,69 +89,60 @@ functions within the same service.
9289

9390
### Instructions
9491

95-
9692
<!--custom.instructions.start-->
9793
<!--custom.instructions.end-->
9894

99-
100-
101-
#### Create and invoke an agent
95+
#### Create and invoke a flow
10296

10397
This example shows you how to do the following:
10498

105-
- Create an execution role for the agent.
106-
- Create the agent and deploy a DRAFT version.
107-
- Create a Lambda function that implements the agent's capabilities.
108-
- Create an action group that connects the agent to the Lambda function.
109-
- Deploy the fully configured agent.
110-
- Invoke the agent with user-provided prompts.
99+
- Create an execution role for the flow.
100+
- Create the flow.
101+
- Deploy the fully configured flow.
102+
- Invoke the flow with user-provided prompts.
111103
- Delete all created resources.
112104

113-
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockAgents.start-->
114-
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockAgents.end-->
115-
116-
Start the example by running the following at a command prompt:
117-
118-
```
119-
python scenario_get_started_with_agents.py
120-
```
121-
122-
123-
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockAgents.start-->
124-
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockAgents.end-->
105+
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockFlows.start-->
125106

126-
127-
#### Create and invoke a flow
128-
129-
Shows how to create a simple flow that generates music playlists.
130107
The flow includes a prompt node that generates a playlist for a chosen genre
131108
and number of songs. The example creates the nodes and permissions
132109
for the flow.
133110

111+
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockFlows.end-->
112+
134113
Start the example by running the following at a command prompt:
135114

136115
```
137116
python flows/playlist_flow.py
138117
```
118+
119+
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockFlows.start-->
120+
139121
When prompted, enter the genre of music and the number of songs you want
140122
in the playlist.
141123
Optionally, the script can delete the resources that it creates. If you want to use the flow later, such as in the Amazon Bedrock console, enter `n` when the script prompts you to delete resources. Note that you will then need to manually delete the resources.
142124

125+
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockFlows.end-->
126+
127+
#### Create and invoke a managed prompt
143128

129+
This example shows you how to do the following:
144130

145-
#### List flows
131+
- Create a managed prompt.
132+
- Create a version of the prompt.
133+
- Invoke the prompt using the version.
134+
- Clean up resources (optional).
146135

147-
Shows how to List Amazon Bedrock flows, versions of a flow, and aliases of a flow.
136+
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockPrompts.start-->
137+
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockPrompts.end-->
148138

149139
Start the example by running the following at a command prompt:
150140

151141
```
152-
python flows/list_flows.py
142+
python prompts/scenario_get_started_with_prompts.py
153143
```
154-
The example first lists the flows in the current AWS Region. It
155-
then prompts for a flow ID, which you can get from the list of flows. Finally, the example lists the flow versions and flow aliases for the flow ID that you entered.
156144

157-
#### Create and invoke a managed prompt
145+
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockPrompts.start-->
158146

159147
This example shows you how to do the following:
160148

@@ -184,29 +172,39 @@ You can also specify a different AWS region or model ID:
184172
python prompts/scenario_get_started_with_prompts.py --region us-west-2 --model-id anthropic.claude-3-sonnet-20240229-v1:0
185173
```
186174

187-
#### List prompts
175+
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockPrompts.end-->
176+
177+
#### Create and invoke an agent
178+
179+
This example shows you how to do the following:
180+
181+
- Create an execution role for the agent.
182+
- Create the agent and deploy a DRAFT version.
183+
- Create a Lambda function that implements the agent's capabilities.
184+
- Create an action group that connects the agent to the Lambda function.
185+
- Deploy the fully configured agent.
186+
- Invoke the agent with user-provided prompts.
187+
- Delete all created resources.
188188

189-
Shows how to list Amazon Bedrock managed prompts and versions of a prompt.
189+
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockAgents.start-->
190+
<!--custom.scenario_prereqs.bedrock-agent_GettingStartedWithBedrockAgents.end-->
190191

191192
Start the example by running the following at a command prompt:
192193

193194
```
194-
python prompts/list_prompts.py
195+
python scenario_get_started_with_agents.py
195196
```
196197

197-
The example first lists the prompts in the current AWS Region.
198-
198+
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockAgents.start-->
199+
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockAgents.end-->
199200

200201
### Tests
201202

202203
⚠ Running tests might result in charges to your AWS account.
203204

204-
205205
To find instructions for running these tests, see the [README](../../README.md#Tests)
206206
in the `python` folder.
207207

208-
209-
210208
<!--custom.tests.start-->
211209
<!--custom.tests.end-->
212210

0 commit comments

Comments
 (0)