Saltar al contenido

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 !

preguntada hace 2 años954 visualizaciones

2 Respuestas
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

respondido hace 2 años

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

EXPERTO

respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.