Home Page
cover of fwaexopenaiassistance - Made with Clipchamp
fwaexopenaiassistance - Made with Clipchamp

fwaexopenaiassistance - Made with Clipchamp

Sumit So

0 followers

00:00-07:50

Nothing to say, yet

Voice Overspeechgaspnarrationmonologuemale speech
2
Plays
0
Downloads
0
Shares

Audio hosting, extended storage and much more

AI Mastering

Transcription

You can use OpenAI Playground or OpenAI APIs to configure and interact with OpenAI Assistant. If you create an Assistant in the Playground, you can use it in the APIs, and vice versa. To create an Assistant, go to the sidebar and click on "Create". You can customize the Assistant by adding a name, instructions, models, and tools. There are three components to the Assistant API: Assistant, thread, and runs. You can test the Assistant by asking questions and checking the logs in the runs component. The Assistant can provide information on different weather conditions, but it does not have real-time capabilities. You can use tools like function calling to improve the response. The Assistant API can be implemented using JavaScript or Python code. The code creates the Assistant, thread, adds a message to the thread, runs the Assistant, and displays the response. More details and examples can be found in the provided repository. One thing we all know that is configure and interact with OpenAI Assistant. We can use OpenAI Playground or we can use OpenAI APIs and they are interchangeable. If you are creating Assistant using OpenAI Playground, then you can use that same Assistant in OpenAI APIs. And if you have created Assistant using OpenAI APIs, you can test that Assistant in OpenAI Playground. And let's see how we can create Assistant here. So in sidebar, you'll find this Assistant. Here you'll see list of all the Assistant you have created. And in order to create new Assistant, you can click this button, create. And these are all the configuration we have already discussed. You need to pass the name, instructions and the models. You can select any model you want and the tools. And these tools help us to improvise the response. So I have already created one Assistant. Let's see how it works and how we can improvise it. So this is the Assistant weather report and it is going to answer queries related to the weather in short statements. And if you click this test button, it will head over to Platform Playground. So this is Platform Playground. And here we have a list of all the Assistant we have created. I already talked about the different components of Assistant API. We have three components. One is Assistant itself. Another is thread. So this is one thread open in our platform, open in our Playground. And the third component is runs. So let's see. Let's start by asking a very simple question. Let's ask something like, what are different weather conditions? When I click this button, add and runs, it is going to pass this entire thread to the runs component. When you click this add and runs and you can see all the logs here in runs. So it is passing this entire thread to this runs. When I click this clear button, it is going to remove this thread. OK, we'll see all these steps using the APIs when we deal with code. OK, so it is returning me this answer. Different weather conditions include, you know, these are different weather conditions. Now, let's ask something which this model is not aware of. OK, so let me ask a different question. Let's say, tell me current weather in New Delhi. Because this model do not have current information. When I click this add and run, it is going to return the response. Let's wait. So it is returning us. Sorry, as an AI model, I don't have real time capabilities. So we can improvise this response. What we can do, we can use any of these tools. We can pass some sort of file if we have current data or we can use function calling. OK, I have a dedicated video on function calling, but let's see how function calling works. So in function calling, we are going to define a function and our model going to extract those parameters which are relevant for us. And we can fire that function or we can say we can dispatch that function from our software. Let me give you one example. In previous video, we have seen this example. Here we have defined this function get current weather. So let's copy this definition. Here we can paste this definition. Click save. Now, if I ask a similar question, tell me current weather in New Delhi. When I click add and run. This time, as you can see, our model is saying that we need to dispatch this function get current weather because we are not building any software. So I do not have implementation of this function. But if you are, for example, you want to create a weather application where a user can type something and it is going to return a response. In that case, you can implement this function. OK, so this is how assistant APIs work. But, you know, this is the broad explanation of assistant API. Let's see how they actually work with the help of coding examples. First, let's see what this JavaScript code is doing. Then we will understand each individual piece. So in order to run this file, type node, AI, system, name of the file. As you can see, it is doing everything in steps. So first it is creating the assistant. Then it is creating thread. Then it is adding message to the thread and it is waiting for the response. And once we have a response, it is displaying that response. And here, what is what it is doing? It is also displaying this code because we have enabled the code interpreter tool while we are creating this assistant. Here, what we are doing, we are creating Python tutor and this code interpreter tool is enabled. That is why it was creating that code. Obviously, we can create we can display that response in nicer way if you are building any application. OK, so first what we have did, we have created this assistant and I have included all the endpoints in this readme file. OK, and OK, so first we have created the assistant like we did in in the playground. OK, once we have assistant, what we can do, we can get that assistant ID. So that is why I have defined this assistant ID on the top. And then I have assigned that assistant ID to this variable. And then we are going to create the thread. Now, these first four steps are making post requests because they are generating something. And the last two steps are making that request, as you can see in this repository. OK, so in this second step, we are creating a thread. And in third step, what we are doing, we are adding message to the thread with the help of thread ID. And in a fourth step, we are running that assistant by passing thread ID and the assistant ID. And finally, we are waiting for the response. Once we have response, we are displaying that response by making a get request to this endpoint. OK, so all these examples are there in this repository. You can check out that repository. And finally. Finally, we are displaying. So finally, we are getting this data from this response and we are displaying this data. So this is how everything works together. Now, let's see that Python file as well. And let's run this Python file. So let me copy that API key. OK, so I can run Python file by using this. As you can see, it is also doing the similar thing. So this is how we can implement all these steps.

Listen Next

Other Creators