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

Function request_handler

python/examples/drawing/demo.py:35–53  ·  view source on GitHub ↗
(request: str)

Source from the content-addressed store, hash-verified

33 history: list[str] = []
34
35 async def request_handler(request: str):
36 print("[Sending request...]")
37 history.append(request)
38 result: Success[schema.Drawing] | Failure = await translator.translate("\n".join(history))
39 if isinstance(result, Failure):
40 print("Failure:", result.message)
41 else:
42 value: schema.Drawing = result.value
43 print(value)
44 if any(isinstance(item, schema.UnknownText) for item in value.items):
45 print("Unknown text detected. Please provide more context:")
46 for item in value.items:
47 if isinstance(item, schema.UnknownText):
48 print(" ", item.text)
49
50 canvas.delete("all")
51 render_drawing(canvas, value)
52 print("Click in drawing to continue...")
53 window.mainloop()
54
55 await process_requests("~> ", file_path, request_handler)
56

Callers

nothing calls this directly

Calls 2

render_drawingFunction · 0.90
translateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…