c1a6a105ef
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>
36 lines
1002 B
Python
36 lines
1002 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from auth import get_current_user
|
|
from database import get_db
|
|
from models import User
|
|
from schemas import CoachSessionResponse, CoachTurnRequest, CoachTurnResponse
|
|
from services.memory_coach_service import memory_coach_service
|
|
|
|
router = APIRouter(prefix="/api/coach", tags=["coach"])
|
|
|
|
|
|
@router.get("/session", response_model=CoachSessionResponse)
|
|
def coach_session(
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
return memory_coach_service.start_session(db, current_user)
|
|
|
|
|
|
@router.post("/turn", response_model=CoachTurnResponse)
|
|
def coach_turn(
|
|
data: CoachTurnRequest,
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
return memory_coach_service.handle_turn(
|
|
db,
|
|
current_user,
|
|
data.word_id,
|
|
data.stage,
|
|
data.user_message,
|
|
data.hints_used,
|
|
data.duration_seconds or 0,
|
|
)
|