11import * as fs from "fs"
22import { ChatMessage } from "@cdklabs/generative-ai-cdk-constructs/lib/cdk-lib/bedrock"
33import { Construct } from "constructs"
4+ import { CfnPrompt } from "aws-cdk-lib/aws-bedrock"
45
56export type BedrockPromptSettingsType = "system" | "user" | "reformulation"
67
7- export interface BedrockPromptInferenceConfig {
8- temperature : number ,
9- topP : number ,
10- maxTokens : number ,
11- stopSequences : Array < string >
12- }
13-
148/** BedrockPromptSettings is responsible for loading and providing
159 * the system, user, and reformulation prompts along with their
1610 * inference configurations.
@@ -19,7 +13,7 @@ export class BedrockPromptSettings extends Construct {
1913 public readonly systemPrompt : ChatMessage
2014 public readonly userPrompt : ChatMessage
2115 public readonly reformulationPrompt : ChatMessage
22- public readonly inferenceConfig : BedrockPromptInferenceConfig
16+ public readonly inferenceConfig : CfnPrompt . PromptModelInferenceConfigurationProperty
2317
2418 /**
2519 * @param scope The Construct scope
@@ -38,14 +32,10 @@ export class BedrockPromptSettings extends Construct {
3832 const reformulationPrompt = this . getTypedPrompt ( "reformulation" )
3933 this . reformulationPrompt = ChatMessage . user ( reformulationPrompt . text )
4034
41- const temperature = this . node . tryGetContext ( "ragTemperature" )
42- const maxTokens = this . node . tryGetContext ( "ragMaxTokens" )
43- const topP = this . node . tryGetContext ( "ragTopP" )
44-
4535 this . inferenceConfig = {
46- temperature : parseInt ( temperature , 10 ) ,
47- topP : parseInt ( topP , 10 ) ,
48- maxTokens : parseInt ( maxTokens , 10 ) ,
36+ temperature : 0 ,
37+ topP : 1 ,
38+ maxTokens : 512 ,
4939 stopSequences : [
5040 "Human:"
5141 ]
0 commit comments