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

Connected

Exercise

Creating a conversation history

An online math learning platform called Easy as Pi has contracted you to help them develop an AI tutor. You immediately see that you can build this application by utilizing the OpenAI API, and start to design a simple proof-of-concept (POC) for the major stakeholders at the company to review.

To start, you'll demonstrate how responses to student messages can be stored in a message history, which will enable full conversations.

Instructions

100 XP
  • Send messages to the model in a chat request.
  • Extract the assistant message from response, convert it to a message dictionary, and append it to messages.