-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# QChatGPT 3.x 新扩展方式草案 | ||
|
||
## 背景 | ||
|
||
### 历史问题 | ||
|
||
在过去的实践中,QChatGPT 直接从 `plugins` 目录下加载所有`.py`文件,这些文件中可以自由自定义类和函数,并通过 QChatGPT 提供的 API 注册插件类。但在实践中,我们发现此种加载方式存在以下问题: | ||
|
||
#### 设计上的 | ||
|
||
- 插件类命名和插件包(目录)命名不符,造成混乱。 | ||
- 一个插件内实际上可以注册多个插件类,未强制限定。 | ||
- 插件需要的依赖由 QChatGPT 动态安装,这对网络环境较差的用户以及使用 Docker 的情况很不友好。 | ||
- 通过源代码发布的插件代码,管理松散,不利于分发。 | ||
|
||
#### 加载逻辑上的 | ||
|
||
- 遍历插件目录下所有py模块,无统一的入口 | ||
|
||
### 未来需求 | ||
|
||
- QChatGPT 可能会以可执行文件的形式发布,这时动态安装依赖将不再可行。 | ||
- 插件的发布和管理需要更加规范和统一的方式。 | ||
|
||
## 设计 | ||
|
||
在新的扩展方案中, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class PluginClass: | ||
|
||
name: str | ||
|
||
def __init__(self) -> None: | ||
self.name = "Basic Plugin" | ||
|
||
def get_name(self) -> str: | ||
return self.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class PluginClass: | ||
|
||
name: str | ||
|
||
def __init__(self) -> None: | ||
self.name = "Basic Plugin Inner" | ||
|
||
def get_name(self) -> str: | ||
return self.name |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import sys | ||
|
||
sys.path.insert(0, "exts/basic.zip") | ||
|
||
import basic | ||
|
||
print(basic.PluginClass().get_name()) |