romeshsithumina / pal-chatbot

A ChatGPT powered chatbot
https://pal-chatbot.vercel.app
0 stars 0 forks source link

TypeError: database_message_model__WEBPACK_IMPORTED_MODULE_2_.default.create is not a function #1

Closed romeshsithumina closed 5 months ago

romeshsithumina commented 5 months ago

Encountering an error with the following details:

[TypeError: _database_message_model__WEBPACK_IMPORTED_MODULE_2__.default.create is not a function] ... TypeError: mongoose__WEBPACK_IMPORTED_MODULE_0___default(...).set is not a function ... Error: aborted ...

This issue seems to be related to the usage of create and set functions in mongoose. This error happens when trying to save the streaming response from OpenAI to mongodb.

Steps to Reproduce:

  1. Send a prompt/message to pal chatbot from the front end.
  2. Observe the error appearing in the server console.
romeshsithumina commented 5 months ago

This issue was happening due to the use of vercel edge functions to stream the ChatGPT API responses. It appears that mongoose does not support it. To resolve the issue, Prisma accelerate was used by replacing mongoose for the database operations.