Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bedrock: Prompt Management. Add ability to add variables for system prompt #883

Open
2 tasks
o-alexandrov opened this issue Jan 7, 2025 · 3 comments
Open
2 tasks
Labels
backlog enhancement New feature or request

Comments

@o-alexandrov
Copy link

o-alexandrov commented Jan 7, 2025

Describe the feature

Currently, there is a limitation in Prompt Management:

  • it's impossible to use variables in the system part 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
@o-alexandrov o-alexandrov added the needs-triage This issue or PR still needs to be triaged. label Jan 7, 2025
@o-alexandrov
Copy link
Author

o-alexandrov commented Jan 7, 2025

There're also 2 bugs in AWS Bedrock => Prompt Management.
I don't know where to report them, so I just drop them here.

  1. When browsing the prompt in the UI, it highlights variables syntax in the system part as if it's working.
Screenshot 2025-01-07 at 12 02 19 PM
  1. When opening the prompt in the prompt editor, the model shows infinite loading indicator
Screenshot 2025-01-07 at 12 03 37 PM

@krokoko krokoko added enhancement New feature or request backlog and removed needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2025
@aws-rafams
Copy link
Contributor

aws-rafams commented Jan 8, 2025

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'],
});

@o-alexandrov
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants