QueryEngine.py 712 B

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