1. Learn
  2. /
  3. Courses
  4. /
  5. Working with the OpenAI API

Connected

Exercise

Creating an AI chatbot

To complete your POC, you'll integrate your message history with a for loop, so you can send repeated prompts to the model, storing each response in the message history in series.

Instructions

100 XP
  • Loop over the user messages (user_msgs).
  • Create a dictionary for the user message in each iteration, and append it to messages.
  • Send messages to the model in a chat request.
  • Append the assistant message dictionary to messages.