Files
PastpaperMaster/backend/regen_comp2711h_trio.py
Zhao 10fa2b74ef feat: guest access, pricing modal, UI polish, LaTeX prompt fix
- Remove login gate, allow guest browsing with Sign in link
- Add favicon (book logo)
- Add pricing modal (Free/Standard/Exam) with hover animations
- Dynamic course list from DB instead of hardcoded
- Enforce LaTeX in AI trio generation prompt
- UI improvements: homepage animations, analytics donut chart, error book cards
- Fix error book locked state for guests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 18:40:22 +07:00

48 lines
1.5 KiB
Python

"""
One-off script: clear AI trio for COMP2711H paper and regenerate with LaTeX-enforced prompt.
Run inside the backend Docker container or locally with .env loaded.
"""
import asyncio
import json
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
from dotenv import load_dotenv
load_dotenv(os.path.join(os.path.dirname(__file__), "..", ".env"))
from app.services.supabase_client import get_supabase
from app.services.paper_processor import _resume_ai_trio
PAPER_ID = "5ee87a62-65bf-4952-be40-fcdf9ba7ca63" # COMP2711H 2025 fall final
async def main():
sb = get_supabase()
# 1. Clear existing AI trio fields so _resume_ai_trio will regenerate them
questions = sb.table("paper_questions").select("id, question_number, solution").eq("paper_id", PAPER_ID).execute().data
print(f"Found {len(questions)} questions for paper {PAPER_ID[:8]}")
cleared = 0
for q in questions:
if q.get("solution"):
sb.table("paper_questions").update({
"knowledge_reminder": "",
"ai_hint": "",
"solution": "",
}).eq("id", q["id"]).execute()
cleared += 1
q["solution"] = None # so _resume_ai_trio picks it up
print(f"Cleared AI trio for {cleared} questions. Regenerating...")
# 2. Regenerate
await _resume_ai_trio(sb, PAPER_ID, questions)
print("Done! AI trio regenerated with LaTeX-enforced prompt.")
if __name__ == "__main__":
asyncio.run(main())