Skip to content

Commit a2408e7

Browse files
authored
Merge pull request #376 from LlmKira/dev
Refactor to v4
2 parents bcd012a + 5d4276e commit a2408e7

File tree

202 files changed

+7112
-494063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+7112
-494063
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,6 @@ config_dir/*.db
145145
/jobs.sqlite
146146
config_dir/*.pem
147147
config_dir/*.secret/
148+
/.pdm-python
149+
/.montydb/
150+
/.snapshot/

NOTICE.MD

-15
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,10 @@ Copyright (C) 2023 sudoskys
1717
along with this program. If not, see <https://www.gnu.org/licenses/>.
1818
```
1919

20-
## GPL2 License
21-
22-
The GPL2 license applies to the denpendencies of this project:
23-
24-
- pyTelegramBotAPI
25-
2620
## MIT License
2721

2822
The MIT license applies to the files in:
2923

3024
- folder: "llmkira/sdk/func_calling" from https://github.com/nonebot/nonebot2
3125
- folder: "llmkira/sdk/memory/redis" from https://github.com/langchain-ai/langchain
3226
- code: "llmkira/sdk/schema.py@parse_from_pydantic" from https://github.com/jxnl/instructor
33-
34-
## 仅对部署者的安全指南(For Deployer Only)
35-
36-
如果您部署本项目的代码,即表示您同意遵守 Apache-2.0 协议。
37-
38-
如其所在地法律特殊,不认为 Apache-2.0 协议所有条款均具有法律效力的,**且造成恶性法律后果的**,视为违约。
39-
40-
注意,本项目因为 Openai TOS 禁止中国区域故不构成网络产品 且 本项目不提供服务,不适用《网络安全法》的第 22
41-
条规定。但是您仍然可以提交[漏洞报告](https://github.com/LlmKira/Openaibot/security/advisories), 我们会尽快修复。

README.md

+91-137
Original file line numberDiff line numberDiff line change
@@ -26,198 +26,152 @@
2626
</p>
2727

2828
<p align="center">
29-
<a href="https://llmkira.github.io/Docs/">🍩 部署文档</a>
29+
<a href="https://llmkira.github.io/Docs/">🍩 Deploy Docs</a>
3030
&
31-
<a href="https://llmkira.github.io/Docs/dev/basic">🧀 开发文档</a>
31+
<a href="https://llmkira.github.io/Docs/dev/basic">🧀 Dev Docs</a>
3232
&
33-
<a href="README_EN.md">📝 English Readme</a>
34-
&
35-
<a href=".github/CONTRIBUTING.md">🤝 贡献必看</a>
33+
<a href=".github/CONTRIBUTING.md">🤝 Contribute</a>
3634
</p>
3735

36+
> Don't hesitate to Star ⭐️, Issue 📝, and PR 🛠️
3837
39-
> **Look for English README? Click [here](README_EN.md). We also have English
40-
documentation [here](https://llmkira.github.io/Docs/en).**
41-
42-
> 部署遇到问题?提交 Issue 帮助我们提升可用性
38+
> Python>=3.9
4339
44-
此项目为自部署,实用可扩展的机器人核心,以 `FunctionCall` `ToolCall` 为核心,支持多种消息平台。
40+
This project uses the ToolCall feature.
4541

46-
采用消息队列,很好处理函数请求,支持繁杂的插件和功能设计。良好支持文件系统。
42+
It integrates a message queuing and snapshot system, offering plugin mechanisms and authentication prior to plugin
43+
execution.
4744

48-
支持多种模型源,支持跨平台消息转发。
45+
The model adheres to the Openai Schema, other models are not supported. Please adapt using gateways independently.
4946

5047
| Demo |
5148
|-----------------------------------|
5249
| ![sticker](./docs/chain_chat.gif) |
5350

54-
与之前的项目不同的是,此项目尝试基于消息平台复刻 ChatGpt 的插件系统,实现部分或更进一步的功能。
55-
56-
> 因为 func call 为 feature,所以只支持 Openai 类型的 api, 不打算支持没有 func call 的 LLM
57-
5851
## 🍔 Roadmap
5952

60-
- [ ] 去除历史遗留代码
61-
- [ ] 删除计量系统
62-
- [ ] 删除模型选择系统,统一为 OpenAI Schema
63-
- [ ] 使用更好的插件系统
64-
- [ ] 简化项目结构
65-
- [ ] 尝试用本地化方案替代 RabbitMQ
66-
- [ ] 去除 Provider 体系
67-
68-
## 📦 Feature
69-
70-
- 🍪 完善的插件开发生态,采用经典设计,通过 `pip` 安装即可使用
71-
- 📝 消息系统,不限时间,不限发送端,定义发送接收者,逻辑完全解耦
72-
- 📎 路由消息,自定义消息路由,以路由决定运作方式
73-
- 📬 公共开放限额/私人自配置后端/代理Token认证,提供灵活可扩展的鉴权开发方案
74-
- 🍾 支持中间件拦截开发,开发扩展即可操作流程前后数据
75-
- 🎵 细化的统计系统,轻松统计使用情况
76-
- 🍰 支持插件人在回路验证,可鉴权,可设置插件黑名单
77-
- 📦 完善标准的文件交互支持,上传/下载文件
78-
- 🍖 支持个人单独配置环境密钥,为插件提供个人的私有环境变量
79-
- 🍟 支持大语言模型增量支持,支持多平台扩展,继承标准类即可适配
80-
- 🍔 同时支持 `FunctionCall` `ToolCall` 特性,根据模型动态构建需要的函数类
81-
82-
### 🧀 部分插件预览
83-
84-
| Sticker Converter | Timer Func | Translate Func |
85-
|-------------------------------------|---------------------------------|----------------------------------------------|
86-
| ![sticker](./docs/sticker_func.gif) | ![timer](./docs/timer_func.gif) | ![translate](./docs/translate_file_func.gif) |
87-
88-
### 🧀 认证系统介绍
53+
- [x] Removal of legacy code
54+
- [x] Deletion of metric system
55+
- [x] Deletion of model selection system, unified to OpenAI Schema
56+
- [x] Implementation of a more robust plugin system
57+
- [x] Project structure simplification
58+
- [x] Elimination of the Provider system
8959

90-
我们采用的认证系统称为 `Service Provider`,即服务提供商,它的作用是为每个发送者分配 Endpoint/Key/Model ,用于鉴权。
91-
拥有一个 `token` 作为绑定的 OpenKey。程序会调用设定的 `Service Provider` 读取私有 Key/配置 Token 来获取鉴权信息。
60+
## 📦 Features
9261

93-
![auth](./docs/SeriveProvider.svg)
62+
- 🍪 A comprehensive plugin development ecosystem, adopting a classic design, and seamless integration with plugins
63+
through `pip` installation
64+
- 📝 Message system with no time or sender constraints, offering fully decoupled logics
65+
- 📬 Offers Login via a URL mechanism, providing a flexible and expandable authentication development solution
66+
- 🍰 Empowers users to authorize plugin execution. Users can configure plugin environment variables at their discretion
67+
- 📦 Support for plugins to access files
68+
- 🍟 Multi-platform support – extend new platforms by inheriting the base class
69+
- 🍔 Plugins can determine their appearance in new sessions dynamically, preventing performance degradation despite large
70+
amounts of plugins
9471

95-
认证组件和后端均需要自行实现。
72+
### 🍔 Login Modes
9673

97-
### 🎬 平台支持
74+
- `Login via url`: Use `/login token#https://provider.com` to Login. The program posts the token to the interface to
75+
retrieve configuration information
76+
- `Login`: Use `/login https://api.com/v1#key#model` to login
9877

99-
| 平台 | 支持情况 | 文件系统 | 备注 |
100-
|----------|------|------|-------------|
101-
| Telegram ||| |
102-
| Discord ||| |
103-
| Kook ||| 不支持 `被回复启动` |
104-
| Slack ||| 不支持 `被回复启动` |
105-
| QQ || | |
106-
| Wechat || | |
107-
| Twitter || | |
108-
| Matrix || | |
109-
| IRC || | |
110-
| ... | | | 创建Issue/PR |
78+
### 🧀 Plugin Previews
11179

112-
## 📦 快速开始
80+
| Sticker Converter | Timer Function | Translate Function |
81+
|-------------------------------------|---------------------------------|----------------------------------------------|
82+
| ![sticker](./docs/sticker_func.gif) | ![timer](./docs/timer_func.gif) | ![translate](./docs/translate_file_func.gif) |
11383

114-
阅读 [🧀 部署文档](https://llmkira.github.io/Docs/) 获得更多信息。
84+
### 🎬 Platform Support
11585

116-
请提前用 `pdm run python3 start_sender.py` `pdm run python3 start_receiver.py` 测试是否能正常运行。
86+
| Platform | Support | File System | Remarks |
87+
|----------|---------|-------------|----------------------------------------|
88+
| Telegram ||| |
89+
| Discord ||| |
90+
| Kook ||| Does not support `triggering by reply` |
91+
| Slack ||| Does not support `triggering by reply` |
92+
| QQ || | |
93+
| Wechat || | |
94+
| Twitter || | |
95+
| Matrix || | |
96+
| IRC || | |
97+
| ... | | | Create Issue/PR |
11798

118-
#### 性能指标测试(Until 2023/11/1)
99+
## 📦 Quick Start
119100

120-
注意,不包括pm2,redis,rabbitmq,mongodb,docker等服务的内存占用。
101+
Refer to the [🧀 Deployment Document](https://llmkira.github.io/Docs/) for more information.
121102

122-
| 进程 | 内存均值 | 测算命令 | client |
123-
|------------|-----------|--------------------------------------------------|----------|
124-
| `receiver` | 120.202MB | `python3 -m memray run --live start_receiver.py` | telegram |
125-
| `sender` | 83.375MB | `python3 -m memray run --live start_sender.py` | telegram |
103+
```shell
104+
# Install RabbitMQ
105+
docker pull rabbitmq:3.10-management
106+
docker run -d -p 5672:5672 -p 15672:15672 \
107+
-e RABBITMQ_DEFAULT_USER=admin \
108+
-e RABBITMQ_DEFAULT_PASS=8a8a8a \
109+
--hostname myRabbit \
110+
--name rabbitmq \
111+
rabbitmq:3.10-management
112+
docker ps -l
113+
# Install Project
114+
pip install pdm
115+
pdm install -G bot
116+
cp .env.exp .env && nano .env
117+
# Test
118+
pdm run python3 start_sender.py
119+
pdm run python3 start_receiver.py
120+
# Host
121+
pdm start pm2.json
122+
```
126123

127124
### 🥣 Docker
128125

129126
Build Hub: [sudoskys/llmbot](https://hub.docker.com/repository/docker/sudoskys/llmbot/general)
130127

131-
#### 自动 Docker/Docker-compose安装
132-
133-
如果你在使用一台崭新的服务器,你可以使用下面的Shell来尝试自动安装本项目。
128+
#### Automatic Docker/Docker-compose Installation
134129

135-
此脚本会自动使用 Docker 方法安装所需服务并映射端口,如果您已经部署了 `redis``rabbitmq``mongodb`
130+
If you are using a brand new server, you can use the following shell to automatically install this project.
136131

137-
请自行修改 `docker-compose.yml` 文件。
132+
This script automatically installs the required services and maps ports using Docker methods. If you have
133+
deployed `redis`, `rabbitmq`, `mongodb`, please modify the `docker-compose.yml` file accordingly.
138134

139135
```shell
140-
141136
curl -sSL https://raw.githubusercontent.com/LLMKira/Openaibot/main/deploy.sh | bash
142137
```
143138

144-
#### 手动 Docker-compose安装
139+
#### Manual Docker-compose Installation
145140

146141
```shell
147142
git clone https://github.com/LlmKira/Openaibot.git
148143
cd Openaibot
149144
cp .env.exp .env&&nano .env
150145
docker-compose -f docker-compose.yml up -d
151-
152146
```
153147

154-
更新镜像使用 `docker-compose pull`
148+
Update image using `docker-compose pull`.
155149

156-
在 docker 中查看 Shell,使用 `docker exec -it llmbot /bin/bash`,输入 `exit` 退出。
150+
Use `docker exec -it llmbot /bin/bash` to view Shell in Docker, enter `exit` to exit.
157151

158-
### 🍔 Shell
159-
160-
人工使用Pm2启动,需要自行安装 `redis``rabbitmq``mongodb`
152+
## 🍪 Slash Commands
161153

162154
```shell
163-
git clone https://github.com/LlmKira/Openaibot.git
164-
pip install pdm
165-
cd Openaibot
166-
pdm install -G bot
167-
cp .env.exp .env && nano .env
168-
apt install npm -y && npm install pm2 && pm2 start pm2.json
169-
pm2 monit
170-
171-
```
172-
173-
重启程序使用 `pm2 restart pm2.json`
174-
175-
> 推荐使用 `pdm` 进行依赖管理,因为我们使用了 `pydantic^1.9.0`,为了防止出现版本冲突,我们使用了 `pdm` 进行依赖管理。
176-
177-
## 🍪 Slash Command
178-
179-
```shell
180-
clear - 删除聊天记录
181-
help - 显示文档
182-
chat - 对话
183-
task - 启用函数以对话
184-
ask - 禁止函数以对话
185-
tool - 列出所有函数
186-
set_endpoint - 设置私有 key 和 endpoint
187-
clear_endpoint - 清除私有 key 和 endpoint
188-
auth - 授权一个函数
189-
env - 函数环境变量
190-
token - 绑定令牌
191-
token_clear - 清除令牌绑定
192-
func_ban - 禁用一个函数
193-
func_unban - 解禁一个函数
194-
bind - 绑定消息源
195-
unbind - 解绑消息源
155+
clear - Deletes chat records
156+
help - Displays documentation
157+
chat - Conversation
158+
task - Use a function to converse
159+
ask - Disable function-based conversations
160+
tool - Lists all functions
161+
login - Login
162+
auth - Authorize a function
163+
env - Environment variables of the function
196164
```
197165

198-
## 💻 如何开发插件?
199-
200-
插件开发文档请参考 `plugins` 目录下的示例插件和 [🧀 插件开发文档](https://llmkira.github.io/Docs/dev/basic)
201-
202-
## 🤝 We need your help!
203-
204-
This is a long term project and we started the development of the LLM APP very early!
205-
206-
We applied a plugin-like system and search online before GPT3 OpenaiApi was released(davinci-003)
207-
208-
After many iterations, we have worked hard to make this project more standardized, generic, and open.
209-
210-
We can't do it on our own at the moment:
211-
212-
- [ ] We need help with the documentation
213-
- [ ] Web UI
166+
## 💻 How to Develop Plugins?
214167

215-
Feel free to submit a Pull Request or discuss, we'd love to receive your contribution!
168+
Refer to the example plugins in the `plugins` directory and
169+
the [🧀 Plugin Development Document](https://llmkira.github.io/Docs/dev/basic) for plugin development documentation.
216170

217-
## 📜 告知
171+
## 📜 Notice
218172

219-
> 此项目与 Openai 官方无关,全称为 OpenAiBot,表示开放人工智能机器人,并不表示为 Openai 所属机器人。
173+
> This project, named OpenAiBot, signifying "Open Artificial Intelligence Robot", is not officially affiliated with
174+
> OpenAI.
220175
221-
> 如果您所在辖区禁止使用 Openai 服务,请勿使用此项目。
222176

223177
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsudoskys%2FOpenaibot.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsudoskys%2FOpenaibot?ref=badge_small)

SECURITY.md

-12
This file was deleted.

app/__init__.py

Whitespace-only changes.

app/_exception.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ChainBuildException(Exception):
2+
pass

app/components/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)