Models don't remember anything on their own. To hold a conversation, your bot keeps a message history: a list of every message so far, sent in full each time.
messages = []
messages.append({"role": "user", "content": "Hi!"})
reply = pip.chat(messages)
messages.append({"role": "assistant", "content": reply})Each message is a dict with a role (who said it) and content (what they said). pip.chat() reads the whole list and answers the last user message. That's memory, the simple way. Finish this one for your second badge.
messages = []talk. Each time, add {"role": "user", "content": text} to messages.pip.chat(messages) in reply, print it, and add it as {"role": "assistant", "content": reply}.messages holds 6 messages and Pip says Your name is Sam.for text in talk: append the user message, then reply = pip.chat(messages), print(reply), then append the assistant message. All 4 lines indented inside the loop.
import pip
talk = ["Hi!", "My name is Sam.", "What is my name?"]
messages = []
for text in talk:
messages.append({"role": "user", "content": text})
reply = pip.chat(messages)
print(reply)
messages.append({"role": "assistant", "content": reply})Press "Talk it out" at the top. Our Discord opens soon; until then email us and paste your code.