Simplify our Tool-Calling Agent through create_react_agent
LangGraph has some amazing Prebuilt Components, one of them is the create_react_agent
function that allows you to hughely simplify creating new tool-using agents.
The full source code can be found within our github history.
The simplified version
This willb e based upon our recent configuration-improved version. Similar to that version, we start by reading the configuration data, setting up our LLM, connecting to the target system via SSH, and configuring tools for usage through LLMs:
Now we can use the create_react_agent
method to create a new agent graph based upon our configured LLM and the known tools:
Using create_react_agent | |
---|---|
All that's left is to create the initial message (as detailed in our initial blog post) and start the agent by calling stream
on it while passing the mentioned initial message.
Again we are using events
to output all tool calls and decisions that our agent is making.
And that's it! Pretty amazing, when you think about it.
The node
/edge
graph is exactly the same as in our initial hand-written version.