Skip to content

Commit

Permalink
chore(bedrock): update code snippet in readme (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
krokoko authored May 16, 2024
1 parent cac5724 commit 8a81eb2
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/cdk-lib/bedrock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,15 @@ const actionGroupFunction = new lambda_python.PythonFunction(this, 'ActionGroupF
entry: path.join(__dirname, '../lambda/action-group'),
});

agent.addActionGroup({
const actionGroup = new bedrock.AgentActionGroup(this,'MyActionGroup',{
actionGroupName: 'query-library',
description: 'Use these functions to get information about the books in the library.',
actionGroupExecutor: actionGroupFunction,
actionGroupState: "ENABLED",
apiSchema: bedrock.ApiSchema.fromAsset(path.join(__dirname, 'action-group.yaml')),
});

agent.addActionGroup(actionGroup);
```

Python
Expand All @@ -375,21 +377,23 @@ action_group_function = PythonFunction(
entry="./lambda",
index="app.py",
handler="lambda_handler",
)
)

agent.add_action_group(
action_group_name="query-library",
description="Use these functions to get information about the books in the library.",
action_group_executor=action_group_function,
action_group_state="ENABLED",
api_schema=bedrock.ApiSchema.from_asset("action-group.yaml"),
)
actionGroup = bedrock.AgentActionGroup(self,
"MyActionGroup",
action_group_name="query-library",
description="Use these functions to get information about the books in the library.",
action_group_executor=action_group_function,
action_group_state="ENABLED",
api_schema=bedrock.ApiSchema.from_asset("action-group.yaml"))

agent.add_action_group(actionGroup)
```

### Prepare the Agent
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 .
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 .

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.
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***.

#### Prompt Overrides
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.
Expand Down Expand Up @@ -491,9 +495,9 @@ TypeScript
const agent = new bedrock.Agent(this, 'Agent', {
foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1,
instruction: 'You are a helpful and friendly agent that answers questions about literature.',
knowledgeBases: [kb],
aliasName: 'latest',
});
agent.addKnowledgeBase([kb]);
```

Python
Expand Down

0 comments on commit 8a81eb2

Please sign in to comment.