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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Fix to check model type for custom models
ozanarmagan85ed9090b2fb
diff --git a/src/text_embedder.cpp b/src/text_embedder.cppindex c884fdf5..10647d09 100644--- a/src/text_embedder.cpp+++ b/src/text_embedder.cpp@@ -186,10 +186,20 @@ bool TextEmbedder::is_model_valid(const std::string& model_name, unsigned int& nreturn false;}+ if(!config["model_type"].is_string() || !config["vocab_file_name"].is_string()) {+ LOG(ERROR) << "Invalid config file: " << TextEmbedderManager::get_absolute_config_path(model_name);+ return false;+ }+if(!std::filesystem::exists(TextEmbedderManager::get_model_subdir(model_name) + "/" + config["vocab_file_name"].get<std::string>())) {LOG(ERROR) << "Vocab file not found: " << TextEmbedderManager::get_model_subdir(model_name) + "/" + config["vocab_file_name"].get<std::string>();return false;}++ if(config["model_type"].get<std::string>() != "bert" && config["model_type"].get<std::string>() != "xlm_roberta" && config["model_type"].get<std::string>() != "distilbert") {+ LOG(ERROR) << "Invalid model type: " << config["model_type"].get<std::string>();+ return false;+ }}Ort::Session session(env, abs_path.c_str(), session_options);