Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| import sys | |
| from app.config import REPO_ROOT | |
| from app.schemas import EfficiencyResponse | |
| def _ensure_path() -> None: | |
| if str(REPO_ROOT) not in sys.path: | |
| sys.path.insert(0, str(REPO_ROOT)) | |
| def compare_efficiency(sentence: str, target_word: str, local_latency_ms: float) -> EfficiencyResponse: | |
| _ensure_path() | |
| from ui.efficiency_panel import compare_query | |
| cmp = compare_query(sentence, target_word, local_latency_ms) | |
| return EfficiencyResponse( | |
| local_latency_ms=cmp.local_latency_ms, | |
| ai_latency_ms=cmp.ai_latency_ms, | |
| ai_provider=cmp.ai_provider, | |
| ai_cost_usd=cmp.ai_cost_usd, | |
| ai_cost_per_1k_usd=cmp.ai_cost_per_1k_usd, | |
| local_cost_usd=cmp.local_cost_usd, | |
| speedup_factor=cmp.speedup_factor, | |
| ) | |