File size: 813 Bytes
fc7db98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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,
    )