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.
This commit is contained in:
parent
3571817524
commit
ff726f6ba3
1 changed files with 11 additions and 2 deletions
|
@ -26,6 +26,8 @@ JUST PROVIDE THE JSON AND NOTHING ELSE.
|
||||||
|
|
||||||
The user's topic of interest is:
|
The user's topic of interest is:
|
||||||
[topic]
|
[topic]
|
||||||
|
|
||||||
|
The User wants [number of questions] questions.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
async function ApiCall() {
|
async function ApiCall() {
|
||||||
|
@ -38,7 +40,7 @@ The user's topic of interest is:
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: "user",
|
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() {
|
async function GenerateQuestionsUsingAI() {
|
||||||
ParsingTry = 0;
|
ParsingTry = 0;
|
||||||
userInput = prompt(
|
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) {
|
if (!userInput) {
|
||||||
|
@ -68,6 +70,13 @@ The user's topic of interest is:
|
||||||
return;
|
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(
|
await toast.promise(
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue