\brief Check if the model is compatible with the current FLM version \param model_tag the model tag \return true if the model is compatible, false otherwise
| 47 | /// \param model_tag the model tag |
| 48 | /// \return true if the model is compatible, false otherwise |
| 49 | bool ModelDownloader::check_model_compatibility(const std::string& model_tag, bool sub_process_mode) { |
| 50 | auto [new_model_tag, model_info] = supported_models.get_model_info(model_tag); |
| 51 | LM_Config config; |
| 52 | config.from_pretrained(this->supported_models.get_model_path(new_model_tag)); |
| 53 | std::string flm_version = config.flm_version; |
| 54 | std::string flm_min_version = model_info["flm_min_version"]; |
| 55 | int l_l, m_l, r_l; //left, middle, right on local version |
| 56 | int l_r, m_r, r_r; //left, middle, right on requried version |
| 57 | int l_f, m_f, r_f; //left, middle, right on flm version |
| 58 | sscanf(__FLM_VERSION__, "%d.%d.%d", &l_f, &m_f, &r_f); |
| 59 | sscanf(flm_version.c_str(), "%d.%d.%d", &l_l, &m_l, &r_l); |
| 60 | sscanf(flm_min_version.c_str(), "%d.%d.%d", &l_r, &m_r, &r_r); |
| 61 | uint32_t local_version_u32 = l_l * 1000000 + m_l * 1000 + r_l; |
| 62 | uint32_t required_version_u32 = l_r * 1000000 + m_r * 1000 + r_r; |
| 63 | uint32_t flm_version_u32 = l_f * 1000000 + m_f * 1000 + r_f; |
| 64 | bool is_future_version = false; |
| 65 | if (local_version_u32 > flm_version_u32) { |
| 66 | is_future_version = true; |
| 67 | } |
| 68 | bool is_compatible = true; |
| 69 | if (local_version_u32 < required_version_u32) { |
| 70 | is_compatible = false; |
| 71 | } |
| 72 | if (!sub_process_mode) { |
| 73 | if (is_future_version) { |
| 74 | header_print("WARNING", "Local model version: " + flm_version + " > " + __FLM_VERSION__); |
| 75 | header_print("WARNING", "This model may not be compatible with the current FLM version."); |
| 76 | header_print("WARNING", "Please update FLM to the latest version."); |
| 77 | exit(0); |
| 78 | } |
| 79 | if (!is_compatible) { |
| 80 | header_print("FLM", "Local model " + model_tag + " version: " + flm_version + " < " + flm_min_version); |
| 81 | return false; |
| 82 | } |
| 83 | } |
| 84 | return is_compatible; |
| 85 | } |
| 86 | /// \brief Pull the model |
| 87 | /// \param model_tag the model tag |
| 88 | /// \param force_redownload true if the model should be downloaded even if it is already downloaded |
nothing calls this directly
no test coverage detected