Spaces:
Running
Running
github-actions[bot] commited on
Commit ·
a715f01
1
Parent(s): c1d887c
🚀 Auto-deploy backend from GitHub (f3dbc1f)
Browse files
main.py
CHANGED
|
@@ -571,7 +571,7 @@ def _init_firebase_admin() -> None:
|
|
| 571 |
return None
|
| 572 |
|
| 573 |
try:
|
| 574 |
-
if not firebase_admin._apps: # type: ignore[
|
| 575 |
init_options: Dict[str, Any] = {}
|
| 576 |
credentials_obj: Optional[Any] = None
|
| 577 |
if FIREBASE_AUTH_PROJECT_ID:
|
|
@@ -3061,7 +3061,7 @@ async def predict_risk(student_data: StudentRiskData, response: Response):
|
|
| 3061 |
parsed = {"risk_label": "medium academic risk", "confidence": 0.5}
|
| 3062 |
|
| 3063 |
risk_label = str(parsed.get("risk_label", "medium academic risk"))
|
| 3064 |
-
confidence = float(parsed.get("confidence", 0.5))
|
| 3065 |
|
| 3066 |
risk_level = RISK_MAPPING.get(risk_label, "Medium")
|
| 3067 |
strict_risk_level = _to_strict_risk_level(risk_level)
|
|
@@ -4085,10 +4085,10 @@ def _sync_imported_students_to_teacher_dashboard(
|
|
| 4085 |
engagement = float(row.get("engagementScore") or 0.0)
|
| 4086 |
completion = float(row.get("assignmentCompletion") or 0.0)
|
| 4087 |
|
| 4088 |
-
state["scores"].append(avg_quiz)
|
| 4089 |
-
state["attendance"].append(attendance)
|
| 4090 |
-
state["engagement"].append(engagement)
|
| 4091 |
-
state["completion"].append(completion)
|
| 4092 |
if not state.get("weakestTopic"):
|
| 4093 |
state["weakestTopic"] = _pick_weakest_topic(row.get("unknownFields") or {})
|
| 4094 |
|
|
@@ -7825,7 +7825,7 @@ MAX_TOPICS_LIMIT = 12
|
|
| 7825 |
|
| 7826 |
class QuizGenerationRequest(BaseModel):
|
| 7827 |
topics: List[str] = Field(
|
| 7828 |
-
default=None,
|
| 7829 |
min_length=1,
|
| 7830 |
description="Specific math topics to cover (at least one required)",
|
| 7831 |
)
|
|
@@ -9195,11 +9195,11 @@ async def generate_lesson_plan(http_request: Request, request: LessonGenerationR
|
|
| 9195 |
|
| 9196 |
if retrieval_issues:
|
| 9197 |
source_legitimacy_report["status"] = "review_required"
|
| 9198 |
-
source_legitimacy_report["score"] = min(float(source_legitimacy_report.get("score") or 0.0), retrieval_confidence or 0.5)
|
| 9199 |
source_legitimacy_report.setdefault("issues", [])
|
| 9200 |
-
source_legitimacy_report["issues"] = list({*map(str, source_legitimacy_report.get("issues") or []), *retrieval_issues})
|
| 9201 |
source_legitimacy_report.setdefault("evidenceChecked", [])
|
| 9202 |
-
evidence_checked = list(source_legitimacy_report.get("evidenceChecked") or [])
|
| 9203 |
evidence_checked.extend([
|
| 9204 |
f"{chunk.get('source_file')} p.{chunk.get('page')}" for chunk in curriculum_chunks if chunk.get("source_file")
|
| 9205 |
])
|
|
@@ -9361,7 +9361,7 @@ async def generate_lesson_plan(http_request: Request, request: LessonGenerationR
|
|
| 9361 |
confidenceBand=retrieval_band,
|
| 9362 |
retrievedChunks=len(curriculum_chunks),
|
| 9363 |
needsReview=needs_review,
|
| 9364 |
-
issues=sorted({*(retrieval_issues or []), *(source_legitimacy_report.get("issues") or [])}),
|
| 9365 |
),
|
| 9366 |
gradeLevel=request.gradeLevel,
|
| 9367 |
classSectionId=request.classSectionId,
|
|
|
|
| 571 |
return None
|
| 572 |
|
| 573 |
try:
|
| 574 |
+
if not firebase_admin._apps: # type: ignore[union-attr]
|
| 575 |
init_options: Dict[str, Any] = {}
|
| 576 |
credentials_obj: Optional[Any] = None
|
| 577 |
if FIREBASE_AUTH_PROJECT_ID:
|
|
|
|
| 3061 |
parsed = {"risk_label": "medium academic risk", "confidence": 0.5}
|
| 3062 |
|
| 3063 |
risk_label = str(parsed.get("risk_label", "medium academic risk"))
|
| 3064 |
+
confidence = float(parsed.get("confidence", 0.5)) # type: ignore[arg-type]
|
| 3065 |
|
| 3066 |
risk_level = RISK_MAPPING.get(risk_label, "Medium")
|
| 3067 |
strict_risk_level = _to_strict_risk_level(risk_level)
|
|
|
|
| 4085 |
engagement = float(row.get("engagementScore") or 0.0)
|
| 4086 |
completion = float(row.get("assignmentCompletion") or 0.0)
|
| 4087 |
|
| 4088 |
+
state["scores"].append(avg_quiz) # type: ignore[union-attr]
|
| 4089 |
+
state["attendance"].append(attendance) # type: ignore[union-attr]
|
| 4090 |
+
state["engagement"].append(engagement) # type: ignore[union-attr]
|
| 4091 |
+
state["completion"].append(completion) # type: ignore[union-attr]
|
| 4092 |
if not state.get("weakestTopic"):
|
| 4093 |
state["weakestTopic"] = _pick_weakest_topic(row.get("unknownFields") or {})
|
| 4094 |
|
|
|
|
| 7825 |
|
| 7826 |
class QuizGenerationRequest(BaseModel):
|
| 7827 |
topics: List[str] = Field(
|
| 7828 |
+
default=None, # type: ignore[arg-type]
|
| 7829 |
min_length=1,
|
| 7830 |
description="Specific math topics to cover (at least one required)",
|
| 7831 |
)
|
|
|
|
| 9195 |
|
| 9196 |
if retrieval_issues:
|
| 9197 |
source_legitimacy_report["status"] = "review_required"
|
| 9198 |
+
source_legitimacy_report["score"] = min(float(source_legitimacy_report.get("score") or 0.0), retrieval_confidence or 0.5) # type: ignore[arg-type]
|
| 9199 |
source_legitimacy_report.setdefault("issues", [])
|
| 9200 |
+
source_legitimacy_report["issues"] = list({*map(str, source_legitimacy_report.get("issues") or []), *retrieval_issues}) # type: ignore[arg-type]
|
| 9201 |
source_legitimacy_report.setdefault("evidenceChecked", [])
|
| 9202 |
+
evidence_checked = list(source_legitimacy_report.get("evidenceChecked") or []) # type: ignore[arg-type]
|
| 9203 |
evidence_checked.extend([
|
| 9204 |
f"{chunk.get('source_file')} p.{chunk.get('page')}" for chunk in curriculum_chunks if chunk.get("source_file")
|
| 9205 |
])
|
|
|
|
| 9361 |
confidenceBand=retrieval_band,
|
| 9362 |
retrievedChunks=len(curriculum_chunks),
|
| 9363 |
needsReview=needs_review,
|
| 9364 |
+
issues=sorted({*(retrieval_issues or []), *(source_legitimacy_report.get("issues") or [])}), # type: ignore[misc]
|
| 9365 |
),
|
| 9366 |
gradeLevel=request.gradeLevel,
|
| 9367 |
classSectionId=request.classSectionId,
|