Skip to content

Commit 490c683

Browse files
Fix: [AEA-0000] - removes hardcoded text value (#220)
## Summary **Remove items from this list if they are not relevant. Remove this line once this has been done** - Routine Change - ❗ Breaking Change - 🤖 Operational or Infrastructure Change - ✨ New Feature - ⚠️ Potential issues that might be caused by this change ### Details Add any summary information of what is in the change. **Remove this line if you have nothing to add.** ## Pull Request Naming Pull requests should be named using the following format: ```text Tag: [AEA-NNNN] - Short description ``` Tag can be one of: - `Fix` - for a bug fix. (Patch release) - `Update` - either for a backwards-compatible enhancement or for a rule change that adds reported problems. (Patch release) - `New` - implemented a new feature. (Minor release) - `Breaking` - for a backwards-incompatible enhancement or feature. (Major release) - `Docs` - changes to documentation only. (Patch release) - `Build` - changes to build process only. (No release) - `Upgrade` - for a dependency upgrade. (Patch release) - `Chore` - for refactoring, adding tests, etc. (anything that isn't user-facing). (Patch release) If the current release is x.y.z then - a patch release increases z by 1 - a minor release increases y by 1 - a major release increases x by 1 Correct tagging is necessary for our automated versioning and release process. The description of your pull request will be used as the commit message for the merge, and also be included in the changelog. Please ensure that your title is sufficiently descriptive. ### Rerunning Checks If you need to rename your pull request, you can restart the checks by either: - Closing and reopening the pull request - pushing an empty commit ```bash git commit --allow-empty -m 'trigger build' git push ``` - Amend your last commit and force push to the branch ```bash git commit --amend --no-edit git push --force ``` Rerunning the checks from within the pull request will not use the updated title.
1 parent 782b3e7 commit 490c683

5 files changed

Lines changed: 21 additions & 16 deletions

File tree

packages/cdk/resources/BedrockPromptResources.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export interface BedrockPromptResourcesProps {
1414
export class BedrockPromptResources extends Construct {
1515
public readonly queryReformulationPrompt: Prompt
1616
public readonly ragResponsePrompt: Prompt
17+
public readonly ragModelId: string
18+
public readonly queryReformulationModelId: string
1719

1820
constructor(scope: Construct, id: string, props: BedrockPromptResourcesProps) {
1921
super(scope, id)
@@ -56,6 +58,10 @@ export class BedrockPromptResources extends Construct {
5658
variants: [ragResponsePromptVariant]
5759
})
5860

61+
// expose model IDs for use in Lambda environment variables
62+
this.ragModelId = novaProModel.modelId
63+
this.queryReformulationModelId = novaLiteModel.modelId
64+
5965
this.queryReformulationPrompt = queryReformulationPrompt
6066
this.ragResponsePrompt = ragPrompt
6167
}

packages/cdk/resources/Functions.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import {StringParameter} from "aws-cdk-lib/aws-ssm"
55
import {Secret} from "aws-cdk-lib/aws-secretsmanager"
66
import {TableV2} from "aws-cdk-lib/aws-dynamodb"
77

8-
// Claude model for RAG responses
9-
const RAG_MODEL_ID = "anthropic.claude-3-sonnet-20240229-v1:0"
10-
// Claude model for query reformulation
11-
const QUERY_REFORMULATION_MODEL_ID = "anthropic.claude-3-haiku-20240307-v1:0"
128
const BEDROCK_KB_DATA_SOURCE = "eps-assist-kb-ds"
139
const LAMBDA_MEMORY_SIZE = "265"
1410

@@ -38,6 +34,8 @@ export interface FunctionsProps {
3834
readonly ragResponsePromptVersion: string
3935
readonly isPullRequest: boolean
4036
readonly mainSlackBotLambdaExecutionRoleArn : string
37+
readonly ragModelId: string
38+
readonly queryReformulationModelId: string
4139
}
4240

4341
export class Functions extends Construct {
@@ -58,8 +56,8 @@ export class Functions extends Construct {
5856
additionalPolicies: [props.slackBotManagedPolicy],
5957
dependencyLocation: ".dependencies/slackBotFunction",
6058
environmentVariables: {
61-
"RAG_MODEL_ID": RAG_MODEL_ID,
62-
"QUERY_REFORMULATION_MODEL_ID": QUERY_REFORMULATION_MODEL_ID,
59+
"RAG_MODEL_ID": props.ragModelId,
60+
"QUERY_REFORMULATION_MODEL_ID": props.queryReformulationModelId,
6361
"KNOWLEDGEBASE_ID": props.knowledgeBaseId,
6462
"BEDROCK_KB_DATA_SOURCE": BEDROCK_KB_DATA_SOURCE,
6563
"LAMBDA_MEMORY_SIZE": LAMBDA_MEMORY_SIZE,

packages/cdk/resources/RuntimePolicies.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import {Construct} from "constructs"
22
import {PolicyStatement, ManagedPolicy} from "aws-cdk-lib/aws-iam"
33

4-
// Claude model for RAG responses
5-
const RAG_MODEL_ID = "anthropic.claude-3-sonnet-20240229-v1:0"
6-
// Claude model for query reformulation
7-
const QUERY_REFORMULATION_MODEL_ID = "anthropic.claude-3-haiku-20240307-v1:0"
8-
94
export interface RuntimePoliciesProps {
105
readonly region: string
116
readonly account: string
@@ -17,6 +12,8 @@ export interface RuntimePoliciesProps {
1712
readonly guardrailArn: string
1813
readonly dataSourceArn: string
1914
readonly promptName: string
15+
readonly ragModelId: string
16+
readonly queryReformulationModelId: string
2017
}
2118

2219
export class RuntimePolicies extends Construct {
@@ -30,8 +27,8 @@ export class RuntimePolicies extends Construct {
3027
const slackBotPolicy = new PolicyStatement({
3128
actions: ["bedrock:InvokeModel"],
3229
resources: [
33-
`arn:aws:bedrock:${props.region}::foundation-model/${RAG_MODEL_ID}`,
34-
`arn:aws:bedrock:${props.region}::foundation-model/${QUERY_REFORMULATION_MODEL_ID}`
30+
`arn:aws:bedrock:${props.region}::foundation-model/${props.ragModelId}`,
31+
`arn:aws:bedrock:${props.region}::foundation-model/${props.queryReformulationModelId}`
3532
]
3633
})
3734

packages/cdk/stacks/EpsAssistMeStack.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export class EpsAssistMeStack extends Stack {
129129
knowledgeBaseArn: vectorKB.knowledgeBase.attrKnowledgeBaseArn,
130130
guardrailArn: vectorKB.guardrail.guardrailArn,
131131
dataSourceArn: vectorKB.dataSourceArn,
132-
promptName: bedrockPromptResources.queryReformulationPrompt.promptName
132+
promptName: bedrockPromptResources.queryReformulationPrompt.promptName,
133+
ragModelId: bedrockPromptResources.ragModelId,
134+
queryReformulationModelId: bedrockPromptResources.queryReformulationModelId
133135
})
134136

135137
// Create Functions construct with actual values from VectorKB
@@ -157,6 +159,8 @@ export class EpsAssistMeStack extends Stack {
157159
ragResponsePromptName: bedrockPromptResources.ragResponsePrompt.promptName,
158160
reformulationPromptVersion: bedrockPromptResources.queryReformulationPrompt.promptVersion,
159161
ragResponsePromptVersion: bedrockPromptResources.ragResponsePrompt.promptVersion,
162+
ragModelId: bedrockPromptResources.ragModelId,
163+
queryReformulationModelId: bedrockPromptResources.queryReformulationModelId,
160164
isPullRequest: isPullRequest,
161165
mainSlackBotLambdaExecutionRoleArn: mainSlackBotLambdaExecutionRoleArn
162166
})

packages/slackBotFunction/app/services/query_reformulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
def reformulate_query(user_query: str) -> str:
1515
"""
16-
Reformulate user query using Claude Haiku for better RAG retrieval.
16+
Reformulate user query using Amazon Nova Lite for better RAG retrieval.
1717
1818
Loads prompt template from Bedrock Prompt Management, formats it with the user's
19-
query, and uses Claude to generate a reformulated version optimized for vector search.
19+
query, and uses Nova Lite to generate a reformulated version optimized for vector search.
2020
"""
2121
try:
2222
client: BedrockRuntimeClient = boto3.client("bedrock-runtime", region_name=os.environ["AWS_REGION"])

0 commit comments

Comments
 (0)