Spaces:
Running
Running
File size: 2,828 Bytes
f2f372e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
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()
|