Skip to content

Commit

Permalink
Merge branch 'main' into guardrail-monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
krokoko authored Feb 12, 2025
2 parents e702f2a + 82c203e commit 132ee59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apidocs/namespaces/bedrock/interfaces/AgentAliasProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The name for the agent alias.
#### Default

```ts
- "latest"
- "latest-{hash}"
```

***
Expand Down
2 changes: 1 addition & 1 deletion src/cdk-lib/bedrock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ agent.add_action_group(actionGroup)

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 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_**.
Creating an agent alias will not prepare the agent, so if you create an alias using the `AgentAlias` resource then you should set `shouldPrepareAgent` to **_true_**.

#### Prompt Overrides

Expand Down
11 changes: 6 additions & 5 deletions src/cdk-lib/bedrock/agents/agent-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface AgentAliasProps {
/**
* The name for the agent alias.
*
* @default - "latest"
* @default - "latest-{hash}"
*/
readonly aliasName?: string;
/**
Expand Down Expand Up @@ -215,15 +215,16 @@ export class AgentAlias extends AgentAliasBase {
constructor(scope: Construct, id: string, props: AgentAliasProps) {
super(scope, id);

// Compute hash from agent, to recreate the resource when agent has changed
const hash = md5hash(props.agent.agentId + props.agentVersion + props.agent.lastUpdated);

// ------------------------------------------------------
// Set properties or defaults
// ------------------------------------------------------
this.aliasName = props.aliasName ?? 'latest';
// see https://github.com/awslabs/generative-ai-cdk-constructs/issues/947
this.aliasName = props.aliasName ?? `latest-${hash}`;
this.agent = props.agent;

// Compute hash from agent, to recreate the resource when agent has changed
const hash = md5hash(props.agent.agentId + props.agentVersion + props.agent.lastUpdated);

// ------------------------------------------------------
// L1 Instantiation
// ------------------------------------------------------
Expand Down

0 comments on commit 132ee59

Please sign in to comment.