Bots often need answers they can read, not just chat. So we ask the model for JSON: text written like a Python dictionary. json.loads() turns it into a real dict.
import json
text = '{"hp": 10, "class": "mage"}'
hero = json.loads(text)
print(hero["class"])mage
Ask Pip for JSON and it answers with its mood and battery.
import json (next to import pip).pip.ask("Give me your mood as JSON") in reply.json.loads(reply) and store it in data.data["mood"].data = json.loads(reply) makes a dict. Then data["mood"] reads one value out of it.
import pip
import json
reply = pip.ask("Give me your mood as JSON")
data = json.loads(reply)
print(data["mood"])Press "Talk it out" at the top. Our Discord opens soon; until then email us and paste your code.