|
| 1 | +import os |
| 2 | +from pprint import pprint |
| 3 | + |
| 4 | +from typesafe_sdk import Choice, Noul, Score, TypeSafeClient |
| 5 | + |
| 6 | +client = TypeSafeClient( |
| 7 | + api_key=os.environ["OPENROUTER_API_KEY"], |
| 8 | + base_url="https://openrouter.ai/api", |
| 9 | +) |
| 10 | + |
| 11 | +QUESTIONS = { |
| 12 | + "desk": Choice( |
| 13 | + instructions="Where should the info desk send the visitor?", |
| 14 | + criteria={ |
| 15 | + "ticket_counter": "Buying, changing, or refunding tickets.", |
| 16 | + "lost_and_found": "Looking for something they lost.", |
| 17 | + "immediate_help": "An emergency, an injury, or a missing person.", |
| 18 | + }, |
| 19 | + ), |
| 20 | + "urgency": Score( |
| 21 | + instructions="How urgent is the request of the visitor?", |
| 22 | + criteria=[ |
| 23 | + "Not urgent at all.", |
| 24 | + "Should be handled today.", |
| 25 | + "Should be handled within the next few minutes.", |
| 26 | + "Needs to be handled right now.", |
| 27 | + ], |
| 28 | + ), |
| 29 | + "needs_assistance": Noul( |
| 30 | + instructions=( |
| 31 | + "Does the visitor need a staff member to help them get around " |
| 32 | + "the station, for example because of a wheelchair, heavy " |
| 33 | + "luggage, or small children?" |
| 34 | + ), |
| 35 | + ), |
| 36 | +} |
| 37 | + |
| 38 | + |
| 39 | +def main(): |
| 40 | + visitor_says = input("What does the visitor say? ") |
| 41 | + r = client.system_one( |
| 42 | + state={"visitor_says": visitor_says}, |
| 43 | + questions=QUESTIONS, |
| 44 | + ) |
| 45 | + pprint(r.model_dump()["answers"]) |
| 46 | + |
| 47 | + |
| 48 | +if __name__ == "__main__": |
| 49 | + main() |
0 commit comments