A dialogue is a back-and-forth exchange between a user and a chat model. Its message history includes the latest message and any prior messages supplied as context. The model uses that history to generate a reply, so a follow-up can refer to an earlier request without repeating it. section 3.4 section 2.2
In Python, represent the history as a list of message dictionaries. Each message needs:
- A `role`: `user` for an input or `assistant` for a model reply. An optional `system` message can give general instructions, such as translating data-set questions into SQL queries. section 3.4
- A `content` value containing the message. Pass the list as `messages` when requesting a chat completion. section 3.4
Ask for a story
A first request can contain just `{'role': 'user', 'content': 'Tell me a story!'}`. In the ChatGPT interface, a later request can ask for a change to the answer without restating the original prompt. Starting a New Chat instead clears the prior dialogue steps from that conversation. section 3.4 section 2.2
Message histories also serve as fine-tuning examples. For movie-review classification, pair a user message containing a review with an assistant message containing the desired label, such as `neg`. A collection of these successful interactions can be written as JSON-lines training data. section 9.8
{'messages':[
{'role':'user', 'content':'I am willing to tolerate almost anything
...'},
{'role':'assistant', 'content':'neg'}
]}
This short history shows both sides of one desired interaction: a review as user input and its label as the assistant output. section 9.8









