(request:string)
| 47 | } |
| 48 | |
| 49 | async function routeRequest(request:string): Promise<void> { |
| 50 | const initClasses = JSON.stringify(router._taskTypes, undefined, 2); |
| 51 | const fullRequest = ` |
| 52 | Classify "${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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…