matrix-chatgpt-bot icon indicating copy to clipboard operation
matrix-chatgpt-bot copied to clipboard

Error after upgrading to 2.2.0

Open Dual-0 opened this issue 2 years ago • 4 comments
trafficstars

after upgrading from 2.1.0 to 2.2.0 I got this error

matrix-gpt-bot@instance:~/2.2.0$ yarn start
yarn run v1.22.19
$ node --enable-source-maps dist/index.js
/opt/matrix_gpt_bot/2.2.0/node_modules/keyv/src/index.js:94
                        || iterableAdapters.findIndex(element => this.opts.store.opts.url.includes(element)) >= 0;
                                                                                          ^

TypeError: Cannot read properties of undefined (reading 'includes')
    at /opt/matrix_gpt_bot/2.2.0/node_modules/keyv/src/index.js:94:70
    at Array.findIndex (<anonymous>)
    at Keyv._checkIterableAdaptar (/opt/matrix_gpt_bot/2.2.0/node_modules/keyv/src/index.js:94:24)
    at new Keyv (/opt/matrix_gpt_bot/2.2.0/node_modules/keyv/src/index.js:87:12)
    at new ChatGPTClient (file:///opt/matrix_gpt_bot/2.2.0/node_modules/@waylaidwanderer/chatgpt-api/src/ChatGPTClient.js:51:35)
    at main (file:///opt/matrix_gpt_bot/2.2.0/dist/index.js:53:21)
    at file:///opt/matrix_gpt_bot/2.2.0/dist/index.js:77:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Node.js v18.14.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

my env:

# Set the API Key from OpenAI
OPENAI_API_KEY=**hidden**

# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
CHATGPT_CONTEXT=thread
# (Optional) Explicitly set the ChatGPT model to be used by the API.
CHATGPT_MODEL=text-chat-davinci-002-20221122
# (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=true

# Set data store settings
KEYV_BACKEND=other
KEYV_URL=redis://localhost:6379/5
KEYV_BOT_ENCRYPTION=false
KEYV_BOT_STORAGE=true

# Matrix Static Settings (required, see notes)
# Defaults to "https://matrix.org"
MATRIX_HOMESERVER_URL=https://**hidden**
# With the @ and :DOMAIN, ie @SOMETHING:DOMAIN - Not used if `MATRIX_ACCESS_TOKEN` is set.
MATRIX_BOT_USERNAME=
# Set `MATRIX_BOT_PASSWORD` the bot will print an `MATRIX_ACCESS_TOKEN` to the terminal
MATRIX_ACCESS_TOKEN=**hidden**
# 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=:**hidden**

# 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

# needs to be ./storage/ if you aren't using Docker or /storage/ if you are.
DATA_PATH=/mnt/matrix_gpt_bot

Thanks in advance

Dual-0 avatar Feb 08 '23 16:02 Dual-0

2.2.1 pushed with a hotfix to this issue (put the old code back from before we added KEYV_BOT_ENCRYPTION).

Unfortunately the KEYV_BOT_ENCRYPTION setting has been removed until support is available upstream.

bertybuttface avatar Feb 08 '23 17:02 bertybuttface

unfortunately the (same) error with 2.2.1:

matrix-gpt-bot@instance:~/2.2.1$ yarn start
yarn run v1.22.19
$ node --enable-source-maps dist/index.js
/opt/matrix_gpt_bot/2.2.1/node_modules/keyv/src/index.js:94
                        || iterableAdapters.findIndex(element => this.opts.store.opts.url.includes(element)) >= 0;
                                                                                          ^

TypeError: Cannot read properties of undefined (reading 'includes')
    at /opt/matrix_gpt_bot/2.2.1/node_modules/keyv/src/index.js:94:70
    at Array.findIndex (<anonymous>)
    at Keyv._checkIterableAdaptar (/opt/matrix_gpt_bot/2.2.1/node_modules/keyv/src/index.js:94:24)
    at new Keyv (/opt/matrix_gpt_bot/2.2.1/node_modules/keyv/src/index.js:87:12)
    at new ChatGPTClient (file:///opt/matrix_gpt_bot/2.2.1/node_modules/@waylaidwanderer/chatgpt-api/src/ChatGPTClient.js:51:35)
    at main (file:///opt/matrix_gpt_bot/2.2.1/dist/index.js:55:21)
    at file:///opt/matrix_gpt_bot/2.2.1/dist/index.js:79:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Node.js v18.14.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Dual-0 avatar Feb 08 '23 17:02 Dual-0

This is an error coming back from interaction between the Keyv library and the upstream ChatGPT library.

A couple of things to try:

  1. Does it work with just files?
  2. Does it work if you use a Redis URL without the number on the end.
  3. Does the upstream package work using this Keyv storage adapter.

Closing as I don't think it is an issue our end, the hotfix was unnecessary. Feel free to reopen if I'm wrong.

bertybuttface avatar Feb 08 '23 17:02 bertybuttface

This is due to switching to the waylaidwanderer library. They initialise Keyv rather than allowing us to pass our own instance in. We will need to put in a PR upstream.

bertybuttface avatar Feb 08 '23 18:02 bertybuttface