mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-11-08 19:18:55 +01:00
Remove matrix-chatgpt-bot
Reuse: -096b85bd96/docs/configuring-playbook-email2matrix.md-096b85bd96/docs/configuring-playbook-bridge-appservice-webhooks.mdSigned-off-by: Suguru Hirahara <did🔑z6MkvVZk1A3KBApWJXv2Ju4H14ErDfRGxh8zxdXSZ4vACDg5>
This commit is contained in:
committed by
Slavi Pantaleev
parent
096b85bd96
commit
3eced43292
3
.github/renovate.json
vendored
3
.github/renovate.json
vendored
@@ -27,9 +27,6 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"ignoreDeps": [
|
||||
"ghcr.io/matrixgpt/matrix-chatgpt-bot"
|
||||
],
|
||||
"pre-commit": {
|
||||
"enabled": true
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# 2025-11-07
|
||||
|
||||
## The matrix-chatgpt-bot has been removed from the playbook
|
||||
|
||||
The [matrix-bot-chatgpt](./docs/configuring-playbook-bot-chatgpt.md) has been removed from the playbook, as it has been deprecated since September 2024.
|
||||
|
||||
The playbook will let you know if you're using any `matrix_bot_chatgpt_*` variables. You'll need to remove them from `vars.yml` and potentially [uninstall the bot manually](./docs/configuring-playbook-bot-chatgpt.md#uninstalling-matrix-chatgpt-bot-manually).
|
||||
|
||||
# 2025-11-05
|
||||
|
||||
## The MX Puppet bridges for Discord, Instagram, Slack, and Twitter have been removed from the playbook
|
||||
|
||||
@@ -1,98 +1,25 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev
|
||||
SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
SPDX-FileCopyrightText: 2019 - 2025 Slavi Pantaleev
|
||||
SPDX-FileCopyrightText: 2022 Dennis Ciba
|
||||
SPDX-FileCopyrightText: 2022 Nikita Chernyi
|
||||
SPDX-FileCopyrightText: 2023 - 2024 MDAD project contributors
|
||||
SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Setting up matrix-bot-chatgpt (optional, unmaintained)
|
||||
# Setting up matrix-chatgpt-bot (optional, removed)
|
||||
|
||||
**Note**: [matrix-chatgpt-bot](https://github.com/matrixgpt/matrix-chatgpt-bot) is now an archived (**unmaintained**) project. Talking to ChatGPT (and many other LLM providers) can happen via the much more featureful [baibot](https://github.com/etkecc/baibot), which can be [installed using this playbook](configuring-playbook-bot-baibot.md). Consider using that bot instead of this one.
|
||||
🪦 The playbook used to be able to install and configure [matrix-chatgpt-bot](https://github.com/matrixgpt/matrix-chatgpt-bot), but no longer includes this component.
|
||||
|
||||
The playbook can install and configure [matrix-chatgpt-bot](https://github.com/matrixgpt/matrix-chatgpt-bot) for you.
|
||||
While not a 1:1 replacement, the bot's author suggests taking a look at [baibot](https://github.com/etkecc/baibot) as a replacement, which can also be [installed using this playbook](configuring-playbook-bot-baibot.md).
|
||||
|
||||
Talk to [ChatGPT](https://openai.com/blog/chatgpt/) via your favourite Matrix client!
|
||||
## Uninstalling matrix-chatgpt-bot manually
|
||||
|
||||
See the project's [documentation](https://github.com/matrixgpt/matrix-chatgpt-bot/blob/main/README.md) to learn what it does and why it might be useful to you.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Obtain an OpenAI API key
|
||||
|
||||
To use the bot, you'd need to obtain an API key from [https://platform.openai.com/account/api-keys](https://platform.openai.com/account/api-keys).
|
||||
|
||||
### Register the bot account
|
||||
|
||||
The playbook does not automatically create users for you. You **need to register the bot user manually** before setting up the bot.
|
||||
|
||||
Generate a strong password for the bot. You can create one with a command like `pwgen -s 64 1`.
|
||||
|
||||
You can use the playbook to [register a new user](registering-users.md):
|
||||
If you still have the matrix-chatgpt-bot component installed on your Matrix server, the playbook can no longer help you uninstall it and you will need to do it manually. To uninstall manually, run these commands on the server:
|
||||
|
||||
```sh
|
||||
ansible-playbook -i inventory/hosts setup.yml --extra-vars='username=bot.chatgpt password=PASSWORD_FOR_THE_BOT admin=no' --tags=register-user
|
||||
systemctl disable --now matrix-bot-chatgpt.service
|
||||
|
||||
rm -rf /matrix/chatgpt
|
||||
```
|
||||
|
||||
### Obtain an access token and create encryption keys
|
||||
|
||||
The bot requires an access token to be able to connect to your homeserver. Refer to the documentation on [how to obtain an access token](obtaining-access-tokens.md).
|
||||
|
||||
> [!WARNING]
|
||||
> Access tokens are sensitive information. Do not include them in any bug reports, messages, or logs. Do not share the access token with anyone.
|
||||
|
||||
To make sure the bot can read encrypted messages, it will need an encryption key, just like any other new user. While obtaining the access token, follow the prompts to setup a backup key. More information can be found in the [Element documentation](https://element.io/help#encryption6).
|
||||
|
||||
## Adjusting the playbook configuration
|
||||
|
||||
To enable the bot, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file. Make sure to replace `API_KEY_HERE` with the API key retrieved [here](#obtain-an-openai-api-key) and `ACCESS_TOKEN_HERE` with the access token created [here](#obtain-an-access-token-and-create-encryption-keys), respectively.
|
||||
|
||||
```yaml
|
||||
matrix_bot_chatgpt_enabled: true
|
||||
|
||||
matrix_bot_chatgpt_openai_api_key: 'API_KEY_HERE'
|
||||
|
||||
# Uncomment and adjust this part if you'd like to use a username different than the default
|
||||
# matrix_bot_chatgpt_matrix_bot_username_localpart: 'bot.chatgpt'
|
||||
|
||||
matrix_bot_chatgpt_matrix_access_token: 'ACCESS_TOKEN_HERE'
|
||||
|
||||
# Configuring the system prompt used, needed if the bot is used for special tasks.
|
||||
# More information: https://github.com/mustvlad/ChatGPT-System-Prompts
|
||||
matrix_bot_chatgpt_matrix_bot_prompt_prefix: 'Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.'
|
||||
```
|
||||
|
||||
### Extending the configuration
|
||||
|
||||
There are some additional things you may wish to configure about the bot.
|
||||
|
||||
Take a look at:
|
||||
|
||||
- `roles/custom/matrix-bot-chatgpt/defaults/main.yml` for some variables that you can customize via your `vars.yml` file
|
||||
|
||||
## Installing
|
||||
|
||||
After configuring the playbook, run it with [playbook tags](playbook-tags.md) as below:
|
||||
|
||||
<!-- NOTE: let this conservative command run (instead of install-all) to make it clear that failure of the command means something is clearly broken. -->
|
||||
```sh
|
||||
ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-users-created,start
|
||||
```
|
||||
|
||||
**Notes**:
|
||||
|
||||
- The `ensure-matrix-users-created` playbook tag makes the playbook automatically create the bot's user account.
|
||||
|
||||
- The shortcut commands with the [`just` program](just.md) are also available: `just install-all` or `just setup-all`
|
||||
|
||||
`just install-all` is useful for maintaining your setup quickly ([2x-5x faster](../CHANGELOG.md#2x-5x-performance-improvements-in-playbook-runtime) than `just setup-all`) when its components remain unchanged. If you adjust your `vars.yml` to remove other components, you'd need to run `just setup-all`, or these components will still remain installed.
|
||||
|
||||
## Usage
|
||||
|
||||
To use the bot, invite it to the room you specified on your `vars.yml` file (`/invite @bot.chatgpt:example.com` where `example.com` is your base domain, not the `matrix.` domain).
|
||||
|
||||
After the bot joins the room, you can send a message to it. When you do so, use the prefix if you configured it or mention the bot.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
As with all other services, you can find the logs in [systemd-journald](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) by logging in to the server with SSH and running `journalctl -fu matrix-bot-chatgpt`.
|
||||
|
||||
@@ -291,8 +291,6 @@ devture_systemd_service_manager_services_list_auto: |
|
||||
+
|
||||
([{'name': 'matrix-bot-draupnir.service', 'priority': 4000, 'groups': ['matrix', 'bots', 'draupnir', 'bot-draupnir']}] if matrix_bot_draupnir_enabled else [])
|
||||
+
|
||||
([{'name': 'matrix-bot-chatgpt.service', 'priority': 2200, 'groups': ['matrix', 'bots', 'chatgpt', 'bot-chatgpt']}] if matrix_bot_chatgpt_enabled else [])
|
||||
+
|
||||
([{'name': 'matrix-appservice-discord.service', 'priority': 2000, 'groups': ['matrix', 'bridges', 'appservice-discord']}] if matrix_appservice_discord_enabled else [])
|
||||
+
|
||||
([{'name': 'matrix-appservice-draupnir-for-all.service', 'priority': 4000, 'groups': ['matrix', 'bridges', 'draupnir-for-all', 'appservice-draupnir-for-all']}] if matrix_appservice_draupnir_for_all_enabled else [])
|
||||
@@ -2844,33 +2842,6 @@ matrix_bot_baibot_container_additional_networks_auto: |-
|
||||
#
|
||||
######################################################################
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# matrix-bot-chatgpt
|
||||
#
|
||||
######################################################################
|
||||
|
||||
# We don't enable bots by default.
|
||||
matrix_bot_chatgpt_enabled: false
|
||||
|
||||
matrix_bot_chatgpt_container_image_registry_prefix_upstream: "{{ matrix_container_global_registry_prefix_override if matrix_container_global_registry_prefix_override else matrix_bot_chatgpt_container_image_registry_prefix_upstream_default }}"
|
||||
|
||||
matrix_bot_chatgpt_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}"
|
||||
|
||||
matrix_bot_chatgpt_container_network: "{{ matrix_addons_container_network }}"
|
||||
matrix_bot_chatgpt_container_additional_networks_auto: "{{ [] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network] }}"
|
||||
|
||||
matrix_bot_chatgpt_matrix_homeserver_url: "{{ matrix_addons_homeserver_client_api_url }}"
|
||||
|
||||
matrix_bot_chatgpt_systemd_required_services_list_auto: "{{ matrix_addons_homeserver_systemd_services_list }}"
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# /matrix-bot-chatgpt
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# matrix-bot-go-neb
|
||||
@@ -4906,10 +4877,6 @@ matrix_synapse_admin_config_asManagedUsers_auto: |
|
||||
'^@'+(matrix_bot_draupnir_login | default('') | regex_escape) +':'+(matrix_domain | regex_escape)+'$',
|
||||
] if matrix_bot_draupnir_enabled else [])
|
||||
+
|
||||
([
|
||||
'^@'+(matrix_bot_chatgpt_matrix_bot_username_localpart | default('') | regex_escape) +':'+(matrix_domain | regex_escape)+'$',
|
||||
] if matrix_bot_chatgpt_enabled else [])
|
||||
+
|
||||
([
|
||||
'^@'+(matrix_bot_honoroit_login | default('') | regex_escape) +':'+(matrix_domain | regex_escape)+'$',
|
||||
] if matrix_bot_honoroit_enabled else [])
|
||||
@@ -5819,12 +5786,6 @@ matrix_user_creator_users_auto: |
|
||||
'initial_type': 'bot',
|
||||
}] if matrix_bot_baibot_enabled else [])
|
||||
+
|
||||
([{
|
||||
'username': matrix_bot_chatgpt_matrix_bot_username_localpart,
|
||||
'initial_password': matrix_bot_chatgpt_matrix_bot_password,
|
||||
'initial_type': 'bot',
|
||||
}] if matrix_bot_chatgpt_enabled and matrix_bot_chatgpt_matrix_bot_password | length > 0 else [])
|
||||
+
|
||||
([{
|
||||
'username': matrix_bot_matrix_reminder_bot_matrix_user_id_localpart,
|
||||
'initial_password': matrix_bot_matrix_reminder_bot_matrix_user_password,
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev
|
||||
# SPDX-FileCopyrightText: 2023 Joe Kappus
|
||||
# SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2023 Nikita Chernyi
|
||||
# SPDX-FileCopyrightText: 2023 Samuel Meenzen
|
||||
# SPDX-FileCopyrightText: 2024 Suguru Hirahara
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
# chatgpt is a bot for chatting to openAI chatgpt Matrix bot
|
||||
# Project source code URL: https://github.com/matrixgpt/matrix-chatgpt-bot
|
||||
|
||||
matrix_bot_chatgpt_enabled: true
|
||||
|
||||
# renovate: datasource=docker depName=ghcr.io/matrixgpt/matrix-chatgpt-bot
|
||||
matrix_bot_chatgpt_version: 3.1.4
|
||||
|
||||
matrix_bot_chatgpt_container_image_self_build: false
|
||||
matrix_bot_chatgpt_container_image_self_build_repo: "https://github.com/matrixgpt/matrix-chatgpt-bot"
|
||||
matrix_bot_chatgpt_container_image_self_build_repo_version: "{{ 'main' if matrix_bot_chatgpt_version == 'latest' else matrix_bot_chatgpt_version }}"
|
||||
|
||||
matrix_bot_chatgpt_container_image: "{{ matrix_bot_chatgpt_container_image_registry_prefix }}matrixgpt/matrix-chatgpt-bot:{{ matrix_bot_chatgpt_container_image_tag }}"
|
||||
matrix_bot_chatgpt_container_image_registry_prefix: "{{ 'localhost/' if matrix_bot_chatgpt_container_image_self_build else matrix_bot_chatgpt_container_image_registry_prefix_upstream }}"
|
||||
matrix_bot_chatgpt_container_image_registry_prefix_upstream: "{{ matrix_bot_chatgpt_container_image_registry_prefix_upstream_default }}"
|
||||
matrix_bot_chatgpt_container_image_registry_prefix_upstream_default: "ghcr.io/"
|
||||
matrix_bot_chatgpt_container_image_tag: "{{ matrix_bot_chatgpt_version }}"
|
||||
matrix_bot_chatgpt_container_image_force_pull: "{{ matrix_bot_chatgpt_container_image.endswith(':latest') }}"
|
||||
|
||||
matrix_bot_chatgpt_base_path: "{{ matrix_base_data_path }}/chatgpt"
|
||||
matrix_bot_chatgpt_config_path: "{{ matrix_bot_chatgpt_base_path }}/config"
|
||||
matrix_bot_chatgpt_data_path: "{{ matrix_bot_chatgpt_base_path }}/data"
|
||||
matrix_bot_chatgpt_container_src_path: "{{ matrix_bot_chatgpt_base_path }}/container-src"
|
||||
|
||||
# Controls how long to wait for the container to stop gracefully before killing it.
|
||||
# We use a small value here, because this container does not seem to handle the SIGTERM signal.
|
||||
matrix_bot_chatgpt_container_stop_grace_time_seconds: 1
|
||||
|
||||
matrix_bot_chatgpt_container_network: ""
|
||||
|
||||
matrix_bot_chatgpt_container_additional_networks: "{{ matrix_bot_chatgpt_container_additional_networks_auto + matrix_bot_chatgpt_container_additional_networks_custom }}"
|
||||
matrix_bot_chatgpt_container_additional_networks_auto: []
|
||||
matrix_bot_chatgpt_container_additional_networks_custom: []
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_bot_chatgpt_container_extra_arguments: []
|
||||
|
||||
# List of systemd services that matrix-bot-chatgpt.service depends on
|
||||
matrix_bot_chatgpt_systemd_required_services_list: "{{ matrix_bot_chatgpt_systemd_required_services_list_default + matrix_bot_chatgpt_systemd_required_services_list_auto + matrix_bot_chatgpt_systemd_required_services_list_custom }}"
|
||||
matrix_bot_chatgpt_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
|
||||
matrix_bot_chatgpt_systemd_required_services_list_auto: []
|
||||
matrix_bot_chatgpt_systemd_required_services_list_custom: []
|
||||
|
||||
# List of systemd services that matrix-bot-chatgpt.service wants
|
||||
matrix_bot_chatgpt_systemd_wanted_services_list: []
|
||||
|
||||
# ChatGPT Settings
|
||||
matrix_bot_chatgpt_openai_api_key: ''
|
||||
matrix_bot_chatgpt_api_model: 'gpt-3.5-turbo'
|
||||
matrix_bot_chatgpt_context: 'thread' # CHATGPT_CONTEXT="thread"
|
||||
|
||||
matrix_bot_chatgpt_keyv_backend: 'file'
|
||||
matrix_bot_chatgpt_keyv_url: ''
|
||||
matrix_bot_chatgpt_keyv_bot_encryption: false
|
||||
matrix_bot_chatgpt_keyv_bot_storage: true
|
||||
|
||||
# Matrix Static Settings (required, see notes)
|
||||
# Defaults to "https://matrix.org"
|
||||
matrix_bot_chatgpt_matrix_homeserver_url: "" # MATRIX_HOMESERVER_URL=
|
||||
# With the @ and :example.com, ie @bot.chatgpt:example.com, needs to be set, created manually beforehand.
|
||||
matrix_bot_chatgpt_matrix_bot_username_localpart: 'bot.chatgpt'
|
||||
matrix_bot_chatgpt_matrix_bot_username: "@{{ matrix_bot_chatgpt_matrix_bot_username_localpart }}:{{ matrix_domain }}" # MATRIX_BOT_USERNAME=
|
||||
# Set `MATRIX_BOT_PASSWORD` the bot will print an `MATRIX_ACCESS_TOKEN` to the terminal
|
||||
# or https://webapps.stackexchange.com/questions/131056/how-to-get-an-access-token-for-element-riot-matrix
|
||||
matrix_bot_chatgpt_matrix_access_token: '' # MATRIX_ACCESS_TOKEN=
|
||||
# Once `MATRIX_BOT_ACCESS_TOKEN` is set this is no longer used.
|
||||
matrix_bot_chatgpt_matrix_bot_password: '' # MATRIX_BOT_PASSWORD=
|
||||
|
||||
# Matrix Configurable Settings Defaults (optional)
|
||||
matrix_bot_chatgpt_matrix_default_prefix: "!chatgpt " # MATRIX_DEFAULT_PREFIX= Leave prefix blank to reply to all messages, trailing space matters
|
||||
matrix_bot_chatgpt_matrix_default_prefix_reply: false # MATRIX_DEFAULT_PREFIX_REPLY=
|
||||
|
||||
# Matrix Access Control (optional)
|
||||
#
|
||||
# Lists of space-separated entries. Example:
|
||||
# matrix_bot_chatgpt_matrix_whitelist: ":{{ matrix_domain }} :example.net :example.org"
|
||||
matrix_bot_chatgpt_matrix_blacklist: ''
|
||||
matrix_bot_chatgpt_matrix_whitelist: ':{{ matrix_domain }}'
|
||||
|
||||
# Matrix Feature Flags (optional)
|
||||
matrix_bot_chatgpt_matrix_autojoin: true # MATRIX_AUTOJOIN=true
|
||||
matrix_bot_chatgpt_matrix_encryption: true # MATRIX_ENCRYPTION=true
|
||||
matrix_bot_chatgpt_matrix_threads: true # MATRIX_THREADS=true
|
||||
matrix_bot_chatgpt_matrix_rich_text: true # MATRIX_RICH_TEXT=true
|
||||
|
||||
|
||||
# A list of admins
|
||||
# Example set of rules:
|
||||
# matrix_bot_chatgpt_admins:
|
||||
# - @alice:example.com
|
||||
# - @bob:example.com
|
||||
# - @bot.*:example.com
|
||||
# - @*:example.net
|
||||
# matrix_bot_chatgpt_admins: "{{ [matrix_admin] if matrix_admin else [] }}"
|
||||
|
||||
# Additional environment variables to pass to the chatgpt container
|
||||
#
|
||||
# You can discover additional environment variables from:
|
||||
# https://github.com/matrixgpt/matrix-chatgpt-bot/blob/main/src/env.ts
|
||||
#
|
||||
# Example:
|
||||
# matrix_bot_chatgpt_environment_variables_extension: |
|
||||
# chatgpt_TEXT_DONE=Done
|
||||
matrix_bot_chatgpt_environment_variables_extension: ''
|
||||
|
||||
matrix_bot_chatgpt_matrix_bot_prompt_prefix: 'Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.'
|
||||
@@ -1,75 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev
|
||||
# SPDX-FileCopyrightText: 2024 David Mehren
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
|
||||
- name: Ensure chatgpt paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_bot_chatgpt_config_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_chatgpt_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_chatgpt_container_src_path }}", when: "{{ matrix_bot_chatgpt_container_image_self_build }}"}
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure chatgpt environment variables file created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/env.j2"
|
||||
dest: "{{ matrix_bot_chatgpt_config_path }}/env"
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
mode: 0640
|
||||
|
||||
- name: Ensure chatgpt container image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_bot_chatgpt_container_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_chatgpt_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_chatgpt_container_image_force_pull }}"
|
||||
when: "not matrix_bot_chatgpt_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ devture_playbook_help_container_retries_count }}"
|
||||
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- when: matrix_bot_chatgpt_container_image_self_build | bool
|
||||
block:
|
||||
- name: Ensure chatgpt repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_chatgpt_container_image_self_build_repo }}"
|
||||
version: "{{ matrix_bot_chatgpt_container_image_self_build_repo_version }}"
|
||||
dest: "{{ matrix_bot_chatgpt_container_src_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_name }}"
|
||||
register: matrix_bot_chatgpt_git_pull_results
|
||||
|
||||
- name: Ensure chatgpt container image is built
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_bot_chatgpt_container_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_bot_chatgpt_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_chatgpt_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_bot_chatgpt_container_src_path }}"
|
||||
pull: true
|
||||
|
||||
- name: Ensure chatgpt container network is created
|
||||
community.general.docker_network:
|
||||
enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
|
||||
name: "{{ matrix_bot_chatgpt_container_network }}"
|
||||
driver: bridge
|
||||
driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
|
||||
|
||||
- name: Ensure matrix-bot-chatgpt.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-chatgpt.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-chatgpt.service"
|
||||
mode: 0644
|
||||
@@ -1,26 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2023 Slavi Pantaleev
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
|
||||
-
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-chatgpt
|
||||
- install-all
|
||||
- install-bot-chatgpt
|
||||
block:
|
||||
- when: matrix_bot_chatgpt_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
|
||||
- when: matrix_bot_chatgpt_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-bot-chatgpt
|
||||
block:
|
||||
- when: not matrix_bot_chatgpt_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/uninstall.yml"
|
||||
@@ -1,30 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2023 Slavi Pantaleev
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-chatgpt service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-chatgpt.service"
|
||||
register: matrix_bot_chatgpt_service_stat
|
||||
|
||||
- when: matrix_bot_chatgpt_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-chatgpt is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-chatgpt
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-bot-chatgpt.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-chatgpt.service"
|
||||
state: absent
|
||||
|
||||
- name: Ensure Matrix chatgpt paths don't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_chatgpt_base_path }}"
|
||||
state: absent
|
||||
@@ -1,44 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
# SPDX-FileCopyrightText: 2023 Slavi Pantaleev
|
||||
# SPDX-FileCopyrightText: 2025 Suguru Hirahara
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
---
|
||||
|
||||
- name: Fail if required Chatgpt settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item.name }}`).
|
||||
when: "item.when | bool and lookup('vars', item.name, default='') | string | length == 0"
|
||||
with_items:
|
||||
- {'name': 'matrix_bot_chatgpt_openai_api_key', when: true}
|
||||
- {'name': 'matrix_bot_chatgpt_matrix_bot_username', when: true}
|
||||
- {'name': 'matrix_bot_chatgpt_container_network', when: true}
|
||||
- {'name': 'matrix_bot_chatgpt_matrix_homeserver_url', when: true}
|
||||
|
||||
- name: Fail if OpenAI configuration not up-to-date.
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable that is no longer used.
|
||||
Please change your configuration to remove the variable (`{{ item.name }}`).
|
||||
when: "lookup('ansible.builtin.varnames', ('^' + item.name + '$'), wantlist=True) | length > 0"
|
||||
with_items:
|
||||
- {'name': 'matrix_bot_chatgpt_openai_email'}
|
||||
- {'name': 'matrix_bot_chatgpt_openai_password'}
|
||||
- {'name': 'matrix_bot_chatgpt_openai_login_type'}
|
||||
|
||||
- name: (Deprecation) Catch and report renamed ChatGPT settings
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable, which now has a different name.
|
||||
Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml).
|
||||
when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0"
|
||||
with_items:
|
||||
- {'old': 'matrix_bot_chatgpt_docker_image', 'new': 'matrix_bot_chatgpt_container_image'}
|
||||
- {'old': 'matrix_bot_chatgpt_docker_image_name_prefix', 'new': 'matrix_bot_chatgpt_container_image_name_prefix'}
|
||||
- {'old': 'matrix_bot_chatgpt_docker_image_force_pull', 'new': 'matrix_bot_chatgpt_container_image_force_pull'}
|
||||
- {'old': 'matrix_bot_chatgpt_docker_repo', 'new': 'matrix_bot_chatgpt_container_image_self_build_repo'}
|
||||
- {'old': 'matrix_bot_chatgpt_docker_repo_version', 'new': 'matrix_bot_chatgpt_container_image_self_build_repo_version'}
|
||||
- {'old': 'matrix_bot_chatgpt_docker_src_files_path', 'new': 'matrix_bot_chatgpt_container_src_path'}
|
||||
- {'old': 'matrix_bot_chatgpt_container_image_name_prefix', 'new': 'matrix_bot_chatgpt_container_image_registry_prefix'}
|
||||
@@ -1,41 +0,0 @@
|
||||
{#
|
||||
SPDX-FileCopyrightText: 2023 Joe Kappus
|
||||
SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
SPDX-FileCopyrightText: 2023 Slavi Pantaleev
|
||||
SPDX-FileCopyrightText: 2024 Suguru Hirahara
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
#}
|
||||
|
||||
MATRIX_HOMESERVER_URL={{ matrix_bot_chatgpt_matrix_homeserver_url }}
|
||||
MATRIX_ACCESS_TOKEN={{ matrix_bot_chatgpt_matrix_access_token }}
|
||||
|
||||
OPENAI_API_KEY={{ matrix_bot_chatgpt_openai_api_key }}
|
||||
CHATGPT_CONTEXT={{ matrix_bot_chatgpt_context }}
|
||||
CHATGPT_API_MODEL={{ matrix_bot_chatgpt_api_model }}
|
||||
|
||||
KEYV_BACKEND={{ matrix_bot_chatgpt_keyv_backend }}
|
||||
KEYV_URL={{ matrix_bot_chatgpt_keyv_url }}
|
||||
KEYV_BOT_ENCRYPTION={{ matrix_bot_chatgpt_keyv_bot_encryption|lower }}
|
||||
KEYV_BOT_STORAGE={{ matrix_bot_chatgpt_keyv_bot_storage|lower }}
|
||||
|
||||
# With the @ and :example.com, ie @bot.chatgpt:example.com
|
||||
MATRIX_BOT_USERNAME={{ matrix_bot_chatgpt_matrix_bot_username }}
|
||||
MATRIX_BOT_PASSWORD={{ matrix_bot_chatgpt_matrix_bot_password }}
|
||||
|
||||
MATRIX_DEFAULT_PREFIX={{ matrix_bot_chatgpt_matrix_default_prefix }}
|
||||
MATRIX_DEFAULT_PREFIX_REPLY={{ matrix_bot_chatgpt_matrix_default_prefix_reply|lower }}
|
||||
|
||||
MATRIX_BLACKLIST={{ matrix_bot_chatgpt_matrix_blacklist }}
|
||||
MATRIX_WHITELIST={{ matrix_bot_chatgpt_matrix_whitelist }}
|
||||
|
||||
MATRIX_AUTOJOIN={{ matrix_bot_chatgpt_matrix_autojoin|lower }}
|
||||
MATRIX_ENCRYPTION={{ matrix_bot_chatgpt_matrix_encryption|lower }}
|
||||
MATRIX_THREADS={{ matrix_bot_chatgpt_matrix_threads|lower }}
|
||||
MATRIX_RICH_TEXT={{ matrix_bot_chatgpt_matrix_rich_text|lower }}
|
||||
|
||||
CHATGPT_PROMPT_PREFIX={{ matrix_bot_chatgpt_matrix_bot_prompt_prefix }}
|
||||
|
||||
DATA_PATH=/data/
|
||||
|
||||
{{ matrix_bot_chatgpt_environment_variables_extension }}
|
||||
@@ -1,49 +0,0 @@
|
||||
#jinja2: lstrip_blocks: True
|
||||
[Unit]
|
||||
Description=Matrix chatgpt bot
|
||||
{% for service in matrix_bot_chatgpt_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_bot_chatgpt_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ matrix_bot_chatgpt_container_stop_grace_time_seconds }} matrix-bot-chatgpt 2>/dev/null || true'
|
||||
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-chatgpt 2>/dev/null || true'
|
||||
|
||||
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
|
||||
--rm \
|
||||
--name=matrix-bot-chatgpt \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--read-only \
|
||||
--tmpfs /tmp \
|
||||
--network={{ matrix_bot_chatgpt_container_network }} \
|
||||
--env-file={{ matrix_bot_chatgpt_config_path }}/env \
|
||||
--mount type=bind,src={{ matrix_bot_chatgpt_data_path }},dst=/data \
|
||||
--env HOME=/data/home \
|
||||
{% for arg in matrix_bot_chatgpt_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_bot_chatgpt_container_image }}
|
||||
|
||||
{% for network in matrix_bot_chatgpt_container_additional_networks %}
|
||||
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-bot-chatgpt
|
||||
{% endfor %}
|
||||
|
||||
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-bot-chatgpt
|
||||
|
||||
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ matrix_bot_chatgpt_container_stop_grace_time_seconds }} matrix-bot-chatgpt 2>/dev/null || true'
|
||||
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-chatgpt 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-bot-chatgpt
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,5 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2023 - 2025 Slavi Pantaleev
|
||||
SPDX-FileCopyrightText: 2023 MDAD project contributors
|
||||
SPDX-FileCopyrightText: 2023 Vladimir Panteleev
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
@@ -534,6 +534,18 @@
|
||||
The following variables in your configuration need to be renamed: {{ lookup('ansible.builtin.varnames', '^devture_container_socket_proxy_.+', wantlist=True) | join(', ') }}
|
||||
when: "lookup('ansible.builtin.varnames', '^devture_container_socket_proxy_.+', wantlist=True) | length > 0"
|
||||
|
||||
- name: (Deprecation) Catch and report matrix-chatgpt-bot variables
|
||||
ansible.builtin.fail:
|
||||
msg: |-
|
||||
matrix-chatgpt-bot was completely removed from the playbook in November 2025.
|
||||
|
||||
Please remove all `matrix_bot_chatgpt_*` variables from your configuration file (vars.yml).
|
||||
|
||||
You may also wish to uninstall the bot manually. See `docs/configuring-playbook-bot-chatgpt.md` for more information.
|
||||
|
||||
The following variables in your configuration need to be removed: {{ lookup('ansible.builtin.varnames', '^matrix_bot_chatgpt_.+', wantlist=True) | join(', ') }}
|
||||
when: "lookup('ansible.builtin.varnames', '^matrix_bot_chatgpt_.+', wantlist=True) | length > 0"
|
||||
|
||||
- name: (Deprecation) Catch and report mautrix-hangouts variables
|
||||
ansible.builtin.fail:
|
||||
msg: |-
|
||||
|
||||
Reference in New Issue
Block a user