feat: add OpenAI-compatible AI provider plugin with SSE streaming support

- Implemented the OpenAI-compatible AI provider plugin, including configuration, chat, and chat_stream functionalities.
- Added support for SSE streaming and tool calls.
- Integrated Boost.JSON for JSON handling.
- Created CMake configuration for the plugin.
- Added error handling and logging throughout the plugin.
This commit is contained in:
2026-05-31 05:37:04 +08:00
parent f6cb51b40a
commit ba7382db2a
61 changed files with 163 additions and 147 deletions

View File

@@ -4,19 +4,19 @@
| 目录 | 功能说明 |
|------|---------|
| `dstalk-core/` | 核心网关库dstalk.dll / libdstalk.so提供插件加载、服务注册、事件总线、配置存储、日志、内存管理 |
| `dstalk_core/` | 核心网关库dstalk.dll / libdstalk.so提供插件加载、服务注册、事件总线、配置存储、日志、内存管理 |
## 二、前端模块
| 目录 | 功能说明 |
|------|---------|
| `dstalk-cli/` | 命令行前端ANSI 终端交互、命令解析、流式对话、工具调用、批处理/管道模式 |
| `dstalk-gui/` | 图形界面前端SDL3 窗口化界面、暗色主题、流式对话(默认关闭) |
| `dstalk-web/` | Web 前端Boost.Beast HTTP + SSE 流式推送、内嵌 HTML/CSS/JS 聊天界面(默认关闭) |
| `dstalk_cli/` | 命令行前端ANSI 终端交互、命令解析、流式对话、工具调用、批处理/管道模式 |
| `dstalk_gui/` | 图形界面前端SDL3 窗口化界面、暗色主题、流式对话(默认关闭) |
| `dstalk_web/` | Web 前端Boost.Beast HTTP + SSE 流式推送、内嵌 HTML/CSS/JS 聊天界面(默认关闭) |
## 三、插件模块
所有插件位于 `plugins/` 目录下,通过 C ABI 与核心网关通信。
插件按依赖层级分布在三个目录下,通过 C ABI 与核心网关通信。
### 3.1 基础插件(无依赖)
@@ -24,9 +24,9 @@
| 目录 | 服务名 | 功能说明 |
|------|--------|---------|
| `plugins/config/` | `"config"` | TOML 配置文件解析、键值读写 |
| `plugins/file-io/` | `"file_io"` | 文件读写服务 |
| `plugins/lsp/` | `"lsp"` | 语言服务器协议 JSON-RPC 客户端(诊断、悬停、补全),自行管理子进程 |
| `plugins_base/config/` | `"config"` | TOML 配置文件解析、键值读写 |
| `plugins_base/file_io/` | `"file_io"` | 文件读写服务 |
| `plugins_base/lsp/` | `"lsp"` | 语言服务器协议 JSON-RPC 客户端(诊断、悬停、补全),自行管理子进程 |
### 3.2 只依赖基础插件的插件
@@ -34,9 +34,9 @@
| 目录 | 服务名 | 功能说明 | 依赖 |
|------|--------|---------|------|
| `plugins/network/` | `"http"` | HTTP/HTTPS POST 和流式请求Boost.Beast + OpenSSL | `config` |
| `plugins/session/` | `"session"` | 会话消息历史管理、保存/加载、Token 计数 | `file_io` |
| `plugins/tools/` | `"tools"` | 工具注册、Schema 管理、执行分发(内置 file_read/file_write | `file_io` |
| `plugins_middle/network/` | `"http"` | HTTP/HTTPS POST 和流式请求Boost.Beast + OpenSSL | `config` |
| `plugins_middle/session/` | `"session"` | 会话消息历史管理、保存/加载、Token 计数 | `file_io` |
| `plugins_middle/tools/` | `"tools"` | 工具注册、Schema 管理、执行分发(内置 file_read/file_write | `file_io` |
### 3.3 依赖其他插件的插件
@@ -44,9 +44,9 @@
| 目录 | 服务名 | 功能说明 | 依赖 |
|------|--------|---------|------|
| `plugins/context/` | `"context"` | Token 计数UTF-8 字节估算)、上下文窗口裁剪 | `session` |
| `plugins/openai/` | `"ai.openai"` | OpenAI 兼容格式 AI 接入chat/stream/tools、SSE 解析) | `http``config` |
| `plugins/anthropic/` | `"ai.anthropic"` | Anthropic Claude Messages API 接入chat/stream、SSE 解析) | `http``config` |
| `plugins_upper/context/` | `"context"` | Token 计数UTF-8 字节估算)、上下文窗口裁剪 | `session` |
| `plugins_upper/openai/` | `"ai.openai"` | OpenAI 兼容格式 AI 接入chat/stream/tools、SSE 解析) | `http``config` |
| `plugins_upper/anthropic/` | `"ai.anthropic"` | Anthropic Claude Messages API 接入chat/stream、SSE 解析) | `http``config` |
### 3.4 规划中的插件(尚未实现)