As a developer, you want to leverage the latest model features, and the assistants API is one of them. Concretely, this API is a stateful evolution of the previous one, facilitating the creation of your new AI agents. This will add deepness to your very own. You need this AI toolkit and knowledge. This lesson will give you the opportunity to work with the new assistants API and test it with both function calling and the code to interpreter their features. It completes the variety of implementation patterns that will help you connect to SQL databases and create your own database agents. Okay, let's go and innovate. In lesson five we'll focus on the final part of this course and explore additional capabilities. We have deployed our instances of Azure, OpenAI, and LangChain, created agents for CSV and SQL and switched to using the function calling feature of Azure OpenAI in lesson four. We saw the function calling works well, allowing the system to leverage multiple functions. Now let's take a look at another functionality of Azure OpenAI. The assistants API. Previously, we use GPT-four with chat completions. The assistants API is different because it maintains the context of the discussion dynamically. Unlike chat completions, which are stateless. The assistants API is a stateful, meaning that it keeps track of the conversation. This is useful for scenarios like e-commerce, where maintaining context across interaction is important. Within the assistants API, we can also use function calling, similar to what we did in lesson four. Additionally, we will explore the code interpreter feature. The code interpreter feature allows the assistants API to handle Python code. It can run code iteratively, modifying it until the execution succeeds, which is very useful for complex tasks. The code interpreter feature is like an environment within your current environment, enabling the agent to modify its own code to find solutions. This lesson will help you explore the stateful capabilities of the assistants API and the code interpreter for dynamic and complex interactions. Let's head to our last notebook and get started. This time we'll keep it brief by combining previous configurations. We will execute everything together. We are recording the endpoint, loading the CSV data, and importing it into the SQL database. Similar to what we have done before. We will start by importing the helper function that contains some variables and functions used in lesson four. This is mainly to bring the tools SQL and the functions for hospitalization and positive cases defined in lesson four. What we are having here is the key. The endpoint and the version of the API. In this case, because we are using all the new functionalities, we are taking the latest one. And with this one, we are saying this okay, we have client which is the actual been the AI object. And we are creating an assistant an API assistant. And we are giving instruction which is your assistant in saying questions about for Covid dataset. We are talking about the model, and we are explaining the tools that are available for this assistant to play with, which are these tools that we have created before based on the function that we defined. And then and this is the second step already, because this is just a few lines of code. We have created a system. Then we create the thread. And these will create like the let's say like trace of the discussion. So we can correlate like we can connect the different messages and a user machine discussion. And the answer that we are getting is okay, we have an identifier for that thread that will be unique. It has been created this and this metadata. And this object is thread which once again is a specific to the assistants API. Now what do we do? You have an assistant, you have a discussion. I'll be adding a message. And this message will be from the user, right? From the user's perspective, they will be how many hospitalizations they were in Alaska for this and this and this. Very similar question to what we did before, but different way to implement it. We are identifying the thread. You see we have the identification here is part the discussion is a message within a thread. This message is from an user. With the value how many which the content how many hospitalizations we have here. We have printed the message. You want to see it in a proper way. And you can see the same. But we can see it like a json kind of dump and you can see all the information, but it is basically the same, right? We are saying data system that we have identification. We have this value. This is a text question. The city received some metadata. So that's good. Let's run the assistant on the thread. Right. We have already that preparation. We have told the system that we have some messages and some discussion going on. Let's run. This is done. This is like the way to set up your assistants API with the four steps that we have mentioned. Always the same, depending on the kind of functions and stuff that you have some the kind of questions, that's very fine. And now we will replicate what we did in listen four for the function calling. So basically we will be using function calling. But this time we will use it with the assistants API. And after that I will use the code interpreter okay. But let's focus first on the function calling. If we use the function calling. The dynamics is very similar to what we did before. We have already the function. We are explaining in this case that there is a thread that we are running something under ongoing discussion, because we launch it before this, the run that we had before waited to see standard to the thread and then once again the same. We are saying we have these available functions with this, this format, this arguments we need these kind of parameters, very similar to listen four. Right. And then we are running these on the thread and assistant and with the tools that we have. So let's run these. So you see for the test question that we have before because we pass it before like how many hospitalizations we have in Alaska is running the message under discussion and assistants. And is getting that answer is getting the answer that is saying there were three hospitalizations for Alaska on a specified date. You could print the json dump if you want to have like a better format of these. Now, the part is new is the use of the code interpreter. Remember, this code interpreter is like a sandbox within this kind of sandbox that you are using is a a code sandbox available on OpenAI and Azure OpenAI that will allow this system to run in an intelligent way the code for complex task, even allowing it to find a way to make it work. If the code is not good, it will iterate and find the way to make it work. And once again, this is incremental. This is on top of the things we have done before. We have already the assistants. We are creating basically a system with our model, which is the same one. And here you have tools. We are saying the type is called interpreter. So yes, we are using a system API, but then we are using specific kind of tool which is a code interpreter. Okay. That's good. And we are using our question hospitalizations in Alaska in 2021. So we will run the thread for the discussion. Same as before. But the incorporating the the tools, right. Incorporating the code interpreter. They are related to assistant and assistant to the run. What we are saying is we are still working on this. If the way I say literate in the system, this is still working, it hasn't been complete, cancel, expire or fail will be running these discussions on the thread. So you see the run, you see the threads, etcetera, etcetera, which is everything related to our assistant. We can print you want the json dumb with the result of the messages parameter, which is basically saying okay for these assistant ID on this thread discussion. Basically we are getting that on March 2021. There were like so many people hospitalized in Alaska due to Covid19. So, again very similar. We are getting the answer. In this case, what we are doing is to add the code interpreter, but the format of the answer is very similar. Just take some seconds, just analyze it is something that you will understand. It is some specific parameter that you understand. You can just copy it, check it on the official documentation of Azure OpenAI. And now let's conclude the class.