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

Function routeRequest

typescript/examples/multiSchema/src/router.ts:49–74  ·  view source on GitHub ↗
(request:string)

Source from the content-addressed store, hash-verified

47 }
48
49 async function routeRequest(request:string): Promise<void> {
50 const initClasses = JSON.stringify(router._taskTypes, undefined, 2);
51 const fullRequest = `
52Classify "${request}" using the following classification table:\n
53${initClasses}\n`;
54 const response = await router._taskClassifier.translate(request, [{
55 role: "assistant", content: `${fullRequest}`
56 }]);
57
58 if (response.success) {
59 if (response.data.taskType != "No Match") {
60 const agentName = response.data.taskType;
61 console.log(`🤖 The task will be handled by the ${agentName} Agent.`);
62 const agent = router._agentMap[agentName];
63 await agent.handleMessage(request);
64 }
65 else {
66 router._handlerUnknownTask(request);
67 }
68 }
69 else {
70 console.log("🙈 Sorry, we could not find an agent to handle your request.\n")
71 console.log(`Context: ${response.message}`)
72 }
73 return
74 }
75}

Callers

nothing calls this directly

Calls 2

handleMessageMethod · 0.80
translateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…