1 回答
- 最新
- 投票最多
- 评论最多
0
This issue occurs because there are two different ways to interact with Bedrock Agents, each using different prompts:
- Bedrock Console (UI) Interaction:
- Uses the Knowledge Base orchestration prompt you configured
- Follows the custom prompt settings you defined in the agent configuration
- Boto3 API Interaction:
- By default, uses the standard API orchestration prompt
- Doesn't automatically use the custom prompt settings from the console
To resolve this, you have a few options:
- Pass the custom prompt explicitly in your boto3 call:
response = bedrock_client.invoke_agent( agentId=agent_id, agentAliasId=agent_alias_id, sessionId='techlead', endSession=False, inputText="what is product X?", orchestrationConfiguration={ "promptOverride": "Your custom prompt here" } )
- Use the prepare_agent API call first:
prepare_response = bedrock_client.prepare_agent( agentId=agent_id, agentAliasId=agent_alias_id, sessionId='techlead', orchestrationConfiguration={ "promptOverride": "Your custom prompt here" } ) response = bedrock_client.invoke_agent( agentId=agent_id, agentAliasId=agent_alias_id, sessionId='techlead', endSession=False, inputText="what is product X?" )
- Update your agent's default orchestration configuration through the AWS CLI or API, so it's consistent across all interaction methods.
The key is to ensure the orchestration configuration is properly set when making API calls. The console automatically handles this for you, but with boto3, you need to explicitly manage it.
Also, make sure you're using the latest version of boto3, as earlier versions might have different behavior regarding prompt handling.
已回答 5 个月前
相关内容
- 已提问 5 个月前
