| 331 | }; |
| 332 | |
| 333 | static handle_model_result common_params_handle_model(struct common_params_model & model, |
| 334 | const std::string & bearer_token, |
| 335 | bool offline) { |
| 336 | handle_model_result result; |
| 337 | |
| 338 | if (!model.docker_repo.empty()) { |
| 339 | model.path = common_docker_resolve_model(model.docker_repo); |
| 340 | model.name = model.docker_repo; |
| 341 | } else if (!model.hf_repo.empty()) { |
| 342 | // If -m was used with -hf, treat the model "path" as the hf_file to download |
| 343 | if (model.hf_file.empty() && !model.path.empty()) { |
| 344 | model.hf_file = model.path; |
| 345 | model.path = ""; |
| 346 | } |
| 347 | common_download_opts opts; |
| 348 | opts.bearer_token = bearer_token; |
| 349 | opts.offline = offline; |
| 350 | auto download_result = common_download_model(model, opts, true); |
| 351 | |
| 352 | if (download_result.model_path.empty()) { |
| 353 | LOG_ERR("error: failed to download model from Hugging Face\n"); |
| 354 | exit(1); |
| 355 | } |
| 356 | |
| 357 | model.name = model.hf_repo; |
| 358 | model.path = download_result.model_path; |
| 359 | |
| 360 | if (!download_result.mmproj_path.empty()) { |
| 361 | result.found_mmproj = true; |
| 362 | result.mmproj.path = download_result.mmproj_path; |
| 363 | } |
| 364 | } else if (!model.url.empty()) { |
| 365 | if (model.path.empty()) { |
| 366 | auto f = string_split<std::string>(model.url, '#').front(); |
| 367 | f = string_split<std::string>(f, '?').front(); |
| 368 | model.path = fs_get_cache_file(string_split<std::string>(f, '/').back()); |
| 369 | } |
| 370 | |
| 371 | common_download_opts opts; |
| 372 | opts.bearer_token = bearer_token; |
| 373 | opts.offline = offline; |
| 374 | auto download_result = common_download_model(model, opts); |
| 375 | if (download_result.model_path.empty()) { |
| 376 | LOG_ERR("error: failed to download model from %s\n", model.url.c_str()); |
| 377 | exit(1); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | return result; |
| 382 | } |
| 383 | |
| 384 | const std::vector<ggml_type> kv_cache_types = { |
| 385 | GGML_TYPE_F32, |
no test coverage detected