matrixgpt / matrix-chatgpt-bot

Talk to ChatGPT via any Matrix client!
GNU Affero General Public License v3.0
233 stars 64 forks source link

api error #159

Closed dhdevdk closed 1 year ago

dhdevdk commented 1 year ago

Hello,

I was trying out this bot with docker-compose and these environment values

# ChatGPT Settings (required)
# Set the API Key from OpenAI
OPENAI_API_KEY=bla

# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
CHATGPT_CONTEXT=thread
# Set the ChatGPT model to be used by the API. 'gpt-3.5-turbo' is the official ChatGPT-model from OpenAI
# Note that the models are not free and will charge your OpenAI account depending on the usage of tokens
CHATGPT_API_MODEL=gpt-4
# (Optional) Explicitly set the prefix sent to model at the beginning of a conversation
#CHATGPT_PROMPT_PREFIX=Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.
# (Optional) Set to true if ChatGPT should ignore any messages which are not text
#CHATGPT_IGNORE_MEDIA=false

# Set data store settings
KEYV_BACKEND=file
KEYV_URL=
KEYV_BOT_ENCRYPTION=false
KEYV_BOT_STORAGE=true

# Matrix Static Settings (required, see notes)
# Defaults to "https://matrix.org"
MATRIX_HOMESERVER_URL=https://matrix.bla.bla
# With the @ and :DOMAIN, ie @SOMETHING:DOMAIN - Not used if `MATRIX_ACCESS_TOKEN` is set.
MATRIX_BOT_USERNAME=chat-gpt-4
# Set `MATRIX_BOT_PASSWORD` the bot will print an `MATRIX_ACCESS_TOKEN` to the terminal
MATRIX_ACCESS_TOKEN=bla 
# Not used if `MATRIX_ACCESS_TOKEN` is set.
#MATRIX_BOT_PASSWORD=

# Matrix Configurable Settings Defaults (optional)
# Leave prefix blank to reply to all messages
MATRIX_DEFAULT_PREFIX=!chatgpt
MATRIX_DEFAULT_PREFIX_REPLY=false

# Matrix Access Control (optional)
# Can be set to user:homeserver or a wildcard like :anotherhomeserver.example
MATRIX_BLACKLIST=
# `MATRIX_WHITELIST` is overriden by `MATRIX_BLACKLIST` if they contain same entry
MATRIX_WHITELIST=

# Matrix Feature Flags (optional)
MATRIX_AUTOJOIN=true
MATRIX_ENCRYPTION=true
# If you turn threads off you will have problems if you don't set CHATGPT_CONTEXT=room
MATRIX_THREADS=true
MATRIX_PREFIX_DM=false
MATRIX_RICH_TEXT=true

Then I created a room and started to chat:

chat-gpt-4: 👋 Hello, I'm ChatGPT bot! Matrix E2EE: true me: !chatgpt hello chat-gpt-4: The bot has encountered an error, please contact your administrator.

The logs from the docker are:

user@X13:/projects/matrix-gpt-bot$ docker compose up 
[+] Running 1/0
 ⠿ Container matrix-chatgpt-bot  Recreated                                                                                                                               0.0s
Attaching to matrix-chatgpt-bot
matrix-chatgpt-bot  | yarn run v1.22.19
matrix-chatgpt-bot  | $ node --enable-source-maps dist/index.js
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [INFO] [index] Starting bot using ChatGPT model: gpt-4
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [INFO] [index] Using promptPrefix: <|im_sep|>Instructions:
matrix-chatgpt-bot  | You are ChatGPT, a large language model trained by OpenAI.
matrix-chatgpt-bot  | Current date: May 6, 2023<|im_sep|>
matrix-chatgpt-bot  | 
matrix-chatgpt-bot  | 
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [ERROR] [MatrixHttpClient] (REQ-3) { errcode: 'M_NOT_FOUND', error: 'Account data not found' }
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [ERROR] [MatrixHttpClient] (REQ-5) { errcode: 'M_NOT_FOUND', error: 'Event not found.' }
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [INFO] [MatrixClientLite] End-to-end encryption enabled
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [INFO] [index] Bot started!
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:03 GMT [ERROR] [MatrixHttpClient] (REQ-9) { errcode: 'M_NOT_FOUND', error: 'Event not found.' }
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:20 GMT [ERROR] [OpenAI-API Error: Error: Failed to send message. HTTP 404 - {
matrix-chatgpt-bot  |   "error": {
matrix-chatgpt-bot  |     "message": "This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?",
matrix-chatgpt-bot  |     "type": "invalid_request_error",
matrix-chatgpt-bot  |     "param": "model",
matrix-chatgpt-bot  |     "code": null
matrix-chatgpt-bot  |   }
matrix-chatgpt-bot  | }
matrix-chatgpt-bot  | ]
matrix-chatgpt-bot  | TypeError: Cannot read properties of undefined (reading 'response')
matrix-chatgpt-bot  |     at CommandHandler.onMessage (file:///usr/src/app/dist/handlers.js:132:86)
matrix-chatgpt-bot  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
matrix-chatgpt-bot  | Sat, 06 May 2023 09:10:21 GMT [ERROR] [MatrixHttpClient] (REQ-20) { errcode: 'M_NOT_FOUND', error: 'Event not found.' }

Is there a hotfix for this in existance?

jame25 commented 1 year ago

Perhaps you should be more clear in your post about the fact that you are trying to use a GPT-4 api key.

max298 commented 1 year ago

Sorry, we haven't released the update to support gpt4 yet, I'll do so shortly. I'll let you know when we've pushed the new image, afterwards you should get the bot up and running simply by pulling the new container.

max298 commented 1 year ago

we've just released v3.1.0, this should fix your issue 👍