Skip to content

Amazon Bedrock Retrieve command

0

Hi, I have a question about the RetrieveCommand. When I use this method to fetch data from the knowledge base based on the input, how do I pass that data to the model?

Someone suggested using invokeAgent, but I don’t understand why. Why would I need to invoke an agent just to answer a question using the retrieved data? Isn’t that the model’s responsibility?

I want to create dynamic code that always interacts directly with the model. For generic queries like "Hi," I don't want it to search the knowledge base. Instead, I want it to only query the knowledge base when the question requires it, adjusting dynamically.

So my question is, how do I configure a model to answer questions directly, while dynamically invoking agents and querying the knowledge base only when necessary?

I already tried the following SDK methods by API - RetrieveAndGenerateCommand, RetrieveAndGenerateCommand, RetrieveCommand.

Thank you in advance !

asked 2 years ago909 views

2 Answers
0

The whole point of working with agents is not to think about who should address your question. The orchestration of the agents should understand if you need now to call the agents that are knowledge-based only of the one that calls some API. This concept is known as multi-agent orchestration, and there are a lot of resources about this topic.  https://github.com/awslabs/multi-agent-orchestrator https://awslabs.github.io/multi-agent-orchestrator/agents/built-in/amazon-bedrock-agent/

However, there is also an alternative. If you know for sure that your application should now address a general question, you can just invoke the LLM Model API. The same is for directly calling the KnowledgeBase API without invoking the agents.

AWS

answered 2 years ago

0

Hi,

You don't need to use invokeAgent(). Especially if you didn't create one...

I personally create and use Bedrock KBs without agent and then just call the regular invokeModel() with the output of the KB

For invokeModel API, see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html

To get a get idea on how to leverage the output of the KB as input to invokeModel(), please have look to my article https://repost.aws/articles/AR-LV1HoR_S0m-qy89wXwHmw/the-leverage-of-llm-system-prompt-by-knowledge-bases-for-bedrock-in-rag-workflows

Best,

Didier

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.