From the course: Creating AI Applications with Python and GitHub Models

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Make changes to the code as required

Solution: Make changes to the code as required

(upbeat music) - [Lecturer] At the end of our previous solution video, the Python code for making calls to the open AI chat completion API didn't work. So let's try and fix our Python code. I can see that the error that we have is because we've used an older version of the chat completion from OpenAI. So we have the option of running OpenAI migrate and there are a couple of options available to us. So let me just go ahead and select this link and let me go ahead and try and find some code that will work for us. And so if I compare this code to what I had earlier, you can see that the problem seems to be that I'm using OpenAI chat completion.create. While as, what I actually need is client.chat.completions.create. And so let me just go ahead and copy this bit of code and let's head back to the code section here and let's replace this. So I've got to be a little bit careful here. So I'm going to go ahead and replace this with this code. So I'm going to use response as my variable name…

Contents