forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_yaml_utils.h
More file actions
93 lines (75 loc) · 2.49 KB
/
config_yaml_utils.h
File metadata and controls
93 lines (75 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include <mutex>
#include <string>
#include "utils/engine_constants.h"
#include "utils/logging_utils.h"
#include <vector>
#include "utils/engine_constants.h"
#include "utils/result.hpp"
namespace config_yaml_utils {
const std::string kDefaultHost{"127.0.0.1"};
const std::string kDefaultPort{"39281"};
const int kDefaultMaxLines{100000};
constexpr const uint64_t kDefaultCheckedForUpdateAt = 0u;
constexpr const uint64_t kDefaultCheckedForLlamacppUpdateAt = 0u;
constexpr const auto kDefaultLatestRelease = "default_version";
constexpr const auto kDefaultLatestLlamacppRelease = "";
constexpr const auto kDefaultCorsEnabled = true;
const std::vector<std::string> kDefaultEnabledOrigins{
"http://localhost:39281", "http://127.0.0.1:39281", "http://0.0.0.0:39281"};
constexpr const auto kDefaultNoProxy = "example.com,::1,localhost,127.0.0.1";
const std::vector<std::string> kDefaultSupportedEngines{kLlamaEngine};
struct CortexConfig {
std::string logFolderPath;
std::string logLlamaCppPath;
std::string logOnnxPath;
std::string dataFolderPath;
int maxLogLines;
std::string apiServerHost;
std::string apiServerPort;
uint64_t checkedForUpdateAt;
uint64_t checkedForLlamacppUpdateAt;
std::string latestRelease;
std::string latestLlamacppRelease;
std::string huggingFaceToken;
/**
* Github's API requires a user-agent string.
*/
std::string gitHubUserAgent;
std::string gitHubToken;
std::string llamacppVariant;
std::string llamacppVersion;
bool enableCors;
std::vector<std::string> allowedOrigins;
std::string proxyUrl;
bool verifyProxySsl;
bool verifyProxyHostSsl;
std::string proxyUsername;
std::string proxyPassword;
std::string noProxy;
bool verifyPeerSsl;
bool verifyHostSsl;
std::string sslCertPath;
std::string sslKeyPath;
std::vector<std::string> supportedEngines;
uint64_t checkedForSyncHubAt;
std::vector<std::string> apiKeys;
};
class CortexConfigMgr {
private:
CortexConfigMgr() {}
std::mutex mtx_;
public:
CortexConfigMgr(CortexConfigMgr const&) = delete;
CortexConfigMgr& operator=(CortexConfigMgr const&) = delete;
~CortexConfigMgr() {}
static CortexConfigMgr& GetInstance() {
static CortexConfigMgr ccm;
return ccm;
}
cpp::result<void, std::string> DumpYamlConfig(const CortexConfig& config,
const std::string& path);
CortexConfig FromYaml(const std::string& path,
const CortexConfig& default_cfg);
};
} // namespace config_yaml_utils