| 2270 | } |
| 2271 | |
| 2272 | int main(int argc, char **argv) |
| 2273 | { |
| 2274 | // own arguments required by this example |
| 2275 | gpt_params params; |
| 2276 | server_params sparams; |
| 2277 | |
| 2278 | // struct that contains llama context and inference |
| 2279 | llama_server_context llama; |
| 2280 | |
| 2281 | server_params_parse(argc, argv, sparams, params, llama); |
| 2282 | |
| 2283 | if (params.model_alias == "unknown") |
| 2284 | { |
| 2285 | params.model_alias = params.model; |
| 2286 | } |
| 2287 | |
| 2288 | llama_backend_init(params.numa); |
| 2289 | |
| 2290 | LOG_INFO("build info", {{"build", LLAMA_BUILD_NUMBER}, |
| 2291 | {"commit", LLAMA_COMMIT}}); |
| 2292 | |
| 2293 | LOG_INFO("system info", { |
| 2294 | {"n_threads", params.n_threads}, |
| 2295 | {"n_threads_batch", params.n_threads_batch}, |
| 2296 | {"total_threads", std::thread::hardware_concurrency()}, |
| 2297 | {"system_info", llama_print_system_info()}, |
| 2298 | }); |
| 2299 | |
| 2300 | // load the model |
| 2301 | if (!llama.load_model(params)) |
| 2302 | { |
| 2303 | return 1; |
| 2304 | } |
| 2305 | |
| 2306 | llama.initialize(); |
| 2307 | |
| 2308 | httplib::Server svr; |
| 2309 | |
| 2310 | svr.set_default_headers({{"Server", "llama.cpp"}, |
| 2311 | {"Access-Control-Allow-Origin", "*"}, |
| 2312 | {"Access-Control-Allow-Headers", "content-type"}}); |
| 2313 | |
| 2314 | // this is only called if no index.html is found in the public --path |
| 2315 | svr.Get("/", [](const httplib::Request &, httplib::Response &res) |
| 2316 | { |
| 2317 | res.set_content(reinterpret_cast<const char*>(&index_html), index_html_len, "text/html"); |
| 2318 | return false; |
| 2319 | }); |
| 2320 | |
| 2321 | // this is only called if no index.js is found in the public --path |
| 2322 | svr.Get("/index.js", [](const httplib::Request &, httplib::Response &res) |
| 2323 | { |
| 2324 | res.set_content(reinterpret_cast<const char *>(&index_js), index_js_len, "text/javascript"); |
| 2325 | return false; |
| 2326 | }); |
| 2327 | |
| 2328 | // this is only called if no index.html is found in the public --path |
| 2329 | svr.Get("/completion.js", [](const httplib::Request &, httplib::Response &res) |
nothing calls this directly
no test coverage detected