MCPcopy Create free account
hub / github.com/microsoft/TypeChat / main

Function main

python/examples/multiSchema/demo.py:23–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 print("The input did not match any registered agents")
22
23async def main():
24 env_vals = dotenv_values()
25 model = create_language_model(env_vals)
26 router = TextRequestRouter(model=model)
27
28 # register agents
29 math_agent = MathAgent(model=model)
30 router.register_agent(
31 name="Math", description="Calculations using the four basic math operations", handler=math_agent.handle_request
32 )
33
34 music_agent = MusicAgent(model=model, authentication_vals=env_vals)
35 await music_agent.authenticate()
36 router.register_agent(
37 name="Music Player",
38 description="Actions related to music, podcasts, artists, and managing music libraries",
39 handler=music_agent.handle_request,
40 )
41
42 coffee_agent = JsonPrintAgent(model=model, target_type=coffeeShop.Cart)
43 router.register_agent(
44 name="CoffeeShop",
45 description="Order Coffee Drinks (Italian names included) and Baked Goods",
46 handler=coffee_agent.handle_request,
47 )
48
49 calendar_agent = JsonPrintAgent(model=model, target_type=calendar.CalendarActions)
50 router.register_agent(
51 name="Calendar",
52 description="Actions related to calendars, appointments, meetings, schedules",
53 handler=calendar_agent.handle_request,
54 )
55
56 restaurant_agent = JsonPrintAgent(model=model, target_type=restaurant.Order)
57 router.register_agent(
58 name="Restaurant", description="Order pizza, beer and salads", handler=restaurant_agent.handle_request
59 )
60
61 sentiment_agent = JsonPrintAgent(model=model, target_type=sentiment.Sentiment)
62 router.register_agent(
63 name="Sentiment",
64 description="Statements with sentiments, emotions, feelings, impressions about places, things, the surroundings",
65 handler=sentiment_agent.handle_request,
66 )
67
68 # register a handler for unknown results
69 router.register_agent(name="No Match", description="Handles all unrecognized requests", handler=handle_unknown)
70
71 async def request_handler(message: str):
72 await router.route_request(message)
73
74 file_path = sys.argv[1] if len(sys.argv) == 2 else None
75 await process_requests("🔀> ", file_path, request_handler)
76
77
78if __name__ == "__main__":

Callers 1

demo.pyFile · 0.70

Calls 8

register_agentMethod · 0.95
authenticateMethod · 0.95
create_language_modelFunction · 0.90
TextRequestRouterClass · 0.90
MathAgentClass · 0.90
MusicAgentClass · 0.90
JsonPrintAgentClass · 0.90
process_requestsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…