48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include "handle.h"
|
|
#include <SimpleIni.h>
|
|
#include <cctype>
|
|
#include <iomanip>
|
|
#include <iostream>
|
|
#include <random>
|
|
#include <sstream>
|
|
|
|
bool CConfig::parse_config(ConfigInfo& config, const std::string& config_path)
|
|
{
|
|
CSimpleIniA ini_handle{};
|
|
SI_Error ret = ini_handle.LoadFile(config_path.c_str());
|
|
if (ret != SI_OK) {
|
|
return false;
|
|
}
|
|
if (!ini_handle.KeyExists("Config", "BaseURL")) {
|
|
std::cerr << "Not Key Found Config/BaseURL in deepseek.ini" << std::endl;
|
|
return false;
|
|
}
|
|
config.base_url = ini_handle.GetValue("Config", "BaseURL");
|
|
|
|
if (!ini_handle.KeyExists("Config", "ApiEnvKey")) {
|
|
std::cerr << "Not Key Found Config/ApiEnvKey in deepseek.ini" << std::endl;
|
|
return false;
|
|
}
|
|
config.api_env_key = ini_handle.GetValue("Config", "ApiEnvKey");
|
|
|
|
if (!ini_handle.KeyExists("Config", "UserName")) {
|
|
std::cerr << "Not Key Found Config/UserName in deepseek.ini" << std::endl;
|
|
return false;
|
|
}
|
|
config.user_name = ini_handle.GetValue("Config", "UserName");
|
|
|
|
if (!ini_handle.KeyExists("Config", "ModelName")) {
|
|
std::cerr << "Not Key Found Config/ModelName in deepseek.ini" << std::endl;
|
|
return false;
|
|
}
|
|
config.model_name = ini_handle.GetValue("Config", "ModelName");
|
|
|
|
if (!ini_handle.KeyExists("Config", "AssistantName")) {
|
|
std::cerr << "Not Key Found Config/AssistantName in deepseek.ini" << std::endl;
|
|
return false;
|
|
}
|
|
config.assistant_name = ini_handle.GetValue("Config", "AssistantName");
|
|
|
|
return true;
|
|
}
|