내용으로 건너뛰기

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년 전946회 조회

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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠