Spaces:
Sleeping
Sleeping
| """Pydantic schemas for adaptive learning path endpoints.""" | |
| from pydantic import BaseModel, ConfigDict, Field | |
| class LearningPathStep(BaseModel): | |
| """A single step in a learning path.""" | |
| step_number: int = Field(..., ge=1, description="Step order in the path") | |
| lo_id: str = Field(..., description="Learning outcome ID") | |
| title: str = Field(..., description="Learning outcome title") | |
| grade: int = Field(..., ge=6, le=8, description="Grade level") | |
| subject: str = Field(..., description="Subject name") | |
| chapter: str = Field(..., description="Chapter name") | |
| difficulty: str = Field(..., description="Difficulty level") | |
| bloom_level: str = Field(..., description="Bloom taxonomy level") | |
| # Student-specific context | |
| current_mastery: float = Field(..., ge=0.0, le=1.0, description="Student's current mastery score") | |
| mastery_label: str = Field(..., description="Student's mastery label") | |
| is_prerequisite: bool = Field(..., description="Whether this is a prerequisite for the target") | |
| estimated_study_time: int = Field(..., ge=0, description="Estimated study time in minutes") | |
| # Reasoning | |
| reason: str = Field(..., description="Why this step is recommended") | |
| class LearningPathRequest(BaseModel): | |
| """Request for adaptive learning path generation.""" | |
| model_config = ConfigDict(extra="forbid") | |
| student_id: str = Field(..., description="Student ID") | |
| target_lo_id: str = Field(..., description="Target learning outcome ID") | |
| max_steps: int = Field(default=10, ge=1, le=20, description="Maximum number of steps in path") | |
| include_mastered: bool = Field(default=False, description="Include already mastered LOs for review") | |
| difficulty_preference: str = Field(default="adaptive", description="Difficulty preference: easy, medium, hard, adaptive") | |
| class LearningPathResponse(BaseModel): | |
| """Response for adaptive learning path generation.""" | |
| model_config = ConfigDict(extra="forbid") | |
| student_id: str = Field(..., description="Student ID") | |
| target_lo_id: str = Field(..., description="Target learning outcome ID") | |
| model_version: str = Field(default="adaptive_path_v2_baseline_001", description="Service version") | |
| source: str = Field(default="knowledge_graph_traversal", description="Path generation method") | |
| timestamp: str = Field(..., description="Response timestamp") | |
| # Path details | |
| learning_path: list[LearningPathStep] = Field(..., description="Ordered learning steps") | |
| total_steps: int = Field(..., ge=0, description="Total number of steps") | |
| estimated_total_time: int = Field(..., ge=0, description="Total estimated study time in minutes") | |
| # Student context | |
| current_overall_mastery: float = Field(..., ge=0.0, le=1.0, description="Student's overall mastery") | |
| weak_prerequisites: list[str] = Field(default_factory=list, description="Weak prerequisite LO IDs") | |
| # Path metadata | |
| path_difficulty: str = Field(..., description="Overall path difficulty") | |
| completion_probability: float = Field(..., ge=0.0, le=1.0, description="Estimated completion probability") | |
| # Recommendations | |
| next_action: str = Field(..., description="Immediate next action for student") | |
| teacher_notes: str = Field(..., description="Notes for teacher intervention") | |