Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Refactor ```get_public_model_config``` method to check cache only if network fails

ozanarmaganbdd35ea642f5
diff --git a/src/embedder_manager.cpp b/src/embedder_manager.cpp
index 91e56c0a..3d6137c6 100644
--- a/src/embedder_manager.cpp
+++ b/src/embedder_manager.cpp
@@ -448,14 +448,6 @@ text_embedding_model::text_embedding_model(const nlohmann::json& json) {
Option<nlohmann::json> EmbedderManager::get_public_model_config(const std::string& model_name) {
- // check cache first
- if(std::filesystem::exists(get_absolute_config_path(model_name))) {
- std::ifstream config_file(get_absolute_config_path(model_name));
- nlohmann::json config;
- config_file >> config;
- config_file.close();
- return Option<nlohmann::json>(config);
- }
auto actual_model_name = get_model_name_without_namespace(model_name);
HttpClient& httpClient = HttpClient::get_instance();
@@ -475,6 +467,15 @@ Option<nlohmann::json> EmbedderManager::get_public_model_config(const std::strin
return Option<nlohmann::json>(nlohmann::json::parse(response_body));
}
+ // check cache if network fails
+ if(std::filesystem::exists(get_absolute_config_path(model_name))) {
+ std::ifstream config_file(get_absolute_config_path(model_name));
+ nlohmann::json config;
+ config_file >> config;
+ config_file.close();
+ return Option<nlohmann::json>(config);
+ }
+
return Option<nlohmann::json>(404, "Model not found");
}