- Newest
- Most votes
- Most comments
Thank you for your question about using Prompt Management Prompts with Bedrock Agents programmatically. There are a few important points to clarify regarding this functionality.
Currently, there is a limitation when it comes to using prompts with agents programmatically. While you can create prompts that include a Generative AI Resource (such as a Bedrock Agent) and test them in the console, this functionality is not directly available through the API.
When using the API to invoke an agent with a prompt, you need to take a different approach. Instead of referencing the prompt directly, you must enter the text of the prompt into the 'inputText' field of the InvokeAgent request. This means you can't directly use the prompt ARN or ID when making API calls to invoke the agent.
To use a prompt with an agent programmatically, you would need to:
- Retrieve the prompt text from your Prompt Management system.
- Insert any necessary variable values into the prompt text.
- Use this prepared text as the input for the InvokeAgent API call.
It's important to note that this workflow differs from how prompts can be used with foundation models, where you can specify the prompt ARN directly in API calls.
For now, the ability to select and use prompts with agents through the console (as you described in the test window) is a feature that simplifies the process for manual testing and interaction, but it doesn't have a direct equivalent in the programmatic API calls.
If you need to frequently use specific prompts with your agents in a programmatic workflow, you may want to consider storing the prompt templates in your application code and preparing them with the necessary variables before making the InvokeAgent call.
AWS is continuously improving its services, so it's worth keeping an eye on future updates that might introduce more seamless integration between Prompt Management and Agent invocation via API.
Sources
Create a prompt using Prompt management - Amazon Bedrock
Test a prompt using Prompt management - Amazon Bedrock
Relevant content
- asked 2 months ago
- AWS OFFICIALUpdated 4 years ago
