import os from huggingface_hub import InferenceClient def generate_quiz(topic: str, num_questions: int = 5, difficulty: str = "Intermediate") -> str: if not topic.strip(): return "Please enter a topic to generate a quiz." # Prepare the prompt prompt = f"""You are a professional quiz generator. Create a {difficulty.lower()}-level multiple-choice quiz on the following topic. Instructions: 1. Generate exactly {num_questions} questions related to the topic. 2. Each question should have 4 answer choices (A, B, C, D). 3. Only one answer choice should be correct for each question. 4. If any other task is mentioned, reply with "Invalid topic for quiz generation." 5. Ensure questions are clear and educational. Format: Question 1: A.