spantaleev / matrix-docker-ansible-deploy

🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
GNU Affero General Public License v3.0
4.92k stars 1.05k forks source link

ChatGPT Bot does not work #2867

Open randomsnowflake opened 1 year ago

randomsnowflake commented 1 year ago

A while ago I enabled the ChatGPT bot in the playbook. It installed fine and I was happy using ChatGPT in my matrix server.

After a while it suddenly stopped working.

Yesterday, while updating my Matrix server the check function fails with the following error:

ansible error

TASK [galaxy/com.devture.ansible.role.systemd_service_manager : Fail if service isn't detected to be running] *************
failed: [matrix.myserver.com] (item=matrix-bot-chatgpt.service) => changed=false
  ansible_loop_var: item
  item: matrix-bot-chatgpt.service
  msg: matrix-bot-chatgpt.service was not detected to be running. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.). Try running `systemctl status matrix-bot-chatgpt.service` and `journalctl -fu matrix-bot-chatgpt.service` on the server to investigate. If you're on a slow or overloaded server, it may be that services take a longer time to start and that this error is a false-positive. You can consider raising the value of the `devture_systemd_service_manager_up_verification_delay_seconds` variable. See `/Users/johannes/Syncthing/Development/PersonalCloud/Matrix/matrix-docker-ansible-deploy/roles/galaxy/com.devture.ansible.role.systemd_service_manager/defaults/main.yml` for more details about that.

Server output:

systemctl status matrix-bot-chatgpt.service

● matrix-bot-chatgpt.service - Matrix chatgpt bot
     Loaded: loaded (/etc/systemd/system/matrix-bot-chatgpt.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2023-09-02 09:36:26 CEST; 7s ago
    Process: 409089 ExecStartPre=/usr/bin/env sh -c /usr/bin/env docker kill matrix-bot-chatgpt 2>/dev/null || true (code=>
    Process: 409098 ExecStartPre=/usr/bin/env sh -c /usr/bin/env docker rm matrix-bot-chatgpt 2>/dev/null || true (code=ex>
    Process: 409107 ExecStart=/usr/bin/env docker run --rm --name=matrix-bot-chatgpt --log-driver=none --user=997:1000 --c>
   Main PID: 409107 (code=exited, status=1/FAILURE)
        CPU: 131ms

Sep 02 09:36:26 personalcloud systemd[1]: matrix-bot-chatgpt.service: Main process exited, code=exited, status=1/FAILURE
Sep 02 09:36:26 personalcloud systemd[1]: matrix-bot-chatgpt.service: Failed with result 'exit-code'.

journalctl -fu matrix-bot-chatgpt.service

Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]:   statusCode: 400,
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]:   errcode: 'M_UNKNOWN',
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]:   error: `One time key signed_curve25519:AAAAAAAAAA8 already exists. Old key: {"key":"Hix5XMoLNSwZqJTG76A82Kju5GlPBIAsQYxLV36UowU","signatures":{"@bot.chatgpt:myserver.com":{"ed25519:YOURDEVICEID":"8lTDOjlTlJfnw5ejzr+gaqkYwz0hB8tbhs5pKTEPKVdemixunxIKzH9PLGp9uMwzFKVdwJuXMIlqT6y8fOucDw"}}}; new key: {'key': 'I5Yl46jN4w8uT8InAX9W8ZgIpVYdcqQlOUPWR29aGV0', 'signatures': {'@bot.chatgpt:myserver.com': {'ed25519:YOURDEVICEID': 'te4RuROzo4rp7GIUY8IN6tE6+vHpLQTrUWw3eXd8EJZtt9OpPKZO7CwN0G8nhbnL3C01Ma+QIwdsV5qatpwqBw'}}}`,
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]:   retryAfterMs: undefined
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]: }
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]: Node.js v19.9.0
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Sep 03 08:27:10 personalcloud matrix-bot-chatgpt[1172522]: error Command failed with exit code 1.
Sep 03 08:27:10 personalcloud systemd[1]: matrix-bot-chatgpt.service: Main process exited, code=exited, status=1/FAILURE
Sep 03 08:27:10 personalcloud systemd[1]: matrix-bot-chatgpt.service: Failed with result 'exit-code'.

Needless to say the bot does not appear online.

MatthewAger commented 9 months ago

I had exactly the same thing and I think that it is actually related to how you set this up and whether matrix_bot_chatgpt_matrix_access_token has already been "used". See here for a related issue.

I removed the config from my vars.yml and ssh'd onto my server and followed the instructions from the upstream repo directly. After using the same access token in the .env file before doing docker run I received the same error. Then, I removed MATRIX_ACCESS_TOKEN and added MATRIX_BOT_PASSWORD to .env which printed a new MATRIX_ACCESS_TOKEN to the terminal. I used this to update .env and ran docker run again. This time it booted just fine.

Honestly, I think is a more secure setup as I'm version controlling my vars.yml to and I didn't want api keys to be committed.

Hope this helps someone down the road, and would like to know what precisely needs to change re obtaining an access token to ensure that it isn't stale at the point of deployment.

AirP0WeR commented 3 months ago

Same issue for me.

One time key signed_curve25519:AAAAAAAAAA0 already exists