Okay.
So in this first lesson we are going to introduce the OpenAI API.
We are going to work in a similar way than the way we have used in previous blocks.
So we are going to divide our screen and we will be able to show the slides you have and also the notebooks
you have in the attached documentation.
So.
First things to say, uh, about, uh, the OpenAI API.
Remember that one of the reasons a long chain became popular initially is that it was seen as a simpler
and more plural alternative to OpenAI's API.
So when OpenAI launched ChatGPT in November 2022, the artificial intelligence engineers went to the
OpenAI API.
And what we saw there is this is difficult to learn.
At the same time, land changed very, very quickly, offered us an easier way to learn about TLM applications
and also a way to work with multiple LM models, not just ChatGPT, but other alternatives.
So most of us, we said, okay, Lansing seems very interesting.
You know, it's a it's a faster, quicker, easier way to use ChatGPT in our applications.
Excellent.
But this trend might change due to three factors.
First.
Until now, OpenAI's ChatGPT model is by far the most used.
So at this moment, the value of land chain as a multimodal framework virtually makes no sense.
So the second advantage of land chain, the first one is okay, it's it's easier.
It's simple.
But the second advantage is okay, I can use land chain for different LM models.
If I learn in the OpenAI API, it is only for this LM model.
If I want to use llama two or Mistral or Falcon, I will need to learn another API.
So why not use land chain that is able to communicate with all LM models, right?
But during the first year of LLM applications.
Virtually 99% of professional LLM applications are using ChatGPT.
So some AI engineers they want their.
So why use long chain or lambda index if I am not using different LM models, I am just using ChatGPT.
So why not just learn how to communicate directly with ChatGPT using the OpenAI API?
Second question with the adoption of the new long chain expression language.
Uh.
Persian lantern is becoming more complex.
So the first advantage of long chain was simplicity.
And now they are making their language more complex with the second version, what they call an gene
expression language.
So it's like Wu and Chen is not so easy anymore.
And at the same time.
At the Deaf Day in November 2023.
OpenAI has launched a simpler and more versatile version of its API.
So one.
ChatGPT is used in 99% of applications.
Two.
OpenAI API is more simple and more versatile than ever.
If you consider these two factors, you will probably jump into OpenAI API.
But there is a another factor.
In my opinion, this is the most important one you need to have in mind.
OpenAI has decided to close part of their API.
So.
Do you remember?
I think we have been talking about that before.
Do you remember when Apple launched a their computers?
Apple computers were the only computers you couldn't open.
So with any other PC personal computer, you could open the the computer and change different parts,
etc. and extend your computer with the Apple computers.
You couldn't do that.
It was impossible.
They close, uh, the it was impossible to look under the hood if you if you want.
This is the same thing that engineers are finding with OpenAI.
Some parts of the OpenAI API are closed.
Do you remember when we talked about the llama index?
And I told you the most interesting part of llama index is the optimizing section.
This is what you cannot do with OpenAI, and that is the main reason why artificial intelligence engineers
are hesitant to use the OpenAI API.
And this is our impression, of course.
What we are feeling is that a most engineers are saying, no, no, no, I prefer to have a higher degree
of control of my applications using long chain or a lambda index.
Because until now, a OpenAI, the OpenAI API is perceived a more closed to engineers.
So it is important for you to understand that just because the OpenAI API, excuse me, can do something
does not mean it is the best way to do it.
Because one it is closed in some areas.
Two it can be very expensive.
And.
I would say these are the two main reasons.
One.
Using the new functionalities of OpenAI implies having a lesser degree of knowledge and control over
the settings.
To using the new functionalities of OpenAI can be very expensive.
So with that in mind.
Sometimes OpenAI A has been the choice.
I would say many times OpenAI API has been the choice of artificial intelligence engineers during 2023.
So it is very important for you to pay attention at this API and to see if in the future things are
going to change, or if, depending on the characteristics of your project, this is going to be the
best choice for you.
So in this initial lesson, we are a taking a quick look at the API.
We.
In this initial lesson, we are going to present the main changes that OpenAI has introduced in the
API since the dev day of November 2023, as well as their impact for developers of LM applications.
In the next lesson, we will.
Do a little, uh, a brief review of OpenAI's API as a whole.
And in the last lesson, we are going to talk about one of the elements of the API, which is the most
used or has been the most used during the first year, which is the OpenAI functions.
Okay.
So one important thing.
As we did with Lama index.
The the approach that we are recommending you is to go directly to open AI documentation.
This is the this is the way we we do.
This is how we work.
Uh, on a daily basis as artificial intelligence engineers.
And this is what you should do as well if you learn a framework by online courses.
It.
Your knowledge is going to become obsolete very early, especially with these kinds of new frameworks.
They are evolving on a daily basis.
So the best thing you can do is first, and this is why we must do with most AI engineers do this.
We go to a course, we get an introduction from the course, we get the main concepts from the course,
we get some main examples from the course.
And then we go into the frameworks documentation and we dig deeper and we practice practice practice
from the frameworks documentation okay.
So these lessons we have extracted for you are just a soft landing into the main documentation okay.
To make it easier for you that approach.
But our recommendation and our teaching to the future artificial intelligence engineers is use this
approach if you want.
It is easier.
What is the problem with the documentation, uh, of the frameworks I we told you before with Lama index,
usually they are very technical.
So usually it is very difficult and ugly to go there, uh, for the first time.
So it is more friendly to go to a simple course, you know, just to understand the main, the main
concepts of the framework.
And then after that you go into the framework documentation itself.
This is what I do 99% of the times, and this is the way I recommend you to do as well.
So first approach to the OpenAI.
The main changes introduced by OpenAI in November 2023.
You have here a list.
And in this notebook you already have, you have some examples regarding that.
So first thing, they announce that the context window of ChatGPT is going to increase and it's going
to be a longer than ever.
You can now upload one full book up to 300 pages and make questions about it.
Excellent.
It's like a Rag application, right?
But what is the trick?
You can do this if you have the ChatGPT for turbo version, which is right now a very expensive version.
So do you remember when I told you that OpenAI.
Receive an investment of $10,000 million from Microsoft, and that this, of course, creates a dependency
there.
So OpenAI, some of the moves that OpenAI is doing is, is they are signaling the big enterprise companies
as customers and users.
So they say, yes, we have a much better context window, but it's going to be for our big customers.
So this is interesting in some cases.
GPT three five has also, you know, uh, better context window now, but very far from the GPT four
turbo.
Second, uh, interesting thing, uh, before the last API version, you have to work with OpenAI functions
one by one.
Now you can call multiple multiple functions at once.
Here you have an example.
This is this is the most interesting functionality of the this API right now.
A OpenAI functions give you the ability to.
Basically define what do you want ChatGPT to do?
So in the functions you are.
Defining whatever you want to do on top of the default functionality of ChatGPT.
So this has a huge potential, and this has been very, very interesting for AI engineers during this
first year.
We are still in a very early stage, but this is super interesting.
This you can do this from long chain and lambda index, but at the end of the day they are using the
functionality of OpenAI.
So I recommend you and I will repeat this in the third lesson.
I will recommend you to study this section here.
Function calling.
Because there you are going to find very interesting examples as well.
So now function calling can be multiple.
Now you can uh, convert their uh answers of ChatGPT into Json format.
If you remember, this is something we could do with long chain and lambda index.
Do you remember.
So as you can see, OpenAI is entering in the space of long chain and laminar.
So OpenAI OpenAI is saying, oh, so people are using long chain Alma index because of this?
No, I'm going to make it available from my API.
So they are threatening a long chain and Lamar index with this kind of moves.
Another thing assistance OpenAI is calling assistance a what long chain is calling agents.
Why these different names?
Probably because a OpenAI doesn't want to associate themselves with the hype around agents.
So during the first year of applications, agents were a little bit, I would say a.
Um, I think they generated a little frustration because the expectations were extremely high.
Uh, frameworks like Island Chain told you you can do whatever you want with agents, but this was only
for demos.
If you want to go into professional, uh, applications, it's too early for agents.
So it it has created a little degree of frustration.
And maybe because of that, uh, OpenAI has decided to use a different name, so they call it assistance.
Very interesting.
The documentation you are going to find in the, in the, in the, uh, OpenAI documentation about assistance.
Very interesting.
A little bit too early, but they are and they are, uh, presenting some very interesting use cases
there regarding the C parameter.
Well, we mention it here.
Uh, in my opinion, it's not very, uh, significant.
The, the well, take a look at the, the examples we provide you here in the notebook about the assistance
and the rag assistant, etc., with the, with the seed.
Uh, I is not here.
Let's see.
Thing is.
Uh, yeah, with the seed parameter.
If you are familiar with traditional machine learning, probably you are familiar with the seed parameter
there.
So we use the seed parameter in order to fix the random, uh, element of our machine learning exercise.
OpenAI is trying to do the same thing here is not 100% reliable, but most of the time it works, so
it's good for testing.
Just a quick note about that.
In my opinion, it's not very relevant right now for you.
But we we we made this note here.
And finally, uh, some of the new things OpenAI has introduced in the API is more versatility.
And regarding multimodality.
So you will find here some interesting things about vision.
Speech, text to speech, etc..
Right?
So this is another interesting point.
In the next lesson, we are going to talk in more detail about the API of OpenAI.