miroslavpejic85 / mirotalk

🚀 WebRTC - P2P - Simple, Secure, Fast Real-Time Video Conferences Up to 4k and 60fps, compatible with all browsers and platforms.
https://p2p.mirotalk.com
GNU Affero General Public License v3.0
2.6k stars 502 forks source link

`OpenAI is not defined` error when using ChatGPT #206

Closed TheBlueSky closed 3 months ago

TheBlueSky commented 3 months ago

Bug Report

IMPORTANT: We primarily use GitHub as an issue tracker. Just open an issue here if you have encountered a bug in MiroTalk. If you have ideas, suggestions, questions, doubts about MiroTalk or need support, please use the MiroTalk Forum instead:

👉 https://discord.gg/rgGYfeYW3N

Describe the bug

I am installed MiroTalk using the latest Docker image, mirotalk/p2p:latest, and configure the ChatGPT section with my API Key, while leaving the rest of the settings as is:

CHATGPT_ENABLED=true
CHATGPT_BASE_PATH=https://api.openai.com/v1/
CHATGTP_APIKEY=MyApiKey
CHATGPT_MODEL=gpt-3.5-turbo-instruct
CHATGPT_MAX_TOKENS=1000
CHATGPT_TEMPERATURE=0

When I enable ChatGPT in that chat window and send a message, the server crashes with the following error message:

mirotalk  | /src/app/src/server.js:704
mirotalk  |                     if (error instanceof OpenAI.APIError) {
mirotalk  |                                          ^
mirotalk  |
mirotalk  | ReferenceError: OpenAI is not defined
mirotalk  |     at Socket.<anonymous> (/src/app/src/server.js:704:42)
mirotalk  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

By looking at the source code, it seems that OpenAI being undefined masks the original error. So, it isn't clear what is actually failing.

To reproduce

Steps to reproduce the behavior:

  1. Create a Docker Compose file like the one below these steps
  2. Download .env.template file from this repo into the same directory as the Docker Compose file, and rename it to .env
  3. Update ChatGPT section in the .env file as shown in the bug description section above (you may also need to update other configurations, such as host)
  4. Run the container with docker compose up -d && docker compose logs -f, so that you see the logs
  5. Navigate to the application, enter a room, open the chat window, enable ChatGPT, and post a message
  6. See error in the logs
services:
  mirotalk:
    image: mirotalk/p2p:latest
    container_name: mirotalk
    hostname: mirotalk-docker
    volumes:
        - ./.env:/src/.env:ro
    ports:
      - 3000:3000/tcp
    privileged: false
    security_opt:
      - no-new-privileges:true
    restart: unless-stopped

Expected behavior

Screenshots

image

Desktop - Mobile

Please complete the following information:

Additional context

-

miroslavpejic85 commented 3 months ago

Hello @TheBlueSky, Thank you for reporting it. I've made a small adjustment. Please check your server console for any potential errors that can help you to identifying the issue.

TheBlueSky commented 3 months ago

Thanks for the quick resposne, @miroslavpejic85. Now I can see the real error behind it, which is 429 insufficient_quota 😬