Skip to content

Commit 4dcf286

Browse files
authored
feat(bedrock): New embedding model config (#665)
1 parent 2d651ef commit 4dcf286

File tree

10 files changed

+309
-24
lines changed

10 files changed

+309
-24
lines changed

apidocs/namespaces/bedrock/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
- [ContextualGroundingPolicyConfigProps](interfaces/ContextualGroundingPolicyConfigProps.md)
6262
- [GuardrailConfiguration](interfaces/GuardrailConfiguration.md)
6363
- [GuardrailProps](interfaces/GuardrailProps.md)
64+
- [IAgentAlias](interfaces/IAgentAlias.md)
6465
- [IPrompt](interfaces/IPrompt.md)
6566
- [InferenceConfiguration](interfaces/InferenceConfiguration.md)
6667
- [KnowledgeBaseProps](interfaces/KnowledgeBaseProps.md)

apidocs/namespaces/bedrock/classes/AgentAlias.md

+58
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66

77
# Class: AgentAlias
88

9+
Interface for both Imported and CDK-created Agent Aliases.
10+
911
## Extends
1012

1113
- `Construct`
1214

15+
## Implements
16+
17+
- [`IAgentAlias`](../interfaces/IAgentAlias.md)
18+
1319
## Constructors
1420

1521
### new AgentAlias()
@@ -34,12 +40,34 @@
3440

3541
## Properties
3642

43+
### agentId
44+
45+
> `readonly` **agentId**: `string`
46+
47+
The unique identifier of the agent.
48+
49+
#### Implementation of
50+
51+
[`IAgentAlias`](../interfaces/IAgentAlias.md).[`agentId`](../interfaces/IAgentAlias.md#agentid)
52+
53+
***
54+
3755
### aliasArn
3856

3957
> `readonly` **aliasArn**: `string`
4058
4159
The ARN of the agent alias.
4260

61+
#### Example
62+
63+
```ts
64+
`arn:aws:bedrock:us-east-1:123456789012:agent-alias/DNCJJYQKSU/TCLCITFZTN`
65+
```
66+
67+
#### Implementation of
68+
69+
[`IAgentAlias`](../interfaces/IAgentAlias.md).[`aliasArn`](../interfaces/IAgentAlias.md#aliasarn)
70+
4371
***
4472

4573
### aliasId
@@ -48,6 +76,16 @@ The ARN of the agent alias.
4876
4977
The unique identifier of the agent alias.
5078

79+
#### Example
80+
81+
```ts
82+
`TCLCITFZTN`
83+
```
84+
85+
#### Implementation of
86+
87+
[`IAgentAlias`](../interfaces/IAgentAlias.md).[`aliasId`](../interfaces/IAgentAlias.md#aliasid)
88+
5189
***
5290

5391
### aliasName
@@ -86,6 +124,26 @@ Returns a string representation of this construct.
86124

87125
***
88126

127+
### fromAliasArn()
128+
129+
> `static` **fromAliasArn**(`scope`, `id`, `aliasArn`): [`IAgentAlias`](../interfaces/IAgentAlias.md)
130+
131+
Brings an Agent Alias from an existing one created outside of CDK.
132+
133+
#### Parameters
134+
135+
**scope**: `Construct`
136+
137+
**id**: `string`
138+
139+
**aliasArn**: `string`
140+
141+
#### Returns
142+
143+
[`IAgentAlias`](../interfaces/IAgentAlias.md)
144+
145+
***
146+
89147
### isConstruct()
90148

91149
> `static` **isConstruct**(`x`): `x is Construct`

apidocs/namespaces/bedrock/classes/BedrockFoundationModel.md

+29
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,27 @@ can instantiate a `BedrockFoundationModel` object, e.g: `new BedrockFoundationMo
117117

118118
> `readonly` `static` **TITAN\_EMBED\_TEXT\_V2\_1024**: [`BedrockFoundationModel`](BedrockFoundationModel.md)
119119
120+
***
121+
122+
### TITAN\_EMBED\_TEXT\_V2\_256
123+
124+
> `readonly` `static` **TITAN\_EMBED\_TEXT\_V2\_256**: [`BedrockFoundationModel`](BedrockFoundationModel.md)
125+
126+
***
127+
128+
### TITAN\_EMBED\_TEXT\_V2\_512
129+
130+
> `readonly` `static` **TITAN\_EMBED\_TEXT\_V2\_512**: [`BedrockFoundationModel`](BedrockFoundationModel.md)
131+
120132
## Methods
121133

122134
### asArn()
123135

124136
> **asArn**(`construct`): `string`
125137
138+
Returns the ARN of the foundation model in the following format:
139+
`arn:${Partition}:bedrock:${Region}::foundation-model/${ResourceId}`
140+
126141
#### Parameters
127142

128143
**construct**: `IConstruct`
@@ -133,6 +148,20 @@ can instantiate a `BedrockFoundationModel` object, e.g: `new BedrockFoundationMo
133148

134149
***
135150

151+
### asIModel()
152+
153+
> **asIModel**(`construct`): `IModel`
154+
155+
#### Parameters
156+
157+
**construct**: `IConstruct`
158+
159+
#### Returns
160+
161+
`IModel`
162+
163+
***
164+
136165
### toString()
137166

138167
> **toString**(): `string`

apidocs/namespaces/bedrock/interfaces/AgentAliasProps.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# Interface: AgentAliasProps
88

9+
Interface to create a new Agent Alias.
10+
911
## Properties
1012

1113
### agentId
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[**@cdklabs/generative-ai-cdk-constructs**](../../../README.md)**Docs**
2+
3+
***
4+
5+
[@cdklabs/generative-ai-cdk-constructs](../../../README.md) / [bedrock](../README.md) / IAgentAlias
6+
7+
# Interface: IAgentAlias
8+
9+
Interface for both Imported and CDK-created Agent Aliases.
10+
11+
## Properties
12+
13+
### agentId
14+
15+
> `readonly` **agentId**: `string`
16+
17+
The unique identifier of the agent.
18+
19+
#### Example
20+
21+
```ts
22+
`DNCJJYQKSU`
23+
```
24+
25+
***
26+
27+
### aliasArn
28+
29+
> `readonly` **aliasArn**: `string`
30+
31+
The ARN of the agent alias.
32+
33+
#### Example
34+
35+
```ts
36+
`arn:aws:bedrock:us-east-1:123456789012:agent-alias/DNCJJYQKSU/TCLCITFZTN`
37+
```
38+
39+
***
40+
41+
### aliasId
42+
43+
> `readonly` **aliasId**: `string`
44+
45+
The unique identifier of the agent alias.
46+
47+
#### Example
48+
49+
```ts
50+
`TCLCITFZTN`
51+
```

src/cdk-lib/bedrock/agent-alias.ts

+62-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,34 @@
1212
*/
1313

1414

15-
import { aws_bedrock as bedrock } from 'aws-cdk-lib';
15+
import { Arn, ArnFormat, aws_bedrock as bedrock, Resource } from 'aws-cdk-lib';
1616
import { Construct } from 'constructs';
1717

1818

19+
/**
20+
* Interface for both Imported and CDK-created Agent Aliases.
21+
*/
22+
export interface IAgentAlias {
23+
/**
24+
* The unique identifier of the agent alias.
25+
* @example `TCLCITFZTN`
26+
*/
27+
readonly aliasId: string;
28+
/**
29+
* The unique identifier of the agent.
30+
* @example `DNCJJYQKSU`
31+
*/
32+
readonly agentId: string;
33+
/**
34+
* The ARN of the agent alias.
35+
* @example `arn:aws:bedrock:us-east-1:123456789012:agent-alias/DNCJJYQKSU/TCLCITFZTN`
36+
*/
37+
readonly aliasArn: string;
38+
}
39+
40+
/**
41+
* Interface to create a new Agent Alias.
42+
*/
1943
export interface AgentAliasProps {
2044
/**
2145
* The unique identifier of the agent.
@@ -27,7 +51,6 @@ export interface AgentAliasProps {
2751
* @default - 'latest'
2852
*/
2953
readonly aliasName?: string;
30-
3154
/**
3255
* Description for the agent alias.
3356
*
@@ -52,13 +75,48 @@ export interface AgentAliasProps {
5275
readonly tags?: Record<string, string>;
5376
}
5477

55-
export class AgentAlias extends Construct {
78+
export class AgentAlias extends Construct implements IAgentAlias {
79+
// ------------------------------------------------------
80+
// Imports
81+
// ------------------------------------------------------
82+
/**
83+
* Brings an Agent Alias from an existing one created outside of CDK.
84+
*/
85+
public static fromAliasArn(scope: Construct, id: string, aliasArn: string): IAgentAlias {
86+
class Import extends Resource implements IAgentAlias {
87+
public readonly aliasArn = aliasArn;
88+
public readonly aliasId: string;
89+
public readonly agentId: string;
90+
91+
constructor() {
92+
super(scope, id);
93+
[this.agentId, this.aliasId] = this.parseArnComponents(aliasArn);
94+
}
95+
96+
private parseArnComponents(arn: string): [string, string] {
97+
const resourceName = Arn.split(arn, ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME).resourceName!;
98+
const [agentId, aliasId] = resourceName.split('/');
99+
return [agentId, aliasId];
100+
}
101+
}
102+
return new Import();
103+
}
104+
105+
// ------------------------------------------------------
106+
// CDK-created Agent Alias
107+
// ------------------------------------------------------
108+
/**
109+
* The unique identifier of the agent.
110+
*/
111+
public readonly agentId: string;
56112
/**
57113
* The unique identifier of the agent alias.
114+
* @example `TCLCITFZTN`
58115
*/
59116
public readonly aliasId: string;
60117
/**
61118
* The ARN of the agent alias.
119+
* @example `arn:aws:bedrock:us-east-1:123456789012:agent-alias/DNCJJYQKSU/TCLCITFZTN`
62120
*/
63121
public readonly aliasArn: string;
64122
/**
@@ -84,6 +142,7 @@ export class AgentAlias extends Construct {
84142
}];
85143
}
86144

145+
this.agentId = props.agentId;
87146
this.aliasId = alias.attrAgentAliasId;
88147
this.aliasArn = alias.attrAgentAliasArn;
89148
this.aliasName = props.aliasName ?? 'latest';

0 commit comments

Comments
 (0)