\brief Check hash of model files \param model_tag the model tag \return true if all files are present and compatible, false otherwise
| 409 | /// \param model_tag the model tag |
| 410 | /// \return true if all files are present and compatible, false otherwise |
| 411 | bool ModelDownloader::check_model(const std::string& model_tag, bool sub_process_mode) { |
| 412 | auto [new_model_tag, model_info] = supported_models.get_model_info(model_tag); |
| 413 | header_print("FLM", "Checking model: " + new_model_tag + "...\n"); |
| 414 | |
| 415 | if (!is_model_downloaded(new_model_tag, sub_process_mode)) { |
| 416 | header_print("FLM", "Model not exist or not compatible: " + new_model_tag); |
| 417 | header_print("FLM", "Please use `flm pull " + new_model_tag + "` to download the model."); |
| 418 | return true; |
| 419 | } |
| 420 | else { |
| 421 | bool ok = verify_and_clean_files(new_model_tag, sub_process_mode); |
| 422 | if (!ok) { |
| 423 | header_print("FLM", "Model check completed with errors. Please use `flm pull " + new_model_tag + "` to re-download corrupted files."); |
| 424 | } |
| 425 | else { |
| 426 | header_print("FLM", "Model check completed successfully. All files are present and compatible."); |
| 427 | } |
| 428 | } |
| 429 | return true; |
| 430 | } |
| 431 | |
| 432 | /// \brief Verify each model file's hash against HuggingFace metadata and |
| 433 | /// remove any corrupted files. Files that pass verification are kept. |