Hey there.
Eden here.
And in this video I'm going to show what are the differences between the function calling agent and
the react agent in the long chain implementation, when to use one over the other, and what are the
advantages and disadvantages of each one?
And like all things in software today, it all boils down where do we shift our responsibility to who
is responsible for the agent selecting the correct tool with the correct input?
And I think the analogy to serverless is appropriate here, because in serverless we shift all the responsibility
for the availability, durability, scalability, all those ilities we shift it to the vendor, to the
cloud provider.
Now, when it comes to agents, we have two paradigms of tool selection.
The one is function calling.
And in function calling we supply a certain schema to the vendor, specifying all of our functions that
we want to equip our agent with.
And after that, our LM is sort of equipped with those tools.
The LM may respond to us in its response that we need to invoke a tool with certain arguments according
to the specification we send it.
Now, just like in serverless here, we are not exposed for the logic that happens under the hood,
for how the LM is determining how to select the tool.
By the way, my guess here is that this is a fine tuned model, specifically fine tuned for tool selection
similar to the gorilla paper.
So in the function calling agent, the responsibility for selecting the tools is on the vendor, the
LM vendor.
And of course I have to note it's a shared responsibility model because we need to make sure that our
tool descriptions are not ambiguous and that they are well defined.
So the LM would have an easier job to do it.
And today many vendors support function calling or tool calling.
OpenAI.
Google.
Anthropic.
Mistral.
They all support tool calling.
And luckily for us, Late Chain implemented an abstraction for this a well defined interface for using
tool, calling for every vendor that supports.
So at the moment, switching between models that support tool calling is super easy.
And we can switch models with tool calling like we switch our socks.
Alrighty.
Now in a react agent, it's an agent that specifically is using the react prompting, which is based
on the react paper.
Here it all boils down to the react prompt that is sent to the LM.
This is a well crafted prompt that the Link Chain team wrote and was inspired by the react paper, and
incorporates a lot of prompt engineering techniques like chain of thought and few shot prompting.
And I have to say, I think it's the most beautiful prompt today in prompt engineering, so well, job
link chain.
This is an awesome prompt.
Anyways, the whole idea of this prompt is to make the LM come our reasoning engine to select which
tools to use.
And it turns out that this prompt is actually very useful for turning the LLM into a reasoning engine,
and that in a lot of cases, it does return the correct tool to use with the correct inputs, and the
LLM output is usually action and action input, which Linkchain knows how to parse and to deduce from
it.
Which tool do we need to use?
They do it with some regular expressions.
Now, after we run the tool and we get a result back from our tool execution, then Linkchain labels
it as an observation.
And then we start to reiterate and to run again a prompt with them.
But this time it will contain the history of what the LLM decided so far.
Which tool did we use and what was the result of that tool?
What was the observation?
And this was a very high level explanation of the react loop.
But basically here it all boils down to the react prompt and the react prompt is what leverages the
LLM to become our reasoning engine.
So we have full control of this prompt.
And if we want, we can tweak it around and we can customize it according to our needs.
So we have much more flexibility here for the tool selection part.
Alrighty.
So which one is better?
And to be honest, I don't have the exact answer for that.
Like everything in software, it depends.
If we want full control and full flexibility, we can use the react prompt.
But the problem here is that all the responsibility is on us as developers while in function calling.
Then the tool selection responsibility is on the vendor and this saves us a lot of work and a lot of
thinking, because all the work for the tool selection was done by the vendor.
We have here less control.
However, we do have here much less headache and that was pretty much it.
I hope you enjoyed the video.
Please let me know in the comments what you think.