https://github.com/ConnectAI-E/Feishu-Wenxin
🍍飞书 × 百度文心一言 = 点亮灵感,享受国内模型的心流体验
https://github.com/ConnectAI-E/Feishu-Wenxin
connect-ai ernie feishu feishu-bot go golang wenxinyiyan
Last synced: 6 months ago
JSON representation
🍍飞书 × 百度文心一言 = 点亮灵感,享受国内模型的心流体验
- Host: GitHub
- URL: https://github.com/ConnectAI-E/Feishu-Wenxin
- Owner: ConnectAI-E
- License: gpl-3.0
- Created: 2023-05-30T01:52:30.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-30T23:04:48.000Z (about 2 years ago)
- Last Synced: 2025-03-31T13:15:38.660Z (6 months ago)
- Topics: connect-ai, ernie, feishu, feishu-bot, go, golang, wenxinyiyan
- Language: Go
- Homepage: https://www.connectai-e.com
- Size: 1.06 MB
- Stars: 39
- Watchers: 1
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
📷 点击展开完整功能
![]()
![]()
飞书 × 文心一言
🚀 Feishu WenXin 🚀
😀企联AI共创计划正式开启😀
www.connectai-e.com|
AI|SDK
| Application |
| :---------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
| 🎒OpenAI | [Go-OpenAI](https://github.com/ConnectAI-E/Go-OpenAI) | [🏅Feishu-OpenAI](https://github.com/ConnectAI-E/Feishu-OpenAI), [Lark-OpenAI](https://github.com/ConnectAI-E/Lark-OpenAI), [Feishu-EX-ChatGPT](https://github.com/ConnectAI-E/Feishu-EX-ChatGPT), [Feishu-OpenAI-Stream-Chatbot](https://github.com/ConnectAI-E/Feishu-OpenAI-Stream-Chatbot), [Feishu-OpenAI-Amazing](https://github.com/ConnectAI-E/Feishu-OpenAI-Amazing), [Feishu-Oral-Friend](https://github.com/ConnectAI-E/Feishu-Oral-Friend), [Feishu-OpenAI-Base-Helper](https://github.com/ConnectAI-E/Feishu-OpenAI-Base-Helper), [Feishu-Vector-Knowledge-Management](https://github.com/ConnectAI-E/Feishu-Vector-Knowledge-Management), [Feishu-OpenAI-PDF-Helper](https://github.com/ConnectAI-E/Feishu-OpenAI-PDF-Helper), [🏅Dingtalk-OpenAI](https://github.com/ConnectAI-E/Dingtalk-OpenAI), [Wework-OpenAI](https://github.com/ConnectAI-E/Wework-OpenAI), [WeWork-OpenAI-Node](https://github.com/ConnectAI-E/WeWork-OpenAI-Node), [llmplugin](https://github.com/ConnectAI-E/llmplugin) |
| 🎭 Stablediffusion | ------ | [🏅Feishu-Stablediffusion](https://github.com/ConnectAI-E/Feishu-Stablediffusion) |
| 🍎 Midjourney | [Go-Midjourney](https://github.com/ConnectAI-E/Feishu-Midjourney/tree/main/midjourney) | [🏅Feishu-Midjourney](https://github.com/ConnectAI-E/Feishu-Midjourney), [MidJourney-Web](https://github.com/ConnectAI-E/MidJourney-Web), [Dingtalk-Midjourney](https://github.com/ConnectAI-E/Dingtalk-Midjourney) |
| 🍍 文心一言 | [Go-Wenxin](https://github.com/ConnectAI-E/Go-Wenxin) | [Feishu-Wenxin](https://github.com/ConnectAI-E/Feishu-Wenxin), [Dingtalk-Wenxin](https://github.com/ConnectAI-E/Dingtalk-Wenxin), [Wework-Wenxin](https://github.com/ConnectAI-E/Wework-Wenxin) |
| 💸 Minimax | [Go-Minimax](https://github.com/ConnectAI-E/Go-Minimax) | [Feishu-Minimax](https://github.com/ConnectAI-E/Feishu-Minimax), [Dingtalk-Minimax](https://github.com/ConnectAI-E/Dingtalk-Minimax), [Wework-Minimax](https://github.com/ConnectAI-E/Wework-Minimax) |
| ⛳️ CLAUDE | [Go-Claude](https://github.com/ConnectAI-E/Go-Claude) | [Feishu-Claude](https://github.com/ConnectAI-E/Feishu-Claude), [DingTalk-Claude](https://github.com/ConnectAI-E/DingTalk-Claude), [Wework-Claude](https://github.com/ConnectAI-E/Wework-Claude) |
| 🎡 Prompt | | [Prompt-Engineering-Tutior](https://github.com/ConnectAI-E/Prompt-Engineering-Tutior) |
| 🤖️ ChatGLM | | [Feishu-ChatGLM](https://github.com/ConnectAI-E/Feishu-ChatGLM) |## 👻 机器人功能
🗣 语音交流:私人直接与机器人畅所欲言
💬 多话题对话:支持私人和群聊多话题讨论,高效连贯
🔄 上下文保留:回复对话框即可继续同一话题讨论
⏰ 自动结束:超时自动结束对话,支持清除讨论历史
📝 富文本卡片:支持富文本卡片回复,信息更丰富多彩
👍 交互式反馈:即时获取机器人处理结果
## 🌟 项目特点
- 🍏 对话基于 文心一言 (https://ai.baidu.com/wenxinworkshop/app/overview) 接口 和 [go-wenxin](https://github.com/ConnectAI-E/go-wenxin) SDK
- 🍎 将 文心一言 接入[飞书](https://open.feishu.cn/app)和[飞书国际版](https://www.larksuite.com/)
- 🥒 支持[Serverless 云函数](https://github.com/serverless-devs/serverless-devs)、[本地环境](https://dashboard.cpolar.com/login)、[Docker](https://www.docker.com/)、[二进制安装包](https://github.com/Leizhenpeng/feishu-chatgpt/releases/)
等多种渠道部署
- 🍋 基于[goCache](https://github.com/patrickmn/go-cache)内存键值对缓存## 项目部署
###### 有关飞书的配置文件说明,**[➡︎ 点击查看](#详细配置步骤)**
本地部署
```bash
git clone git@github.com:Leizhenpeng/feishu-wenxin.git
cd feishu-wenxin/code
```如果你的服务器没有公网 IP,可以使用反向代理的方式
飞书的服务器在国内对 ngrok 的访问速度很慢,所以推荐使用一些国内的反向代理服务商
- [cpolar](https://dashboard.cpolar.com/)
- [natapp](https://natapp.cn/)```bash
# 配置config.yaml
mv config.example.yaml config.yaml//测试部署
go run main.go
cpolar http 9000//正式部署
nohup cpolar http 9000 -log=stdout &//查看服务器状态
https://dashboard.cpolar.com/status// 下线服务
ps -ef | grep cpolar
kill -9 PID
```更多详细介绍,参考[飞书上的小计算器: Go 机器人来啦](https://www.bilibili.com/video/BV1nW4y1378T/)
serverless云函数(阿里云等)部署
```bash
git clone git@github.com:Leizhenpeng/feishu-wenxin.git
cd feishu-wenxin/code
```安装[severless](https://docs.serverless-devs.com/serverless-devs/quick_start)工具
```bash
# 配置config.yaml
mv config.example.yaml config.yaml
# 安装severless cli
npm install @serverless-devs/s -g
```安装完成后,请根据您本地环境,根据下面教程部署`severless`
- 本地 `linux`/`mac os` 环境
1. 修改`s.yaml`中的部署地区和部署秘钥
```
edition: 1.0.0
name: feishuBot-wenxin
access: "aliyun" # 修改自定义的秘钥别称vars: # 全局变量
region: "cn-hongkong" # 修改云函数想要部署地区```
2. 一键部署
```bash
cd ..
s deploy
```- 本地`windows`
1. 首先打开本地`cmd`命令提示符工具,运行`go env`检查你电脑上 go 环境变量设置, 确认以下变量和值
```cmd
set GO111MODULE=on
set GOARCH=amd64
set GOOS=linux
set CGO_ENABLED=0
```如果值不正确,比如您电脑上为`set GOOS=windows`, 请运行以下命令设置`GOOS`变量值
```cmd
go env -w GOOS=linux
```2. 修改`s.yaml`中的部署地区和部署秘钥
```
edition: 1.0.0
name: feishuBot-chatGpt
access: "aliyun" # 修改自定义的秘钥别称vars: # 全局变量
region: "cn-hongkong" # 修改云函数想要部署地区```
3. 修改`s.yaml`中的`pre-deploy`, 去除第二步`run`前面的环变量改置部分
```
pre-deploy:
- run: go mod tidy
path: ./code
- run: go build -o
target/main main.go # 删除GO111MODULE=on GOOS=linux GOARCH=amd64 CGO_ENABLED=0
path: ./code```
4. 一键部署
```bash
cd ..
s deploy
```更多详细介绍,参考[仅需 1min,用 Serverless 部署基于 gin 的飞书机器人](https://www.bilibili.com/video/BV1nW4y1378T/)
docker部署
```bash
docker build -t feishu-chatgpt:latest .
docker run -d --name feishu-chatgpt -p 9000:9000 \
--env APP_ID=xxx \
--env APP_SECRET=xxx \
--env APP_ENCRYPT_KEY=xxx \
--env APP_VERIFICATION_TOKEN=xxx \
--env BOT_NAME=chatGpt \
--env WENXIN_CLIENT_ID="xxx" \
--env WENXIN_CLIENT_SECRET="xxx" \
feishu-chatgpt:latest
```注意:
- `BOT_NAME` 为飞书机器人名称,例如 `chatGpt`
- `WENXIN_CLIENT_ID` 为文心一言应用的 `API_Key`
- `WENXIN_CLIENT_SECRET` 为文心一言应用的 `Secret_Key`---
小白简易化 docker 部署
- docker 地址: https://hub.docker.com/r/leizhenpeng/feishu-chatgpt
```bash
docker run -d --restart=always --name feishu-chatgpt2 -p 9000:9000 -v /etc/localtime:/etc/localtim:ro \
--env APP_ID=xxx \
--env APP_SECRET=xxx \
--env APP_ENCRYPT_KEY=xxx \
--env APP_VERIFICATION_TOKEN=xxx \
--env BOT_NAME=chatGpt \
--env WENXIN_CLIENT_ID="xxx" \
--env WENXIN_CLIENT_SECRET="xxx" \
dockerproxy.com/leizhenpeng/feishu-wenxin:latest
```事件回调地址: http://IP:9000/webhook/event
卡片回调地址: http://IP:9000/webhook/card把它填入飞书后台
---
docker-compose 部署
编辑 docker-compose.yaml,通过 environment 配置相应环境变量(或者通过 volumes 挂载相应配置文件),然后运行下面的命令即可
```bash
# 构建镜像
docker compose build# 启动服务
docker compose up -d# 停止服务
docker compose down
```事件回调地址: http://IP:9000/webhook/event
卡片回调地址: http://IP:9000/webhook/card二进制安装包部署
1. 进入[release 页面](https://github.com/Leizhenpeng/feishu-wenxin/releases/) 下载对应的安装包
2. 解压安装包,修改 config.example.yml 中配置信息,另存为 config.yaml
3. 运行程序入口文件 `feishu-chatgpt`事件回调地址: http://IP:9000/webhook/event
卡片回调地址: http://IP:9000/webhook/card## 详细配置步骤
📸 点击展开飞书机器人配置的分步截图指导
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
- 获取 [文心一言](https://console.bce.baidu.com/ai/#/ai/wenxinworkshop/app/list) 的 API_Key、Secret_Key
- 创建 [飞书](https://open.feishu.cn/) 机器人
1. 前往[开发者平台](https://open.feishu.cn/app?lang=zh-CN)创建应用,并获取到 APPID 和 Secret
2. 前往`应用功能-机器人`, 创建机器人
3. 从 cpolar、serverless 或 Railway 获得公网地址,在飞书机器人后台的 `事件订阅` 板块填写。例如,
- `http://xxxx.r6.cpolar.top`为 cpolar 暴露的公网地址
- `/webhook/event`为统一的应用路由
- 最终的回调地址为 `http://xxxx.r6.cpolar.top/webhook/event`
4. 在飞书机器人后台的 `机器人` 板块,填写消息卡片请求网址。例如,
- `http://xxxx.r6.cpolar.top`为 cpolar 暴露的公网地址
- `/webhook/card`为统一的应用路由
- 最终的消息卡片请求网址为 `http://xxxx.r6.cpolar.top/webhook/card`
5. 在事件订阅板块,搜索三个词`机器人进群`、 `接收消息`、 `消息已读`, 把他们后面所有的权限全部勾选。
进入权限管理界面,搜索`图片`, 勾选`获取与上传图片或文件资源`。
最终会添加下列回调事件
- im:resource(获取与上传图片或文件资源)
- im:message
- im:message.group_at_msg(获取群组中所有消息)
- im:message.group_at_msg:readonly(接收群聊中@机器人消息事件)
- im:message.p2p_msg(获取用户发给机器人的单聊消息)
- im:message.p2p_msg:readonly(读取用户发给机器人的单聊消息)
- im:message:send_as_bot(获取用户在群组中@机器人的消息)
- im:chat:readonly(获取群组信息)
- im:chat(获取与更新群组信息)5. 发布版本,等待企业管理员审核通过
更多介绍,参考[飞书上的小计算器: Go 机器人来啦](https://www.bilibili.com/video/BV12M41187rV/)
## 商业支持
如果开源版无法满足您公司的需求,推荐您尝试企联AI的商业共创版
- 内置开箱即用的Azure Openai: 无需部署到海外,即可获得数十倍的性能提升
- 掌控全局的Admin Panel: AI资源管理、对话日志查询、风险词规避和对话权限管理
- 专人技术支持: 配备专业部署交付人员与后期一对一维护服务
- 同时提供在线Saas版/企业级私有部署查看更多内容: https://www.connectai-e.com
企业客户咨询: 15623677720
![]()
## 一起交流
遇到问题,可以加入飞书群沟通~