Orchestrating the text-to-query agent
Este exercício faz parte do curso
Text-to-Query Agents with MongoDB and LangGraph
Instruções do exercício
- Define the graph state using the
GraphStateclass, with a single attribute calledmessages. - Define the agent node that reads the
messagesattribute of the graph state, invokes thellm_with_toolswith the messages, and appends the result to themessagesattribute of the graph state. - Define the tool node that reads the
tool_callsattribute of the most recent message in the graph state, extracts the name of the tool to execute (name), invokes it with the arguments (args) of the tool call, and appends the result to themessagesattribute of the graph state. - Initialize the graph using the
StateGraphclass in LangGraph, with the graph state (GraphState) we defined previously. - Add the nodes and edges to the graph and compile it.
Note: If you’re running DataLab in Restricted Mode, this exercise isn’t supported yet. We’re actively working on making it available in the future.
Exercício interativo prático
Transforme a teoria em ação com um de nossos exercícios interativos
Começar o exercício