From the course: Hands-On OpenAI API: Building a Real-World Solution
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Running and testing the conversation thread - OpenAI API Tutorial
From the course: Hands-On OpenAI API: Building a Real-World Solution
Running and testing the conversation thread
- [Instructor] We've just created a new thread and added a message to it. In fact, I can continue adding messages to the thread, but nothing will happen until I run it. So, let's do that next. Here, I want to specify a new variable named run, and I want to execute client.beta.threads.runs. And I want to use the create function. Here, I need to specify the thread ID and the assistant ID. Remember that we have both objects, here and in this other place. Okay, so to expedite this process, I'm going to paste this code, because I need to verify and inspect the latest status of that drawn object. The thing about the run object is that it'll be executed asynchronously. Therefore, we need to periodically check and retrieve its latest status in a polling manner. Okay, so I need to import time. And this is because I have that time.sleep(2). This will allow the program to wait for a couple of seconds, before asking for the newer status. And finally, I'm retrieving all the messages that are…