QueryEngine.py
1 from __future__ import annotations 2 3 from .query_engine import QueryEnginePort 4 from .runtime import PortRuntime 5 6 7 class QueryEngineRuntime(QueryEnginePort): 8 def route(self, prompt: str, limit: int = 5) -> str: 9 matches = PortRuntime().route_prompt(prompt, limit=limit) 10 lines = ['# Query Engine Route', '', f'Prompt: {prompt}', ''] 11 if not matches: 12 lines.append('No mirrored command/tool matches found.') 13 return '\n'.join(lines) 14 lines.append('Matches:') 15 lines.extend(f'- [{match.kind}] {match.name} ({match.score}) — {match.source_hint}' for match in matches) 16 return '\n'.join(lines) 17 18 19 __all__ = ['QueryEnginePort', 'QueryEngineRuntime']