0%
⭐ 0 XPMap
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

  1. Make a dict bots with two names, each with its own system prompt that starts You are and its name.
  2. Start with message = "Hello!". Loop 4 turns, swapping speaker each turn with turn % 2.
  3. Each turn, ask Pip as that bot, print Ada: Hello! I am Ada, a poet. (name, colon, reply), and make the reply the next message.
💡 Hint

names = list(bots). In the loop: name = names[turn % 2], reply = pip.ask(message, system=bots[name]), print(name + ": " + reply), then message = reply.

Ask the community

bot.py
Terminal
← BackNext →

Chapter 6: Party of Agents

The full quest map

Talk it out

  1. Read the instruction with the ✗ out loud.
  2. Say what your code does, line by line, as if to a friend.
  3. Find the line where what it does and what you want split apart.
  4. Press Run and read the terminal. Is that what you expected?
  5. Still stuck? Press Ask Pip why, or peek at the solution.
  6. Or ask on the community help board: say which quest, and paste your code.
New badge!

Your bot just got a new part. See it on the quest map.

Name your bot

It levels up as you play, and gets a new part with every chapter.