Spaces:
Runtime error
Runtime error
Download src/schemas.py from TrueTensor/Vidya-V3-Tutor: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/spaces/TrueTensor/Vidya-V3-Tutor/resolve/main/src/schemas.py
- Command line
-
hf download hf://spaces/TrueTensor/Vidya-V3-Tutor/src/schemas.py
-
curl -L -o schemas.py https://huggingface.co/spaces/TrueTensor/Vidya-V3-Tutor/resolve/main/src/schemas.py
1.7 kB
| """ | |
| schemas.py β Pydantic models for session config and tutor output validation. | |
| """ | |
| from typing import Literal | |
| from pydantic import BaseModel, Field, field_validator | |
| # ββ Session Configuration (set once at startup) ββββββββββββββββββββββββββββββ | |
| class SessionConfig(BaseModel): | |
| skill_topic: str = Field(..., min_length=1) | |
| mastery_level: float = Field(..., ge=0.0, le=1.0) | |
| icp_type: Literal["low_wage", "high_wage"] | |
| ca_phase: Literal["MODEL", "COACH", "SCAFFOLD", "FADE"] | |
| language_preference: Literal["en", "hi", "mixed"] | |
| def topic_not_empty(cls, v: str) -> str: | |
| if not v.strip(): | |
| raise ValueError("skill_topic cannot be blank") | |
| return v.strip() | |
| # ββ Official Tutor Output (Gemini must return this) ββββββββββββββββββββββββββ | |
| class TutorOutput(BaseModel): | |
| tutor_response: str = Field(..., min_length=1) | |
| updated_ca_phase: Literal["MODEL", "COACH", "SCAFFOLD", "FADE"] | |
| on_topic_flag: bool | |
| suggested_next_action: str = Field(..., min_length=1) | |
| # ββ Fallback output when Gemini returns invalid JSON βββββββββββββββββββββββββ | |
| def fallback_output(current_phase: str) -> dict: | |
| return { | |
| "tutor_response": ( | |
| "I had a small hiccup processing that. " | |
| "Could you rephrase your question? I'm here to help!" | |
| ), | |
| "updated_ca_phase": current_phase, | |
| "on_topic_flag": True, | |
| "suggested_next_action": "Please try rephrasing your message.", | |
| } | |