Spaces:
Running
Running
def prompts(data: str) -> tuple[str, str]: | |
""" | |
System and User prompts for a quiz question generation task. | |
Args: | |
data (str): The input data string containing factual or conceptual information. | |
Returns: | |
tuple[str, str]: A tuple containing the system prompt and the user prompt. | |
""" | |
if not isinstance(data, str): | |
raise ValueError("Input data must be a string.") | |
if not data.strip(): | |
raise ValueError("Input data cannot be an empty string.") | |
data = data.strip() | |
json_example = r""" | |
{"quiz": [ | |
{"question": "What is the capital of France?", | |
"type": "single_choice", | |
"options": ["Paris", "London", "Berlin", "Madrid"], | |
"answer": "Paris" | |
}, | |
{"question": "Select all the programming languages:", | |
"type": "multiple_choice", | |
"options": ["Python", "HTML", "Java", "CSS"], | |
"answer": ["Python", "Java"] | |
}, | |
{"question": "The sky is blue. (True/False)", | |
"type": "true_false", | |
"answer": "True" | |
}, | |
{"question": "________ is known as the Red Planet.", | |
"type": "fill_in_the_blank", | |
"answer": "Mars" | |
} | |
] | |
} | |
""" | |
system_prompt = f""" | |
You are a Quiz Question Generator AI. Your task is to read and understand the provided input data (a plain text string containing factual or conceptual information), and generate a set of quiz questions based on it. | |
The questions should: | |
- Be clear, relevant, and varied in format (e.g., multiple choice, single choice, true/false, fill-in-the-blank, etc.). | |
- Be phrased in a way that tests comprehension, recall, or reasoning based on the input data. | |
- Include 3 to 4 answer options where applicable (e.g., multiple/single choice). | |
- Clearly indicate the correct answer(s). | |
Return your output in **valid raw JSON format** using the following structure: | |
```json | |
{json_example} | |
``` | |
Additional Guidelines: | |
Ensure the question and answer pair is clearly and correctly based on the input data string. | |
Do not hallucinate facts that are not present in the provided data. | |
Keep the language simple and clear. | |
Avoid repetition across questions. | |
Only return the JSON structure as your final output. Do not include any commentary or explanation. | |
""" | |
user_prompt = f""" | |
Please generate a set of quiz questions based on the following data: | |
{data} | |
Return the questions in JSON format as described, including the correct answers for each. Use a variety of question types such as multiple choice, single choice, true/false, and fill-in-the-blank. | |
""" | |
return system_prompt.strip(), user_prompt.strip() | |