Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| import random | |
| from config import SanatanConfig | |
| from modules.quiz.answer_validator import validate_answer | |
| from modules.quiz.quiz_helper import generate_question | |
| if __name__ == "__main__": | |
| while True: | |
| q = generate_question( | |
| collection=random.choice( | |
| [ | |
| s["collection_name"] | |
| for s in SanatanConfig.scriptures | |
| if s["collection_name"] != "yt_metadata" | |
| ] | |
| ), | |
| complexity=random.choice(["beginner", "intermediate", "advanced"]), | |
| mode=random.choice(["mcq", "open"]), | |
| preferred_lamguage="English", | |
| ) | |
| print(q.model_dump_json(indent=1)) | |
| print("Q:", q.question) | |
| print("Choices:", q.choices) | |
| print("Expected:", q.expected_answer) | |
| # Simulate user input | |
| user_ans = input("Your Answer: ") | |
| result = validate_answer(q, user_ans, preferred_language="English") | |
| print(result.model_dump_json(indent=2)) | |
| want_more = input("Want to keep playing? Y/N: ") | |
| if want_more == "N": | |
| break | |
| print("Game over!") | |