Elliott-Chong / learning-journey-yt

https://learning-journey.reluate.tech
108 stars 57 forks source link

error api/chapter/getInfo 500 internal server error {success: false, error: "unknown"} #1

Open wirapramuja opened 1 year ago

wirapramuja commented 1 year ago

Hello elliot, i have an error error error api/chapter/getInfo 500internal server error {success: false, error: "unknown"} can you suggest me what file need to be check?

88um commented 1 year ago

Hello elliot, i have an error error error api/chapter/getInfo 500internal server error {success: false, error: "unknown"} can you suggest me what file need to be check?

Console Log your error

Hello elliot, i have an error error error api/chapter/getInfo 500internal server error {success: false, error: "unknown"} can you suggest me what file need to be check?

Console log your error bro

wirapramuja commented 1 year ago

when i genereate the course throw an errror like this "An exception occurred: SyntaxError: Unexpected token H in JSON at position 0 at JSON.parse () at strict_output (webpack-internal:///(rsc)/./src/lib/gpt.ts:59:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async getQuestionsFromTranscript (webpack-internal:///(rsc)/./src/lib/youtube.ts:43:23) at async POST (webpack-internal:///(rsc)/./src/app/api/chapter/getInfo/route.ts:43:27) at async eval (webpack-internal:///(rsc)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:254:37) Current invalid json format How many components are needed for the application discussed in the transcript?"

wirapramuja commented 1 year ago

just info when i return nextRespone.json "questions" without prisma.questionCreatemany it trow sucess, but when include question.createMany it trow error

const questions = await getQuestionsFromTranscript( transcript, chapter.name );

await prisma.question.createMany({
  data: questions.map((question) => {
    let options = [
      question.answer,
      question.option1,
      question.option2,
      question.option3,
    ];
    options = options.sort(() => Math.random() - 0.5);
    return {
      question: question.question,
      answer: question.answer,
      options: JSON.stringify(options),
      chapterId: chapterId,
    };
  }),
});

await prisma.chapter.update({
  where: { id: chapterId },
  data: {
    videoId: videoId,
    summary: summary,
  },
});

return NextResponse.json({ questions });
wirapramuja commented 1 year ago

POST http://localhost:3000/api/chapter/getInfo 500 (Internal Server Error)

https://github.com/wirapramuja/ai-learning/tree/master

wirapramuja commented 1 year ago

hello?

Amna0099 commented 1 year ago

same error

88um commented 1 year ago

just info when i return nextRespone.json "questions" without prisma.questionCreatemany it trow sucess, but when include question.createMany it trow error

const questions = await getQuestionsFromTranscript( transcript, chapter.name );

await prisma.question.createMany({
  data: questions.map((question) => {
    let options = [
      question.answer,
      question.option1,
      question.option2,
      question.option3,
    ];
    options = options.sort(() => Math.random() - 0.5);
    return {
      question: question.question,
      answer: question.answer,
      options: JSON.stringify(options),
      chapterId: chapterId,
    };
  }),
});

await prisma.chapter.update({
  where: { id: chapterId },
  data: {
    videoId: videoId,
    summary: summary,
  },
});

return NextResponse.json({ questions });

when i genereate the course throw an errror like this "An exception occurred: SyntaxError: Unexpected token H in JSON at position 0 at JSON.parse () at strict_output (webpack-internal:///(rsc)/./src/lib/gpt.ts:59:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async getQuestionsFromTranscript (webpack-internal:///(rsc)/./src/lib/youtube.ts:43:23) at async POST (webpack-internal:///(rsc)/./src/app/api/chapter/getInfo/route.ts:43:27) at async eval (webpack-internal:///(rsc)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:254:37) Current invalid json format How many components are needed for the application discussed in the transcript?"

If your site is deployed on vercel, they have a timeout limit for server functions of about 5-10 seconds. This works terribly with chat pgt since generations can take some time longer than 5-10 seconds. Its possible thats the reason why you're getting a 500

sreehari0914 commented 8 months ago

can anyone say how to solve this