跳至内容

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 !

已提问 2 年前961 查看次数

2 回答
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

已回答 2 年前

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

专家

已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。