MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / rpc_server_params_parse

Function rpc_server_params_parse

tools/rpc/rpc-server.cpp:192–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192static bool rpc_server_params_parse(int argc, char ** argv, rpc_server_params & params) {
193 std::string arg;
194 for (int i = 1; i < argc; i++) {
195 arg = argv[i];
196 if (arg == "-H" || arg == "--host") {
197 if (++i >= argc) {
198 return false;
199 }
200 params.host = argv[i];
201 } else if (arg == "-t" || arg == "--threads") {
202 if (++i >= argc) {
203 return false;
204 }
205 params.n_threads = std::stoi(argv[i]);
206 if (params.n_threads <= 0) {
207 fprintf(stderr, "error: invalid number of threads: %d\n", params.n_threads);
208 return false;
209 }
210 } else if (arg == "-d" || arg == "--device") {
211 if (++i >= argc) {
212 return false;
213 }
214 const std::regex regex{ R"([,/]+)" };
215 std::string dev_str = argv[i];
216 std::sregex_token_iterator iter(dev_str.begin(), dev_str.end(), regex, -1);
217 std::sregex_token_iterator end;
218 for ( ; iter != end; ++iter) {
219 try {
220 params.devices.push_back(*iter);
221 } catch (const std::exception & ) {
222 fprintf(stderr, "error: invalid device: %s\n", iter->str().c_str());
223 return false;
224 }
225 }
226 } else if (arg == "-p" || arg == "--port") {
227 if (++i >= argc) {
228 return false;
229 }
230 params.port = std::stoi(argv[i]);
231 if (params.port <= 0 || params.port > 65535) {
232 return false;
233 }
234 } else if (arg == "-c" || arg == "--cache") {
235 params.use_cache = true;
236 } else if (arg == "-h" || arg == "--help") {
237 print_usage(argc, argv, params);
238 exit(0);
239 } else {
240 fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());
241 print_usage(argc, argv, params);
242 exit(0);
243 }
244 }
245 return true;
246}
247
248static std::vector<ggml_backend_dev_t> get_devices(const rpc_server_params & params) {
249 std::vector<ggml_backend_dev_t> devices;

Callers 1

mainFunction · 0.85

Calls 5

endMethod · 0.80
print_usageFunction · 0.70
beginMethod · 0.45
push_backMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected