Spaces:
Sleeping
Sleeping
File size: 3,342 Bytes
c045254 | 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 | """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")
|