Bedrock: Prompt Management. Add ability to add variables for `system` prompt
Describe the feature
Currently, there is a limitation in Prompt Management:
- it's impossible to use variables in the
systempart of the prompt
Use Case
When defining a system prompt, most of the prompts I worked on involve a necessity to have variables in the system (role defining) part of the prompt.
Proposed Solution
Add ability to reuse and add unique (used only in the system part) variables.
Than, expose it through the construct.
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
There're also 2 bugs in AWS Bedrock => Prompt Management. I don't know where to report them, so I just drop them here.
- When browsing the prompt in the UI, it highlights variables syntax in the system part as if it's working.
- When opening the prompt in the prompt editor, the model shows infinite loading indicator
Hi @o-alexandrov ! Thanks for flagging this issue. I've tried to recreate a working example in the console, but no luck. It looks like this might be a limitation with Amazon Bedrock itself, not our CDK library.
In any case, system instructions are usually meant for static info that doesn't change between invocations, as this helps the model work more efficiently and better. You can still do role prompting by including your dynamic section in the user message.
const variantChat = PromptVariant.chat({
variantName: 'variant1',
model: BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
system: "You are a highly acclaimed educator with extensive experience in developing innovative inquiry-based curricula for students. The content you create aligns with current educational standards and incorporates the latest research in effective science pedagogy.",
messages: [
ChatMessage.user('Your expertise lies in creating engaging, hands-on lessons about {{subject}} that foster critical thinking and scientific curiosity for students in grades {{grades}}. Your task is to design an interactive, question-driven lesson on {{lessonName}}. Do not include a preamble to your answer.'),
],
promptVariables: ['subject', 'grades', 'lessonName'],
});
@aws-rafams
It looks like this might be a limitation with Amazon Bedrock itself, not our CDK library.
Yes, it's also not working in the AWS Bedrock web interface.
system instructions are usually meant for static info that doesn't change between invocations, as this helps the model work more efficiently and better.
Even though variables for the system message are present, it doesn't mean the system message is different for the chat. I think it's reasonable to have ability to reuse the same prompt for different cases of a system message.
- otherwise, you'd either require a user to:
- create a different prompt with a little difference to the system message
- worsen the output, by moving role defining part into the user message
Anyone has any updates on this? Im facing the same issue with the variable in system message.
The same problem we had with variables in the system message.