Okay, so I checked out this branch, which is called project slash react search agent.
And just a quick note, if you want to check out the code for this section, check out this branch over
here.
And for technical reasons, I committed the code to this branch over here and not the branch on the
bottom left here.
Alright, let's start by initializing our Python project.
Let's write init.
And now let's go install the dependencies.
Let's add link chain.
We want to use link chain OpenAI.
And we discussed those packages in previous videos.
So now we want to add a new package which is called link Chain.
And Tivoli is a third party which is going to help us connect our agent to the web and give the agent
searching capabilities so it will act as a search engine for our agent.
And it also has other very useful APIs like Tivoli Crawl, Tivoli Map, Tivoli Extract, which are very
useful services for AI agents, and we'll be using those capabilities in direct section of the course,
so we'll cover them as well.
And by the way, David is actually the most popular choice for integrating a web search into an agent.
And they're even featured in the official documentation as the default service for a search engine.
And when implementing agents.
So they really go to example.
And I think the reason for that is that they first of all have an excellent API.
It scales very well.
It's very easy to use.
And I think they were actually the first ones to go and integrate this.
So to connect an agent A with searching capabilities.
Now it's also important to note that they have a very generous free tier.
And you can see it's 1000 API requests per month, which is going to be more than enough for this course.
All right.
Let me just show you a quick demo of the capabilities that we can integrate with it.
So in the API playground let me write a query like what are the latest anthropic models?
And we can see in the response we get here the URL of the source.
We also get the content you can see here it's talking about Cloud Outpost 4.1.
And in this search result it talks about Cloud Ops and Sonet four.
And the search can be much more advanced.
We can have some special filtering and advanced capabilities.
However in this section we're only going to stick with the basics.
All right.
So that's enough about me.
And I'm going to link to Vili in the videos.
Resources.
Alrighty.
Let's go back to the code here and link to Vili is the link chain integration.
And here the provider is the Vili a in contrast to OpenAI in the previous example.
So a provider of link chain doesn't have to be a vendor which offers large language models.
It can also be a vendor which offer services that are exposed via API's and clients.
So in this case Turville is going to expose their services, their searching capabilities, their scraping
capabilities, and the LinkedIn integration here is going to make our lives very, very easy when we
want to integrate those capabilities into our link chain graph applications here, because the team
they wrote now, this integration, they connected to all the link chain objects, which we're going
to use.
And I'll give you a quick hint.
It's going to be link chain tools.
And this is another example of a link chain provider.
All right.
Let's go and also install Python dot env to load environment variables like we did before.
And let me also install black.
And I sought for some formatting and uh yeah let's go and install everything.
So let me go and click enter.
We can check out the packages in the pyproject.toml file over here.
And if you want the exact packages we can check out the dot log.
And let's go to our main.py file the boilerplate code.
So let's try it.
And let's run this code and make sure that it's working.
All right.
So we can see it's working.
And now let me show you what I have in my env file.
So like in the previous section I have my open API key I have Lang Smith.
Tracing equals true.
So we want to trace everything and we want to check out the traces I have here.
My Lang Smith API key.
Like previous sections I have my Lang Smith project which I changed in called Search Agent.
And I also have here a API key which I got from the UI.
All right.
Let me show you how you can get it.
You simply need to go to the village to log in.
Let me now go and log with Google.
And right here I have my environment.
You can see all my API keys.
Let me go and generate an API key.
For example I'm using the free plan by the way.
Let me go and click here this plus button.
Now let's name the API key.
let's call it API key.
I'm going to limit my monthly usage.
And yeah let's hit create.
And here you can simply go you can check out you can review the API key.
You can copy it.
And this is the value that you should put in your um dot env file.
So let me go back now to the env file.
And it's also important to note that the name of the environment variable needs to be underscore API
key, because that's where link chain is going to be looking for the credentials to authenticate to
the services.
So it's working very similarly to the OpenAI API key here, where it's going to look for that API key
in the environment variables.
Alrighty, let's go now to our main.py file.
And let's start with the imports.
And first let's go and let's load all the environment variables from the env file like we did in the
previous videos.
So let's import the load env function.
And I want to call it in the beginning of the file here Hey there.
Ethan here.
Um, just a quick disclaimer.
So this is being added in October 20th, 2025, and I just want to have a quick note before we jump
in.
So LinkedIn recently released version one.
And it does have some breaking changes, especially with imports.
And I'm working really hard to make sure everything in this course is compatible for you.
But right now, because LinkedIn v1 has a few mismatches and bugs between the documentation and the
code, I recommend you using for the imports link chain Dash classic package.
That package keeps the old import stable and I'll show you the updated imports alongside the original
ones in the code, so you can follow along easily in case you installed link chain version one, which
is currently now the rolled out default.
So thanks for bearing with me.
I'm making sure everything is going to be as smooth as possible for you, and I will be refilming,
re-editing and adjusting the videos for everything to be compatible.
But right now, because this is so new, this is a transition period.
So let me now import from LinkedIn the hub object.
And the election hub is within the LinkedIn ecosystem.
And it's designed for sharing and exploring prompts, chains and agents created by the community.
So it serves also as a resource where developers can find inspiration, can reuse components.
And we're going to use the hub in order to download a very special prompt, which is called a react
prompt.
All right.
And we want to import the create react agent function and the agent executor class.
Hey there.
This is hidden here popping up.
Now I want to give you a quick heads up in this section.
I want us to treat the react agent as a black box.
So it's going to receive the tools that we want our agent to have, and it's going to run it, and it's
going to give us some awesome capabilities like we saw in the demo.
Now, I am not expecting you to know how it's working under the hood.
In fact, the next section is entirely dedicated for us to figure out how this magic is working.
So in this section, I am not expecting you to understand how this is working.
And what's the magic?
This is going to be in the next section.
I am expecting you just to learn the interface of how to use those objects.
Right.
So back to the code and let's explain those imports.
So the Create react agent is a built in special function that is going to create us a runnable a link
chain chain which is referred to as the react agent.
Now this agent is not really an agent.
It's a link chain chain.
It's a runnable object.
And it's going to be our reasoning engine of our react agent.
And the create react agent receives an LLM.
So this is going to be the LLM which is going to be our reasoning engine.
It's going to receive a list of tools.
So here in our example it's going to be a search tool.
And it's going to receive a prompt.
And the prompt we're going to give it is going to be the react prompt, which we're going to cover in
depth.
Trust me.
And everything together is going to be a very special prompt that is being sent to the LM, and it's
going to make our LM become the reasoning engine, the brain of our agent.
So it's going to decide what we want to do, maybe to invoke something to call a tool, or maybe to
return the answer.
This is going to be the brain.
Now again, you do not need to fully understand it, okay?
You just need to know that it's going to receive the LM, the tools and the special prompt.
All right.
Now let's talk about the agent executor.
And the agent executor is going to be the runtime of the agent.
If the reasoning engine is going to tell us what we need to run, if we need to call the search tool
with which arguments, then the agent executor is going to make the actual calls.
So it's going to be the runtime.
So it's going to be the things that is going to execute everything.
And I'll give you a quick spoiler.
The agent executor is not that complicated as it may sound.
It has a very fancy name, but in the end it's a for loop.
And you're going to see this in the next section.
All right, so I know I introduced a lot of terminology right now.
I hope I didn't freak you out too much.
I remind you, the goal of this section is just to review the interface and to review the capabilities.
Cool.
So let's continue to other imports.
We want to import chat OpenAI because we're going to be using GPT.
And let's go and also import from let's go and import the Tavileh search.
And Tavileh search is a link chain tool that we're going to connect to our LLM, which is going to give
our agent the capability to make searches over the internet.
And Tavileh search is the Tavileh API that the Tavileh team wrapped as a learning tool.
And now it's compatible with the link chain ecosystem, and we can connect it to our link chain agents.