Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 全新预设系统、插件系统,实现多模态支持高度可自定义化的 AI 助手 #755

Open
wants to merge 95 commits into
base: browser-version
Choose a base branch
from

Conversation

lss233
Copy link
Owner

@lss233 lss233 commented May 4, 2023

当前进度:

  • 预设系统
  • 插件系统
  • 中间件
  • 聊天平台维护
    • OneBot
    • Ariadne
    • Telegram
    • Discord
    • Wecom
    • HTTP
  • 中间件模块维护

本次更新如下:

稳定性提升

  • 移除每个账号独立使用代理的设计,整个程序使用一个代理设置。
    这个修改将会改善当前遇到的网络连接问题。
  • 规范错误提示信息,所有的 llm 报错都会使用同一套异常,方便用户定位问题原因。

插件系统

本次更新将会降低代码之间的耦合,可以通过插件来接入新的 LLM、绘图、预设等功能。

预设系统

将原来 txt 格式的预设文件改为使用 YAML 格式描述的交互工作流。

在这个工作流中,你可以定义初始化、输入和输出时的操作,这些操作可以让机器人的回应更加生动。

系统内置以下操作:

  • 设置语音引擎、音色 (tts/use-tts-engine)
  • 向 AI 发送消息 (system/prompt)
  • 向用户发送消息 (system/user_message)
  • 修改文本内容 (system/text)
  • 提取文本内容 (system/text-extraction)
  • 临时向另外一个 AI 发送消息,并获取结果 (system/instant-ask)
  • 生成语音 (tts/speak)
  • 绘图 (drawing/text-to-image)

在工作流被执行时,用户发送的信息、AI返回的信息和操作执行的结果可以存放到变量中。 你可以将这些变量作为参数输入到操作中。

一个具体的预设可以参考: https://github.com/lss233/chatgpt-mirai-qq-bot/blob/refactor-v3/prompts/catgirl.yml

在这个文件中, init 代码块描述了预设在初始化时执行的操作:

  1. 设定语音引擎
  2. 机器人会向 AI 发送预设文本
  3. 给用户发送初始化消息

接下来, input 代码块描述了对用户发送的消息的处理过程:

  1. 修改用户发送的原始内容,加入前缀、后缀和用户名。

最后是 output 代码块:

  1. 从 AI 的回复中提取“情感值”
  2. 判断情感值是增加还是减少,并发送对应的表情图片。
  3. 让另一个 AI 来推测这段回复的语气
  4. 根据上一步的标注结果,通过语音引擎生成带有同样语气的语音
  5. 发送语音
  6. 发送回复

通过插件的配合,这个预设系统可以支持更多别的操作,包括但不限于:联网搜索、阅读文章、图片识别等,还可以和其他平台接口互联,实现多模态。

@lss233
Copy link
Owner Author

lss233 commented May 9, 2023

最新进展: WebUI
开源地址: https://github.com/DarkSkyTeam/chatgpt-for-bot-webui
F}~1WCP1KIXB%XDX)HJ_)4](https://github.com/lss233/chatgpt-mirai-qq-bot/assets/8984680/31fc98e6-5be9-4bf6-8f1c-2123c7064f6c) ![E} 57_IKMP(9QFUSU6$I(1

@lss233
Copy link
Owner Author

lss233 commented May 9, 2023

目前还剩下的内容:

  • 将 OneBot、WeCom、HTTP 中的 Quart 实例合并成一个实例统一管理
  • 将 Renderer 延迟到 Platforms 中进行处理,因为我们对 Telegram、Discord 和 QQ 有不同的处理策略(前者需要打字机效果,后者需要图片渲染代码)
  • HTTP 服务鉴权、密码
  • 隧道(TryCloudflare)

如果有人可以帮忙的话就更好了~

@lss233 lss233 marked this pull request as ready for review May 9, 2023 13:15
@lss233 lss233 added the help wanted Extra attention is needed label May 9, 2023
@lss233 lss233 mentioned this pull request May 10, 2023
@lss233 lss233 force-pushed the refactor-v3 branch 3 times, most recently from 3bddac0 to f67a5b8 Compare May 11, 2023 02:37
@lss233 lss233 force-pushed the refactor-v3 branch 4 times, most recently from 06aa597 to 20e3037 Compare May 11, 2023 03:46
@lss233
Copy link
Owner Author

lss233 commented May 11, 2023

TODO:

  • WebUI 的 HTTP 部分要独立设计,主要是修改密码的部分
  • 编写默认预设

@lss233
Copy link
Owner Author

lss233 commented May 14, 2023

More TODO:

  • 兼容旧版 txt 格式预设 或 为旧版预设编写升级工具
    如果使用后一种方案,那么最好将当前版本的 prompts 文件夹改名为 presets 文件夹,启动时扫描 config.presets.scan_dir,将 txt 格式预设改写为 yml 格式后删除 txt 文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

3 participants