Chapter 6 · Quest 1 of 4 · 10 XP
Two Heads
👯 One bot is good. Two bots talking is a party. Each bot is the same model with a different system prompt, and each bot's reply becomes the other one's next message.
import pip
print(pip.ask("Hello!", system="You are Ada, a poet."))Hello! I am Ada, a poet.
list(bots) gives you the names in a dict. To switch speaker each turn, use turn % 2: it gives 0, 1, 0, 1... because % is the remainder after dividing by 2.
Instructions
- Make a dict
botswith two names, each with its own system prompt that startsYou areand its name. - Start with
message = "Hello!". Loop 4 turns, swapping speaker each turn withturn % 2. - Each turn, ask Pip as that bot, print
Ada: Hello! I am Ada, a poet.(name, colon, reply), and make the reply the nextmessage.
💡 Hint
names = list(bots). In the loop: name = names[turn % 2], reply = pip.ask(message, system=bots[name]), print(name + ": " + reply), then message = reply.
bot.py
Terminal