Add memory coach, transformer recall model, and training FAB.

Introduce Q/K/V memory dialogue with coach APIs, a lightweight NumPy
transformer for per-word forgetting prediction, and a floating training
menu linking daily quiz, spell, and coach flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
John
2026-06-04 18:11:49 -07:00
parent 59aeb9aed3
commit c1a6a105ef
26 changed files with 2030 additions and 78 deletions
+74
View File
@@ -233,3 +233,77 @@ class SettingsUpdate(BaseModel):
daily_target: Optional[int] = Field(None, ge=1, le=100)
master_required_count: Optional[int] = Field(None, ge=1, le=20)
weak_wrong_threshold: Optional[int] = Field(None, ge=1, le=20)
# Memory coach (Q/K/V dialogue)
class MemoryToken(BaseModel):
role: str
key: str
label: str
value: str
revealed: bool = False
class CoachWordBrief(BaseModel):
word_id: int
zh: str
phonetic: Optional[str] = None
retention_now: float
mastery_score: int
status: str
class CoachSessionResponse(BaseModel):
words: list[CoachWordBrief]
total: int
class CoachTurnRequest(BaseModel):
word_id: int
stage: str = "intro"
user_message: str = ""
hints_used: int = Field(0, ge=0, le=20)
duration_seconds: Optional[int] = Field(None, ge=0, le=3600)
class MemoryTransformerCurvePoint(BaseModel):
hours_ahead: float
recall_percent: float
forgetting_percent: float
class MemoryTransformerAttention(BaseModel):
index: int
label: str
weight: float
class MemoryTransformerPredictResponse(BaseModel):
word_id: int
en: str
recall_now_percent: float
formula_recall_percent: float
model_recall_percent: float
blend_weight: float
event_count: int
model_trained: bool
recommended_review_days: int
half_life_hours: Optional[float] = None
curve: list[MemoryTransformerCurvePoint]
attention_hint: list[MemoryTransformerAttention]
class CoachTurnResponse(BaseModel):
assistant_messages: list[str]
tokens: list[MemoryToken] = []
stage: str
expect_input: bool
prompt_zh: str = ""
prompt_phonetic: Optional[str] = None
input_hint: str = "请输入对应的英文单词"
is_correct: Optional[bool] = None
quiz_recorded: bool = False
word_complete: bool = False
hints_used: int = 0
target_en: Optional[str] = None
target_zh: Optional[str] = None