So one of the things that, uh, we software developers, uh, do a lot is to interact with external
APIs.
So we request data from external APIs.
And in order to do that, until now, we have to do it by writing code and understanding the API endpoints.
So this is a process that is really it takes time effort you know, trial and error etc..
No.
And now what we want is to request data from an external API using natural language.
And as you will see, we can do this with an LM application very easily.
And it's going to be a very simple process.
Uh, just with these, uh, three steps here, you are going to define the API.
You are going to create a chain, and you are going to start asking questions in natural language to
request data to this API.
So if you look at the right side of the screen, you see that as always we ask for the OpenAI API key
and we start creating an instance of the LM model.
Once we have that, and this is a crucial step, we are going to define what we can call our API documentation.
This is very important because what we enter here is really what matters to this application.
So in this case for example we are going to use an API.
That is associated with a huge database with data about, you know, all the countries in the world,
right?
So they have information about, you know, the number of people living there, the language they speak,
and thousands of different indicators.
Right.
But the only information we are going to access is the information we define here in our API documentation,
because this is the information that is going to be passed to the GPT.
So this is like the prompt right.
So in this prompt what we are saying is this is the URL where the API is the base URL.
And in this API we are going to show interest in three endpoints just in three endpoints instead of
I don't know 100 endpoints that they provide.
So in this case, the only thing we are telling ChatGPT that we are interested in is the name of the
country, the currency they use and the language they speak there.
So.
Once we have that, the only thing we need to to do is to import a predefined chain from line chain
called API.
Chain this chain we are going to configure our our instance.
Instance of this chain using the LM we created and this API documentation.
We have configured this verbose through.
Don't worry about that.
You can just remove it and it will work the same.
So once we have that we just make questions to the API.
So we can ask this question.
Give me information about France in less than 100 words.
So ChatGPT is going to this external API is going to look for information about France using the endpoint.
And it's going to provide us this summary.
We can say we can ask questions more you know complex like list the top three biggest countries where
the official language is French.
So in this case they are looking for the official language.
And also three countries, uh, from biggest to smaller.
And probably they are using the population size here, I don't know.
So, uh, the answer here is that the top three biggest countries with official where the official language
is French are France, Canada and Belgium.
And I understand that here they are using the population size, because my understanding is that Canada
is a larger country than France in, in, in, in size.
But, uh, well, I don't know.
So this may be a question to, to to study further.
Right.
But right now what we have is a very, very simple application in order to request data from an external
API using a natural language.
This is really powerful and is going to change the way we as a software developers or software engineers
work on a daily basis.
So this is really revolutionary.
And we are, just as I say, in the elemental, simple basic stage of LM applications.