@@ -97,6 +97,16 @@ static const std::unordered_map<std::string, ApiConfigurationMetadata>
9797 .accept_value = " string" ,
9898 .default_value = " " ,
9999 .allow_empty = true }},
100+ {" api_server_host" , ApiConfigurationMetadata{.name = " api_server_host" ,
101+ .desc = " API server host" ,
102+ .group = " Server setup" ,
103+ .accept_value = " string" ,
104+ .default_value = " " }},
105+ {" api_server_port" , ApiConfigurationMetadata{.name = " api_server_port" ,
106+ .desc = " API server port" ,
107+ .group = " Server setup" ,
108+ .accept_value = " integer" ,
109+ .default_value = " " }},
100110};
101111
102112class ApiServerConfiguration {
@@ -107,7 +117,8 @@ class ApiServerConfiguration {
107117 const std::string& proxy_url = " " , const std::string& proxy_username = " " ,
108118 const std::string& proxy_password = " " , const std::string& no_proxy = " " ,
109119 bool verify_peer_ssl = true , bool verify_host_ssl = true ,
110- const std::string& hf_token = " " )
120+ const std::string& hf_token = " " , const std::string& server_host = " " ,
121+ int server_port = 39281 )
111122 : cors{cors},
112123 allowed_origins{allowed_origins},
113124 verify_proxy_ssl{verify_proxy_ssl},
@@ -118,7 +129,9 @@ class ApiServerConfiguration {
118129 no_proxy{no_proxy},
119130 verify_peer_ssl{verify_peer_ssl},
120131 verify_host_ssl{verify_host_ssl},
121- hf_token{hf_token} {}
132+ hf_token{hf_token},
133+ server_host{server_host},
134+ server_port{server_port} {}
122135
123136 // cors
124137 bool cors{true };
@@ -139,6 +152,9 @@ class ApiServerConfiguration {
139152 // token
140153 std::string hf_token{" " };
141154
155+ std::string server_host{" 127.0.0.1" };
156+ int server_port{39281 };
157+
142158 Json::Value ToJson () const {
143159 Json::Value root;
144160 root[" cors" ] = cors;
@@ -155,7 +171,8 @@ class ApiServerConfiguration {
155171 root[" verify_peer_ssl" ] = verify_peer_ssl;
156172 root[" verify_host_ssl" ] = verify_host_ssl;
157173 root[" huggingface_token" ] = hf_token;
158-
174+ root[" server_host" ] = server_host;
175+ root[" server_port" ] = server_port;
159176 return root;
160177 }
161178
@@ -246,7 +263,22 @@ class ApiServerConfiguration {
246263 hf_token = value.asString ();
247264 return true ;
248265 }},
249-
266+ {" server_host" ,
267+ [this ](const Json::Value& value) -> bool {
268+ if (!value.isString ()) {
269+ return false ;
270+ }
271+ server_host = value.asString ();
272+ return true ;
273+ }},
274+ {" server_port" ,
275+ [this ](const Json::Value& value) -> bool {
276+ if (!value.isNumeric ()) {
277+ return false ;
278+ }
279+ server_port = value.asInt ();
280+ return true ;
281+ }},
250282 {" cors" ,
251283 [this ](const Json::Value& value) -> bool {
252284 if (!value.isBool ()) {
0 commit comments