58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
export interface QuizPromptOptions {
|
|
topic?: string;
|
|
questionCount: number;
|
|
hasDocuments: boolean;
|
|
includeJsonExample?: boolean;
|
|
}
|
|
|
|
export const TITLE_GUIDANCE = `Title guidance: Make the title fun and varied. Use playful phrasing, light wordplay, or energetic wording. Avoid templates like "The Ultimate ... Quiz" or "Test your knowledge". Keep it short (2-6 words) and specific to the topic, with clear reference to the original topic.`;
|
|
|
|
export const EXPLANATION_GUIDANCE = `IMPORTANT: For each option's reason, write as if you are directly explaining facts - never reference "the document", "the text", "the material", or "the source". Write explanations as standalone factual statements.`;
|
|
|
|
export const JSON_EXAMPLE_GUIDANCE = `You MUST respond with a single JSON object in this exact structure:
|
|
{
|
|
"title": "Quiz Title Here",
|
|
"questions": [
|
|
{
|
|
"text": "Question text here?",
|
|
"options": [
|
|
{ "text": "Option A", "isCorrect": false, "reason": "Explanation why this is wrong" },
|
|
{ "text": "Option B", "isCorrect": true, "reason": "Explanation why this is correct" },
|
|
{ "text": "Option C", "isCorrect": false, "reason": "Explanation why this is wrong" },
|
|
{ "text": "Option D", "isCorrect": false, "reason": "Explanation why this is wrong" }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
|
|
There can be 2-6 options. Use 2 for true/false style questions.
|
|
|
|
Return ONLY valid JSON with no additional text before or after.`;
|
|
|
|
export function buildQuizPrompt(options: QuizPromptOptions): string {
|
|
const questionCount = options.questionCount || 10;
|
|
let baseInstructions = `Create ${questionCount} engaging multiple-choice questions. Each question must have 2-6 options, and exactly one correct answer. Vary the difficulty.
|
|
|
|
${TITLE_GUIDANCE}
|
|
|
|
${EXPLANATION_GUIDANCE}`;
|
|
|
|
if (options.includeJsonExample) {
|
|
baseInstructions += `
|
|
|
|
${JSON_EXAMPLE_GUIDANCE}`;
|
|
}
|
|
|
|
if (options.hasDocuments) {
|
|
const topicContext = options.topic
|
|
? ` Focus on aspects related to "${options.topic}".`
|
|
: '';
|
|
return `Generate a quiz based on the provided content.${topicContext}
|
|
|
|
${baseInstructions}`;
|
|
}
|
|
|
|
return `Generate a trivia quiz about "${options.topic}".
|
|
|
|
${baseInstructions}`;
|
|
}
|