In this basic application, this basic Elm application, we are going to ask using natural language,
a database.
We are going to to ask questions to a database.
And this is really revolutionary because until now, as you know we are having this problem.
So to get information from a database we had to use complex languages like SQL etc..
So this limited a lot the type of people that can ask questions to a database.
If you are not familiar with the SQL language, you cannot do anything in this in this field, right?
But now what we want is that anyone in our company, anyone in our organization, using natural language
or common language, common English, can ask questions from a database.
This is a revolutionary.
So launching can do this in a very, very simple way.
As you will see we are going to use a predefined chain and it will do the job for us.
So the process is going to be very, very simple.
We are going to load the database.
We are going to create a predefined chain and going to we are going to start asking questions in natural
language.
So if you look at the code in the right side of the screen, the first thing we do is to load the OpenAI
API AP api key as we do always.
And once that is complete, we uh, we are going to load.
Well, we are going to create an instance of the of the Elm.
And uh, we are going to import a couple of components.
One is SQL database and the other one is SQL database chain.
This second one we are getting it from long chain experimental okay.
So this is not the, uh, final approved version of long chain.
This is just like a candidate, uh, for, uh, you know, uh, a final version of a long chain.
This is we are using this way because it's interesting for us right now.
You will see that we have different, many different options in next chapters.
But right now this serves us well.
So the first thing we do is to load the database.
And once we have that, the only thing we have to do is to create a chain using this SQL database chain
and chain does everything for us in this change.
In this chain we enter the Elm and the database.
This one is is is nothing but was true.
We can just remove this thing here.
And the only thing we have to do is to execute this chain.
Once we execute this chain.
And with a question.
ChatGPT starts providing responses.
So if we ask the database we have loaded.
Here is a short version of a public database from the, uh, San Francisco city.
So in this database we have information about the trees in the city, blah blah, blah, blah.
Right.
This is a huge database we have reduced with only 1000 rows.
I think the original one has like 80,000 rows or something like that.
So we are making a couple of questions.
The first one is how many species of trees are in San Francisco.
The second one, how many trees of the species Ficus nitida are in San Francisco.
This is the answer that ChatGPT is going to provide, and in both cases the answers are correct.
We can check that the answers are correct if we are use if we use SQL, for example, or if we use a
Gpt4, we load the database as a file in ChatGPT four and we ask questions about that.
The difference of doing this or using the long chain approach is that with the long chain approach,
we don't need to load the whole database to long chain.
And the process of searching information is going to be much more convenient in terms of time and cost,
etc..
Right?
So as you can see, a long chain has a another, uh, very easy and fast way to solve a very important
problem for us.
So imagine in every company and organization that has this huge, uh, databases that until now were
reserved for the software guys, you know, the database guys.
And now they are available for everybody.
You know, the CEO, people in the finance department, in the marketing department, everybody in the
company can start making questions to the database.
It is really, really amazing.