Add unit tests for OpenAI plugin and establish coding standards

- Introduced comprehensive unit tests for the OpenAI plugin, covering SSE parsing, sentinel matching, delta extraction, request building, and more.
- Created a new markdown file detailing coding and naming conventions for the dstalk project, including guidelines for comments, naming rules, code organization, and memory management practices.
This commit is contained in:
2026-05-31 00:51:59 +08:00
parent f2da0f2ed4
commit f6cb51b40a
21 changed files with 343 additions and 131 deletions

View File

@@ -100,7 +100,7 @@ struct GuiState {
int history_index = -1; // 当前历史位置(-1 = 新输入) / current history position (-1 = new input)
std::string saved_input; // 浏览历史时暂存当前输入 / saved current input while browsing history
bool sidebar_visible = true; // 侧边栏可见性 / sidebar visibility
std::string model_name = "deepseek-chat";// 当前模型名 / current model name
std::string model_name = "gpt-4o";// 当前模型名 / current model name
};
// 将 GuiState 与 SDL 窗口/渲染器句柄及逐帧标志打包。
@@ -814,7 +814,7 @@ int main(int argc, char* argv[]) {
}
const char* ai_provider = dstalk_config_get("ai.provider");
if (!ai_provider) ai_provider = "ai.deepseek";
if (!ai_provider) ai_provider = "ai.openai";
g_ai_svc = static_cast<const dstalk_ai_service_t*>(dstalk_service_query(ai_provider, 1));
g_session_svc = static_cast<const dstalk_session_service_t*>(dstalk_service_query("session", 1));
if (!g_ai_svc) dstalk_log(3, "AI service not found (check plugins directory)");