BobMaster's Blog

生活的点滴-是热爱呀

为Mattermost对接AI聊天与作画机器人

Mattermost是开源的团队沟通协作平台,可以简单的理解为slack的开源替代品。这篇文章向大家介绍如何将AI对话与作图功能集成到Mattermost里。

使用到的项目mattermost_bot: https://github.com/hibobmaster/mattermost_bot

为了方便,我们采用docker部署机器人,SSH连上服务器后,假设工作目录是 /opt/mattermost_bot ,在此目录下创建一个 compose.yaml 文件

services:
    app:
      image: ghcr.io/hibobmaster/mattermost_bot:latest
      container_name: mattermost_bot_lala
      restart: unless-stopped
      volumes:
        - ./config.json:/app/config.json
      networks:
        - mattermost_network

networks:
  mattermost_network:

接着创建 config.json 配置文件

{
    "server_url": "chat.quanquan.space",
    "email": "xxxxxx@quanquan.space",
    "password": "xxxxxxxxxxxxx",
    "username": "@ai",
    "openai_api_key": "xxxxxxxxxxxxxxxx",
    "gpt_api_endpoint": "https://xxxxxxxxxx.xxxxxxxxxxx/v1/chat/completions",
    "image_generation_endpoint": "https://xxxxxxxxxx.xxxxxxxxx/v1/images/generations",
    "image_generation_backend": "localai"
}

这里简单解释一下

server_url: mattermost实例的域名
email: 机器人账号的邮箱
password: 机器人账号的密码
username: 机器人账号用户名(别漏了@)
openai_api_key: 如果需要的话就填写在这里
gpt_api_endpoint: 支持与openai api兼容的各种后端,去除该选项默认为官方接口
image_generation_endpoint: 作图后端api地址
image_generation_backend: openai或sdwui或localai,分别对应不同的服务

更多详细配置见: https://github.com/hibobmaster/mattermost_bot/wiki


都配置好后,我们启动容器

docker compose up

如果一切正常,Ctrl+C终止容器,最后将容器运行在后台模式

docker compose up -d

在聊天室中可以使用!help指令获取帮助,AI对话和作图的效果如下


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注


©BobMaster 2018~2024