Reason working
This commit is contained in:
parent
c87ebf0a74
commit
845e3ab3d6
4 changed files with 85 additions and 39 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue