File size: 2,168 Bytes
fc7db98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29ad923
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from __future__ import annotations

from pydantic import BaseModel, Field


class PredictRequest(BaseModel):
    sentence: str = Field(..., min_length=1)
    target_word: str = Field(..., min_length=1)


class PredictResponse(BaseModel):
    complexity_level: str
    level_id: int
    level_probs: dict[str, float]
    difficult_class_prob: float
    reason: str | None
    reason_id: int | None
    reason_probs: dict[str, float] | None
    latency_ms: float
    target_in_sentence: bool


class InterveneRequest(BaseModel):
    sentence: str
    target_word: str
    reason: str
    use_llm: bool = False


class InterventionDetail(BaseModel):
    reason: str
    original_sentence: str
    edited_sentence: str
    edit_method: str
    before_level: str
    after_level: str
    hardness_drop: float
    matches_predicted: bool | None = None


class InterveneResponse(BaseModel):
    intervention: InterventionDetail


class InterveneAllRequest(BaseModel):
    sentence: str
    target_word: str
    predicted_reason: str | None = None
    use_llm: bool = False


class InterveneAllResponse(BaseModel):
    base_level: str
    results: list[InterventionDetail]
    best_reason: str
    faithful: bool | None


class EfficiencyRequest(BaseModel):
    sentence: str
    target_word: str
    local_latency_ms: float = Field(..., ge=0)


class EfficiencyResponse(BaseModel):
    local_latency_ms: float
    ai_latency_ms: float
    ai_provider: str
    ai_cost_usd: float
    ai_cost_per_1k_usd: float
    local_cost_usd: float
    speedup_factor: float


class HealthResponse(BaseModel):
    status: str
    model_path: str
    model_ready: bool
    model_error: str | None = None


class AlterComplexityRequest(BaseModel):
    sentence: str = Field(..., min_length=1)
    target_word: str = Field(..., min_length=1)
    reason: str = Field(..., min_length=1)
    direction: str = Field(..., pattern="^(increase|decrease)$")


class AlterComplexityResponse(BaseModel):
    reason: str
    direction: str
    original_sentence: str
    original_target_word: str
    new_sentence: str
    new_target_word: str
    edit_method: str
    explanation: str
    updates: str