Reason working

This commit is contained in:
Joey Yakimowich-Payne 2026-01-13 07:55:17 -07:00
commit 845e3ab3d6
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
4 changed files with 85 additions and 39 deletions

View file

@ -13,7 +13,7 @@ const getClient = () => {
export const generateQuiz = async (topic: string): Promise<Quiz> => {
const ai = getClient();
const prompt = `Generate a trivia quiz about "${topic}". Create 10 engaging multiple-choice questions. Each question must have exactly 4 options, and exactly one correct answer. Vary the difficulty.`;
const prompt = `Generate a trivia quiz about "${topic}". Create 10 engaging multiple-choice questions. Each question must have exactly 4 options, and exactly one correct answer. Vary the difficulty. For each option, provide a brief reason explaining why it is correct or incorrect - this helps players learn.`;
const response = await ai.models.generateContent({
model: "gemini-3-flash-preview",
@ -36,9 +36,10 @@ export const generateQuiz = async (topic: string): Promise<Quiz> => {
type: Type.OBJECT,
properties: {
text: { type: Type.STRING },
isCorrect: { type: Type.BOOLEAN }
isCorrect: { type: Type.BOOLEAN },
reason: { type: Type.STRING, description: "Brief explanation of why this answer is correct or incorrect" }
},
required: ["text", "isCorrect"]
required: ["text", "isCorrect", "reason"]
},
}
},
@ -68,7 +69,8 @@ export const generateQuiz = async (topic: string): Promise<Quiz> => {
text: opt.text,
isCorrect: opt.isCorrect,
shape: shapes[index % 4],
color: colors[index % 4]
color: colors[index % 4],
reason: opt.reason
}));
return {