From ac9cef82cc32f1963d1381d2d52d02f92a9979e9 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Wed, 29 Jan 2025 23:41:29 +0800 Subject: [PATCH] chore: migrations --- README.md | 3 +- pkg/core/migrations/m021_lark_config.py | 29 ++++++++ templates/platform.json | 7 ++ templates/schema/platform.json | 92 +++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 pkg/core/migrations/m021_lark_config.py diff --git a/README.md b/README.md index 4a797659..c7fb4d43 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ ## ✨ Features -- 💬 大模型对话、Agent:支持多种大模型,适配群聊和私聊;具有多轮对话、工具调用、多模态能力,并深度适配 [Dify](https://dify.ai)。目前支持 QQ、QQ频道、企业微信,后续还将支持微信、WhatsApp、Discord等平台。 +- 💬 大模型对话、Agent:支持多种大模型,适配群聊和私聊;具有多轮对话、工具调用、多模态能力,并深度适配 [Dify](https://dify.ai)。目前支持 QQ、QQ频道、企业微信、飞书,后续还将支持微信、WhatsApp、Discord等平台。 - 🛠️ 高稳定性、功能完备:原生支持访问控制、限速、敏感词过滤等机制;配置简单,支持多种部署方式。 - 🧩 插件扩展、活跃社区:支持事件驱动、组件扩展等插件机制;丰富生态,目前已有数十个[插件](https://docs.langbot.app/plugin/plugin-intro.html) - 😻 [New] Web 管理面板:支持通过浏览器管理 LangBot 实例,具体支持功能,查看[文档](https://docs.langbot.app/webui/intro.html) @@ -83,6 +83,7 @@ | QQ 个人号 | ✅ | QQ 个人号私聊、群聊 | | QQ 官方机器人 | ✅ | QQ 频道机器人,支持频道、私聊、群聊 | | 企业微信 | ✅ | | +| 飞书 | ✅ | | | 钉钉 | 🚧 | | 🚧: 正在开发中 diff --git a/pkg/core/migrations/m021_lark_config.py b/pkg/core/migrations/m021_lark_config.py new file mode 100644 index 00000000..04c83caf --- /dev/null +++ b/pkg/core/migrations/m021_lark_config.py @@ -0,0 +1,29 @@ +from __future__ import annotations + +from .. import migration + + +@migration.migration_class("lark-config", 21) +class LarkConfigMigration(migration.Migration): + """迁移""" + + async def need_migrate(self) -> bool: + """判断当前环境是否需要运行此迁移""" + + for adapter in self.ap.platform_cfg.data['platform-adapters']: + if adapter['adapter'] == 'lark': + return False + + return True + + async def run(self): + """执行迁移""" + self.ap.platform_cfg.data['platform-adapters'].append({ + "adapter": "lark", + "enable": False, + "app_id": "cli_abcdefgh", + "app_secret": "XXXXXXXXXX", + "bot_name": "LangBot" + }) + + await self.ap.platform_cfg.dump_config() diff --git a/templates/platform.json b/templates/platform.json index 299656fd..b440264b 100644 --- a/templates/platform.json +++ b/templates/platform.json @@ -35,6 +35,13 @@ "token": "", "EncodingAESKey": "", "contacts_secret": "" + }, + { + "adapter": "lark", + "enable": false, + "app_id": "cli_abcdefgh", + "app_secret": "XXXXXXXXXX", + "bot_name": "LangBot" } ], "track-function-calls": true, diff --git a/templates/schema/platform.json b/templates/schema/platform.json index 074c9ae2..900623b8 100644 --- a/templates/schema/platform.json +++ b/templates/schema/platform.json @@ -121,6 +121,98 @@ ] } } + }, + { + "title": "企业微信适配器", + "description": "用于接入企业微信", + "properties": { + "adapter": { + "type": "string", + "const": "wecom" + }, + "enable": { + "type": "boolean", + "default": false, + "description": "是否启用此适配器", + "layout": { + "comp": "switch", + "props": { + "color": "primary" + } + } + }, + "host": { + "type": "string", + "default": "0.0.0.0", + "description": "监听的IP地址" + }, + "port": { + "type": "integer", + "default": 2290, + "description": "监听的端口" + }, + "corpid": { + "type": "string", + "default": "", + "description": "企业微信的corpid" + }, + "secret": { + "type": "string", + "default": "", + "description": "企业微信的secret" + }, + "token": { + "type": "string", + "default": "", + "description": "企业微信的token" + }, + "EncodingAESKey": { + "type": "string", + "default": "", + "description": "企业微信的EncodingAESKey" + }, + "contacts_secret": { + "type": "string", + "default": "", + "description": "企业微信的contacts_secret" + } + } + }, + { + "title": "飞书适配器", + "description": "用于接入飞书", + "properties": { + "adapter": { + "type": "string", + "const": "lark" + }, + "enable": { + "type": "boolean", + "default": false, + "description": "是否启用此适配器", + "layout": { + "comp": "switch", + "props": { + "color": "primary" + } + } + }, + "app_id": { + "type": "string", + "default": "", + "description": "飞书的app_id" + }, + "app_secret": { + "type": "string", + "default": "", + "description": "飞书的app_secret" + }, + "bot_name": { + "type": "string", + "default": "", + "description": "飞书的bot_name" + } + } } ] }