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:
@@ -220,9 +220,9 @@ static void handle_command(const char* line)
|
||||
// /status —— 脱敏显示当前运行状态 / Display current runtime status (desensitized)
|
||||
if (std::strcmp(line, "/status") == 0) {
|
||||
const char* provider = dstalk_config_get("ai.provider");
|
||||
if (!provider) provider = "ai.deepseek";
|
||||
if (!provider) provider = "ai.openai";
|
||||
const char* base_url = dstalk_config_get("api.base_url");
|
||||
if (!base_url) base_url = "https://api.deepseek.com/v1";
|
||||
if (!base_url) base_url = "https://api.openai.com/v1";
|
||||
const char* api_key = dstalk_config_get("api.api_key");
|
||||
|
||||
std::printf(" 模型: %s\n", g_current_model.empty() ? "(未设置)" : g_current_model.c_str());
|
||||
@@ -488,7 +488,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// 查询插件服务 / Query plugin services
|
||||
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 = static_cast<const dstalk_ai_service_t*>(dstalk_service_query(ai_provider, 1));
|
||||
g_session = static_cast<const dstalk_session_service_t*>(dstalk_service_query("session", 1));
|
||||
g_file_io = static_cast<const dstalk_file_io_service_t*>(dstalk_service_query("file_io", 1));
|
||||
@@ -506,8 +506,8 @@ int main(int argc, char* argv[])
|
||||
const char* base_url = dstalk_config_get("api.base_url");
|
||||
const char* api_key = dstalk_config_get("api.api_key");
|
||||
const char* model = dstalk_config_get("api.model");
|
||||
if (!base_url) base_url = "https://api.deepseek.com/v1";
|
||||
if (!model) model = "deepseek-v4-pro";
|
||||
if (!base_url) base_url = "https://api.openai.com/v1";
|
||||
if (!model) model = "gpt-4o";
|
||||
g_ai->configure(ai_provider, base_url, api_key ? api_key : "", model, 4096, 0.7);
|
||||
g_current_model = model; // A1: 记录当前模型名 / Record current model name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user