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
Add `ts` namespace for voice query models (#1549)
Ozan Armağan76c57ec40770
diff --git a/include/vq_model_manager.h b/include/vq_model_manager.hindex 6d3d7cd4..179f6d40 100644--- a/include/vq_model_manager.h+++ b/include/vq_model_manager.h@@ -15,6 +15,7 @@ class VQModelManager {static const Option<nlohmann::json> get_config();static const std::string get_absolute_model_path(const std::string& model_name);static const std::string get_model_namespace(const std::string& model_name);+ static const std::string get_model_name_without_namespace(const std::string& model_name);Option<bool> download_model(const std::string& model_name);std::unordered_map<std::string, std::shared_ptr<VQModel>> models;VQModelManager() = default;diff --git a/src/aq_model_manager.cpp b/src/aq_model_manager.cppindex 1d74a40b..4a581898 100644--- a/src/aq_model_manager.cpp+++ b/src/aq_model_manager.cpp@@ -97,16 +97,23 @@ Option<std::shared_ptr<VQModel>> VQModelManager::validate_and_init_model(const sreturn Option<std::shared_ptr<VQModel>>(models[model_name]);}- auto download_res = download_model(model_name);+ auto model_namespace = get_model_namespace(model_name);+ if(model_namespace != "ts") {+ return Option<std::shared_ptr<VQModel>>(400, "Unknown model namespace");+ }++ auto model_name_without_namespace = get_model_name_without_namespace(model_name);++ auto download_res = download_model(model_name_without_namespace);if (!download_res.ok()) {return Option<std::shared_ptr<VQModel>>(download_res.code(), download_res.error());}- auto model_path = get_absolute_model_path(model_name);- auto model_namespace = get_model_namespace(model_name);+ auto model_path = get_absolute_model_path(model_name_without_namespace);+ auto model_inner_namespace = get_model_namespace(model_name_without_namespace);- if (model_namespace == "whisper") {+ if (model_inner_namespace == "whisper") {auto whisper_ctx = WhisperModel::validate_and_load_model(model_path);if (!whisper_ctx) {return Option<std::shared_ptr<VQModel>>(400, "Failed to load voice query model");@@ -155,6 +162,14 @@ void VQModelManager::clear_unused_models() {}}+const std::string VQModelManager::get_model_name_without_namespace(const std::string& model_name) {+ if(model_name.find("/") != std::string::npos) {+ return model_name.substr(model_name.find("/") + 1);+ } else {+ return model_name;+ }+}+VQModelManager::~VQModelManager() {delete_all_models();}\ No newline at end of filediff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cppindex a6da7597..78dc95cd 100644--- a/test/collection_vector_search_test.cpp+++ b/test/collection_vector_search_test.cpp@@ -3723,7 +3723,7 @@ TEST_F(CollectionVectorTest, TestInvalidVoiceQueryModel) {auto collection_create_op = collectionManager.create_collection(schema_json);ASSERT_FALSE(collection_create_op.ok());- ASSERT_EQ("Voice query model not found", collection_create_op.error());+ ASSERT_EQ("Unknown model namespace", collection_create_op.error());schema_json = R"({"name": "test",@@ -3737,7 +3737,7 @@ TEST_F(CollectionVectorTest, TestInvalidVoiceQueryModel) {collection_create_op = collectionManager.create_collection(schema_json);ASSERT_FALSE(collection_create_op.ok());- ASSERT_EQ("Voice query model not found", collection_create_op.error());+ ASSERT_EQ("Unknown model namespace", collection_create_op.error());schema_json = R"({"name": "test",@@ -3787,7 +3787,7 @@ TEST_F(CollectionVectorTest, TestVoiceQuery) {{"name": "name", "type": "string"}],"voice_query_model": {- "model_name": "whisper/base.en"+ "model_name": "ts/whisper/base.en"}})"_json;@@ -3831,7 +3831,7 @@ TEST_F(CollectionVectorTest, TestInvalidVoiceQuery) {{"name": "name", "type": "string"}],"voice_query_model": {- "model_name": "whisper/base.en"+ "model_name": "ts/whisper/base.en"}})"_json;