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

Function request_handler

python/examples/music/demo.py:17–34  ·  view source on GitHub ↗
(message: str)

Source from the content-addressed store, hash-verified

15 player_context = await get_client_context(env_vals)
16
17 async def request_handler(message: str):
18 result = await translator.translate(message)
19 if isinstance(result, Failure):
20 print(result.message)
21 else:
22 result = result.value
23 print(json.dumps(result, indent=2))
24 try:
25 for action in result["actions"]:
26 await handle_call(action, player_context)
27 except Exception as error:
28 print("An exception occurred: ", error)
29
30 if any(item["actionName"] == "Unknown" for item in result["actions"]):
31 print("I did not understand the following")
32 for item in result["actions"]:
33 if item["actionName"] == "Unknown":
34 print(item["text"])
35
36 file_path = sys.argv[1] if len(sys.argv) == 2 else None
37 await process_requests("🎵> ", file_path, request_handler)

Callers

nothing calls this directly

Calls 2

handle_callFunction · 0.90
translateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…