Skip to content

Commit 8a81eb2

Browse files
authored
chore(bedrock): update code snippet in readme (#453)
1 parent cac5724 commit 8a81eb2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/cdk-lib/bedrock/README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,15 @@ const actionGroupFunction = new lambda_python.PythonFunction(this, 'ActionGroupF
355355
entry: path.join(__dirname, '../lambda/action-group'),
356356
});
357357

358-
agent.addActionGroup({
358+
const actionGroup = new bedrock.AgentActionGroup(this,'MyActionGroup',{
359359
actionGroupName: 'query-library',
360360
description: 'Use these functions to get information about the books in the library.',
361361
actionGroupExecutor: actionGroupFunction,
362362
actionGroupState: "ENABLED",
363363
apiSchema: bedrock.ApiSchema.fromAsset(path.join(__dirname, 'action-group.yaml')),
364364
});
365+
366+
agent.addActionGroup(actionGroup);
365367
```
366368

367369
Python
@@ -375,21 +377,23 @@ action_group_function = PythonFunction(
375377
entry="./lambda",
376378
index="app.py",
377379
handler="lambda_handler",
378-
)
380+
)
379381

380-
agent.add_action_group(
381-
action_group_name="query-library",
382-
description="Use these functions to get information about the books in the library.",
383-
action_group_executor=action_group_function,
384-
action_group_state="ENABLED",
385-
api_schema=bedrock.ApiSchema.from_asset("action-group.yaml"),
386-
)
382+
actionGroup = bedrock.AgentActionGroup(self,
383+
"MyActionGroup",
384+
action_group_name="query-library",
385+
description="Use these functions to get information about the books in the library.",
386+
action_group_executor=action_group_function,
387+
action_group_state="ENABLED",
388+
api_schema=bedrock.ApiSchema.from_asset("action-group.yaml"))
389+
390+
agent.add_action_group(actionGroup)
387391
```
388392

389393
### Prepare the Agent
390-
The `Agent` constructs take an optional parameter `autoPrepare` to indicate that the Agent should be prepared after any updates to an agent, Knowledge Base association, or action group. This may increase the time to create and update those resources. By default, this value is false .
394+
The `Agent` constructs take an optional parameter `shouldPrepareAgent` to indicate that the Agent should be prepared after any updates to an agent, Knowledge Base association, or action group. This may increase the time to create and update those resources. By default, this value is false .
391395

392-
Creating an agent alias will also prepare the agent, so if you create an alias with `addAlias` or by providing an `aliasName` when creating the agent then you should not set `autoPrepare` to ***true*** on other resources.
396+
Creating an agent alias will not prepare the agent, so if you create an alias with `addAlias` or by providing an `aliasName` when creating the agent then you should set `shouldPrepareAgent` to ***true***.
393397

394398
#### Prompt Overrides
395399
Bedrock Agents allows you to customize the prompts and LLM configuration for its different steps. You can disable steps or create a new prompt template. Prompt templates can be inserted from plain text files.
@@ -491,9 +495,9 @@ TypeScript
491495
const agent = new bedrock.Agent(this, 'Agent', {
492496
foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1,
493497
instruction: 'You are a helpful and friendly agent that answers questions about literature.',
498+
knowledgeBases: [kb],
494499
aliasName: 'latest',
495500
});
496-
agent.addKnowledgeBase([kb]);
497501
```
498502

499503
Python

0 commit comments

Comments
 (0)