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:
@@ -82,8 +82,8 @@ static void reset_log_state() {
|
||||
g_last_log_msg[0] = '\0';
|
||||
}
|
||||
|
||||
// Get the absolute path to the build output plugins/ directory
|
||||
// 获取构建输出 plugins/ 目录的绝对路径
|
||||
// Get the absolute path to the plugin tier directory (plugins_base / middle / upper)
|
||||
// 获取插件层级目录 (plugins_base / middle / upper) 的绝对路径
|
||||
static fs::path get_plugins_dir() {
|
||||
#ifdef DSTALK_TEST_PLUGINS_DIR
|
||||
return fs::path(DSTALK_TEST_PLUGINS_DIR);
|
||||
@@ -121,10 +121,10 @@ int main()
|
||||
CHECK(loader.load_plugin("../plugins/test.dll") == -1,
|
||||
"T1.3: ../ traversal rejected");
|
||||
|
||||
// T1.4: 不在 plugins/ 目录下 / not under plugins/ dir
|
||||
// T1.4: 不在插件 tier 目录下 / not under plugin tier dir
|
||||
auto tmp = fs::temp_directory_path() / "dstalk_test_no_plugins" / "test.dll";
|
||||
CHECK(loader.load_plugin(tmp.string().c_str()) == -1,
|
||||
"T1.4: path not under plugins/ dir rejected");
|
||||
"T1.4: path not under plugin tier dir rejected");
|
||||
|
||||
// T1.5: 路径中间的 .. 段 / .. segment in middle of path
|
||||
CHECK(loader.load_plugin("plugins/../secret/test.dll") == -1,
|
||||
@@ -134,9 +134,9 @@ int main()
|
||||
CHECK(loader.load_plugin("plugins/test") == -1,
|
||||
"T1.6: no extension rejected");
|
||||
|
||||
// T1.7: 合法扩展名但不在 plugins/ 下 / valid extension but not under plugins/
|
||||
// T1.7: 合法扩展名但不在插件 tier 目录下 / valid extension but not under plugin tier dir
|
||||
CHECK(loader.load_plugin("/etc/someconfig.so") == -1,
|
||||
"T1.7: .so extension but not under plugins/ rejected");
|
||||
"T1.7: .so extension but not under plugin tier dir rejected");
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
@@ -149,7 +149,7 @@ int main()
|
||||
fs::path plugins_dir = get_plugins_dir();
|
||||
|
||||
fs::path dll_config = plugins_dir / "plugin-config.dll";
|
||||
fs::path dll_fileio = plugins_dir / "plugin-file-io.dll";
|
||||
fs::path dll_fileio = plugins_dir / "plugin-file_io.dll";
|
||||
|
||||
bool have_plugins = fs::exists(dll_config) && fs::exists(dll_fileio);
|
||||
|
||||
@@ -206,7 +206,7 @@ int main()
|
||||
fs::path plugins_dir = get_plugins_dir();
|
||||
|
||||
std::vector<fs::path> dlls;
|
||||
for (auto name : {"plugin-config.dll", "plugin-file-io.dll",
|
||||
for (auto name : {"plugin-config.dll", "plugin-file_io.dll",
|
||||
"plugin-context.dll", "plugin-session.dll"}) {
|
||||
fs::path p = plugins_dir / name;
|
||||
if (fs::exists(p)) dlls.push_back(p);
|
||||
|
||||
Reference in New Issue
Block a user