Let's prepare a question to ask the agent.
We will start with a programming -related
question to see if the agent uses the Python REPL tool.
So, question equals, generate the first 20 numbers in the Fibonacci series.
Now, we ll use the executor to invoke the agent with the question, output equals,
agentExecutor .invoke and the argument will be a dictionary, the keys input and
the value fromTemplate .format of Q equals question.
The argument Q is the parameter of the template, this is the template, it s the
question asked by the user, I am running it, I am running the code.
Take a look at the debugging information, this is the chain of thugs, look how it
chose the right tool Python REPL and generated the first 20 numbers in the
Fibonacci series very well.
By the way, output is a dictionary with
two keys input and output, output of input contains the template and output of
output contains the text response of the agent, that s awesome, the agent nailed it.
Next, let s try a current events question to see if the agent searches the web
using DuckDuckGo, the question will be, Who is the current Prime Minister of the UK?
I am running the code, it chose DuckDuckGo search for this task, it needs
up to date information, very well, this is the correct answer, please ignore this
warning for now, it has nothing to do with Langchain, React or LLMs, let s ask
another question, something related to history so that it will choose the
Wikipedia tool, tell me about Napoleon Bonaparte early life and I am running the
code, very well, it has chosen Wikipedia, the agent nailed it choosing the right
tool for each question and getting the answer right.
Now, let s take a look at the last example to see if the chain of thoughts
features is working as it should, in the template here, I will add answer the
following questions in German as best you can, I am running this cell, now back to
invoking the agent executor, I am running this code, take a look here, the agent
chain of thoughts is clear, to answer this question in German, I will first
gather information about Napoleon Bonaparte early life in English and then
translate it into German, very well, this is the output translated into German,
that s it folks, take your time to soak this all in, it s the key to becoming a
chain LLM wizard,