{"id":13635103,"url":"https://github.com/ConnectAI-E/Feishu-ChatGLM","last_synced_at":"2025-04-19T03:34:18.765Z","repository":{"id":152510039,"uuid":"626167715","full_name":"ConnectAI-E/Feishu-ChatGLM","owner":"ConnectAI-E","description":"🍋 python版本基于ChatGLM的飞书机器人","archived":false,"fork":false,"pushed_at":"2023-05-28T02:39:18.000Z","size":222,"stargazers_count":61,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T13:15:35.760Z","etag":null,"topics":["chatglm","chatglm-api","connect-ai","feishu-bot","python"],"latest_commit_sha":null,"homepage":"https://www.connectai-e.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ConnectAI-E.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-10T23:57:56.000Z","updated_at":"2024-12-22T03:50:17.000Z","dependencies_parsed_at":"2024-01-14T13:07:01.141Z","dependency_job_id":null,"html_url":"https://github.com/ConnectAI-E/Feishu-ChatGLM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectAI-E%2FFeishu-ChatGLM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectAI-E%2FFeishu-ChatGLM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectAI-E%2FFeishu-ChatGLM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectAI-E%2FFeishu-ChatGLM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ConnectAI-E","download_url":"https://codeload.github.com/ConnectAI-E/Feishu-ChatGLM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249600503,"owners_count":21297707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatglm","chatglm-api","connect-ai","feishu-bot","python"],"created_at":"2024-08-02T00:00:40.730Z","updated_at":"2025-04-19T03:34:18.448Z","avatar_url":"https://github.com/ConnectAI-E.png","language":"Python","funding_links":[],"categories":["企联AI","AI集成"],"sub_categories":[],"readme":"# Feishu-ChatGLM\n🍎 一套使用chatGLM模型，能够调用本地知识库的python版飞书**智能**聊天机器人实现方案。  \n\n## 实现思路  \n预计使用使用python为主要开发语言，调用huggingface中的chatGLM模型并实现对话api，利用langchain框架中的 Agent 和 Indexes 模块来处理对话角色和私有数据库的逻辑。\n\n🚀 预计需要完成的功能列表:\n\n✨ 产品规划\n\n- [X] python版飞书机器人实现  \n- [X] ChatGLM 聊天 api 实现  \n- [ ] 利用 langchain 的 agent 模块实现多角色的丝滑转换能力  \n- [ ] 利用 langchain 的 indexes 模块实现两种类型的本地知识读取  \n  - [ ] 一个文件夹内的多个txt文件读取和索引  \n  - [ ] 一个超长文本文件的分片读取和索引  \n- [ ] 两种 chatGLM与 本地知识交互类型的逻辑开发  \n  - [ ] 预设部分知识嵌入的聊天机器人实现  \n  - [ ] 根据用户输入内容动态处理需要嵌入的知识内容实现  \n\n\n✨ 功能列表\n- 单聊自动记忆上下文，不需要飞书回复机器人(更符合聊天直觉) \n- 输入 `/new` 清除历史上下文开启新会话  \n- 同时支持openai, azure, chatGLM 的模型接口 \n  \n    \n    \n## 聊天截图\n![chat](img/chat.png)  \n  \n  \n  \n## 本地部署使用方法\n\n建议环境：conda环境 python 3.10，以下命令为 linux 命令行SHELL命令，windows请根据类似情况调整\n\n### STEP1 启动 chatGLM 的api  \n1. 此步骤可以在本机，也可以在服务器等其他机器，即 `src/chatglm_sever` 这个模块可以移至其他任何地方运行\n2. 安装conda环境，切换conda环境（步骤略）\n3. `cd ./src/chatglm_server`\n4. `pip install -r requirements.txt`  安装 python 依赖包, pytorch 的安装会要比较长的时间\n5. `python chatglm_server.py` 启动 chatGLM api 服务\n6. 第一次启动需要下载 chatGLM 模型，时间会比较久，默认是 'THUDM/chatglm-6b-int4' \n7. 默认支持cpu、gpu、多卡gpu进行部署，一些参数的调整见脚本`server.py`的开头部分\n8. 记录好部署ip地址和端口号（如果为本机和默认配置，则为 http://localhost:8000\n\n  \n详细流程见chatGLM官方github: https://github.com/THUDM/ChatGLM-6B  \n也可以使用网上别人搭建的用来试用的 chatGLM api 测试（若如此可跳过以上步骤）\n\n### STEP2 启动飞机机器人所需服务\n1. `cd ..` 回到项目根目录 \n2. `mv config-example.yml config.yml` 给配置文件改名  \n3. `vim config.yml` 根据yml文件中的提示修改配置  \n4. `pip install -r requirements.txt`  安装 python 依赖包\n5. run `python3 src/main.py`\n\n\n### STEP3 创建飞书机器人，并使用测试用的公网地址  \n- 前往开发者平台创建应用,并获取到 APPID 和 Secret\n- 前往应用功能-机器人, 创建机器人\n- 从 cpolar、serverless 或 Railway 获得公网地址，在飞书机器人后台的 事件订阅 板块填写。例如，\nhttp://xxxx.r6.cpolar.top为 cpolar 暴露的公网地址\n/webhook/event为统一的应用路由\n最终的回调地址为 http://xxxx.r6.cpolar.top/webhook/event\n- 在飞书机器人后台的 机器人 板块，填写消息卡片请求网址。例如，\nhttp://xxxx.r6.cpolar.top为 cpolar 暴露的公网地址\n/webhook/card为统一的应用路由\n- 最终的消息卡片请求网址为 http://xxxx.r6.cpolar.top/webhook/card\n- 在事件订阅板块，搜索三个词机器人进群、 接收消息、 消息已读, 把他们后面所有的权限全部勾选。 进入权限管理界面，搜索图片, 勾选获取与上传图片或文件资源。 最终会添加下列回调事件\n```im:resource(获取与上传图片或文件资源)\nim:message\nim:message.group_at_msg(获取群组中所有消息)\nim:message.group_at_msg:readonly(接收群聊中@机器人消息事件)\nim:message.p2p_msg(获取用户发给机器人的单聊消息)\nim:message.p2p_msg:readonly(读取用户发给机器人的单聊消息)\nim:message:send_as_bot(获取用户在群组中@机器人的消息)\nim:chat:readonly(获取群组信息)\nim:chat(获取与更新群组信息)\n```\n## Docker部署方法（待更新）\n\n\n## 赞助感谢\n\n友情感谢 'Find My AI' 提供的部分经费赞助！\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FConnectAI-E%2FFeishu-ChatGLM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FConnectAI-E%2FFeishu-ChatGLM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FConnectAI-E%2FFeishu-ChatGLM/lists"}