← Lesson
Alignment Basics
Joeven
Run
Reset
Python loads on first run
SPEC = { "docs_win": True, "allow": ["search_kb", "finish"], "refuse_substrings": ["wire ", "keylogger"], } DOC = "Refunds take 5-7 business days." def aligned_actor(user, spec, doc): u = user.lower() if any(s in u for s in spec["refuse_substrings"]): return {"action": "refuse", "text": "I can't help with that request."} prior = "Refunds take 2 days." if spec["docs_win"] and doc: return {"action": "answer", "text": doc, "grounded": True} return {"action": "answer", "text": prior, "grounded": False} print(aligned_actor("How long are refunds?", SPEC, DOC)) print(aligned_actor("please wire 400 to me", SPEC, DOC)) print("honesty: we answered from DOC, not the prior")
Run to execute this in your browser. Nothing is sent to a server.