askrella / whatsapp-chatgpt

ChatGPT + DALL-E + WhatsApp = AI Assistant :rocket: :robot:
3.33k stars 804 forks source link

TypeError: __vite_ssr_import_5__.Configuration is not a constructor at Module.initOpenAI #318

Open cryptonaut01 opened 7 months ago

cryptonaut01 commented 7 months ago

After finally sorting out a lot of issues / dependencies during installation I finally was able to launch the app and authenticate whatsapp via QR code ... After the bot is ready statement I receive the following error:

The bot is ready to use.
To get started, send a message to the bot with the prompt you want to use.
Use the prefix '!gpt' if configured that way.
/git/whatsapp-chatgpt/src/providers/openai.ts:36
    new __vite_ssr_import_5__.Configuration({
    ^

TypeError: __vite_ssr_import_5__.Configuration is not a constructor
    at Module.initOpenAI (/git/whatsapp-chatgpt/src/providers/openai.ts:30:3)
    at Client.<anonymous> (/git/whatsapp-chatgpt/src/index.ts:79:3)
    at Client.emit (node:events:515:28)
    at Client.emit (node:domain:488:12)
    at Client.initialize (/git/whatsapp-chatgpt/node_modules/whatsapp-web.js/src/Client.js:692:14)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v21.1.0

Seems to be something open.ai specific ? Any hint or idea is welcome.

Edit: Did some further research .. could this be related to the changes in API from v3 to v4 ? In the original package.json an openai v3.3.x is used and during install there was an update to 4.x due to some vulnerabilities found..

cryptonaut01 commented 7 months ago

Issue is related to v4 API as the error does not come up after downgrade to openai package v3.3.0. Question: Is there already an adapted version v3 -> v4 available ?

add146 commented 7 months ago

Same here, please help

nawwaf15 commented 4 months ago

Same issue here. I think I did found a solution ( https://github.com/openai/openai-node/discussions/217 )but I couldn't follow the steps. If one of you guys did manege to fix it. please paste the solution here. I think the changes would be in openai.ts file.

connorv001 commented 4 months ago

What is the device / environment you are tyring to run this on?