From ff726f6ba3c5de755c2815dd5d5e6a3e964bc456 Mon Sep 17 00:00:00 2001 From: RezHackXYZ Date: Sun, 15 Jun 2025 23:57:11 +0530 Subject: [PATCH] added 2 promts (topic and number of quetions, so that the ai better understands the number of quetions and give the right number rather than geusing) to create quetions using ai in the create page of the kahhot tool. --- src/routes/kahootclone/create/Buttons.svelte | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/routes/kahootclone/create/Buttons.svelte b/src/routes/kahootclone/create/Buttons.svelte index 2e944b2..96fc09d 100644 --- a/src/routes/kahootclone/create/Buttons.svelte +++ b/src/routes/kahootclone/create/Buttons.svelte @@ -26,6 +26,8 @@ JUST PROVIDE THE JSON AND NOTHING ELSE. The user's topic of interest is: [topic] + +The User wants [number of questions] questions. `; async function ApiCall() { @@ -38,7 +40,7 @@ The user's topic of interest is: messages: [ { role: "user", - content: AIPrompt.replace("[topic]", userInput), + content: AIPrompt.replace("[topic]", userInput).replace("[number of questions]", numberOfQuestions), }, ], }), @@ -60,7 +62,7 @@ The user's topic of interest is: async function GenerateQuestionsUsingAI() { ParsingTry = 0; userInput = prompt( - "Enter the topic and number of questions you want with any instructions for the ai, note: doing this will delete all you previous questions and its not undo able", + "Enter the topic you want with any instructions for the ai, note: doing this will delete all you previous questions and its not undo able", ); if (!userInput) { @@ -68,6 +70,13 @@ The user's topic of interest is: return; } + const numberOfQuestions = prompt("How many questions? (e.g. 5, not 'five')", "5"); + + if (isNaN(parseInt(numberOfQuestions)) || numberOfQuestions <= 0) { + toast.error("Please enter a valid number of questions."); + return; + } + await toast.promise( (async () => { try {