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

@@ -69,7 +69,7 @@ int ConfigStore::load_file(const char* path)
| 类型 | 规则 | 示例 |
|------|------|------|
| 目录名 | 小写英文 + 数字 + 下划线/连字符,字母或下划线开头 | `dstalk-core``file-io``plugins` |
| 目录名 | 小写英文 + 数字 + 下划线/连字符,字母或下划线开头 | `dstalk_core``file_io``plugins` |
| 源文件 | 小写英文 + 下划线,字母开头 | `config_store.cpp``openai_plugin.cpp` |
| 头文件 | 同源文件规则 | `dstalk_host.h``event_bus.hpp` |
| 测试文件 | `<模块名>_test.cpp` | `event_bus_test.cpp``openai_plugin_test.cpp` |
@@ -99,7 +99,7 @@ int ConfigStore::load_file(const char* path)
| 类型 | 规则 | 示例 |
|------|------|------|
| 插件目录 | 功能名,小写 + 连字符 | `plugins/openai/``plugins/file-io/` |
| 插件目录 | 功能名,小写 + 下划线 | `plugins_upper/openai/``plugins_base/file_io/` |
| 插件源文件 | `<功能名>_plugin.cpp` | `openai_plugin.cpp``session_plugin.cpp` |
| CMake 目标 | `plugin-<功能名>` | `plugin-openai``plugin-network` |
| 服务注册名 | 小写 + 点号分级 | `"ai.openai"``"http"``"session"` |
@@ -116,13 +116,13 @@ int ConfigStore::load_file(const char* path)
### 4.1 目录 README
- `dstalk/`(根目录)和所有二级目录(`dstalk-core/``dstalk-cli/``plugins/` 等)必须有 `README.md`
- 三级目录(如 `plugins/openai/`)如内容简单可暂不添加
- `dstalk/`(根目录)和所有二级目录(`dstalk_core/``dstalk_cli/``plugins_base/``plugins_middle/``plugins_upper/` 等)必须有 `README.md`
- 三级目录(如 `plugins_upper/openai/`)如内容简单可暂不添加
### 4.2 include 路径
- 公共头文件放在 `dstalk-core/include/dstalk/`
- 私有实现头文件放在 `dstalk-core/src/`
- 公共头文件放在 `dstalk_core/include/dstalk/`
- 私有实现头文件放在 `dstalk_core/src/`
- 插件不得被 core 反向依赖core 禁止 `#include` 插件目录下的文件)
### 4.3 内存管理
@@ -135,4 +135,4 @@ int ConfigStore::load_file(const char* path)
- 所有目标输出到 `${CMAKE_BINARY_DIR}/bin`(可执行文件)或 `${CMAKE_BINARY_DIR}/plugins`(插件 DLL
- 新前端通过 `option(DSTALK_BUILD_XXX)` 控制,默认 OFF
- 插件在 `plugins/CMakeLists.txt` 中按依赖顺序 `add_subdirectory`
- 插件在 `plugins_base/CMakeLists.txt``plugins_middle/CMakeLists.txt``plugins_upper/CMakeLists.txt` 中按依赖顺序 `add_subdirectory`