(self, line: str)
| 29 | self._current_agents[name] = agent |
| 30 | |
| 31 | async def route_request(self, line: str): |
| 32 | classes_str = json.dumps(self._current_agents, indent=2, default=lambda o: None, allow_nan=False) |
| 33 | |
| 34 | prompt_fragment = F""" |
| 35 | Classify ""{line}"" using the following classification table: |
| 36 | ''' |
| 37 | {classes_str} |
| 38 | ''' |
| 39 | """ |
| 40 | |
| 41 | result = await self._translator.translate(prompt_fragment) |
| 42 | if isinstance(result, Failure): |
| 43 | print("Translation Failed ❌") |
| 44 | print(f"Context: {result.message}") |
| 45 | else: |
| 46 | result = result.value |
| 47 | print("Translation Succeeded! ✅\n") |
| 48 | print(f"The target class is {result['task_kind']}") |
| 49 | target = self._current_agents[result["task_kind"]] |
| 50 | await target.get("handler")(line) |
no test coverage detected