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

Fix naming conventions

ozanarmagancffd1a0fcfcb
diff --git a/include/collection.h b/include/collection.h
index dfd86c90..e9fe2043 100644
--- a/include/collection.h
+++ b/include/collection.h
@@ -20,7 +20,7 @@
#include <tsl/htrie_map.h>
#include "tokenizer.h"
#include "synonym_index.h"
-#include "aq_model_manager.h"
+#include "vq_model_manager.h"
struct doc_seq_id_t {
uint32_t seq_id;
@@ -341,7 +341,7 @@ private:
const size_t remote_embedding_num_tries,
size_t& per_page) const;
- std::shared_ptr<AQModel> aq_model = nullptr;
+ std::shared_ptr<VQModel> vq_model = nullptr;
public:
@@ -369,7 +369,7 @@ public:
static constexpr const char* COLLECTION_SYMBOLS_TO_INDEX = "symbols_to_index";
static constexpr const char* COLLECTION_SEPARATORS = "token_separators";
- static constexpr const char* COLLECTION_AUDIO_QUERY_MODEL = "audio_query_model";
+ static constexpr const char* COLLECTION_VOICE_QUERY_MODEL = "voice_query_model";
// methods
@@ -380,7 +380,7 @@ public:
const std::string& default_sorting_field,
const float max_memory_ratio, const std::string& fallback_field_type,
const std::vector<std::string>& symbols_to_index, const std::vector<std::string>& token_separators,
- const bool enable_nested_fields, std::shared_ptr<AQModel> aq_model = nullptr);
+ const bool enable_nested_fields, std::shared_ptr<VQModel> vq_model = nullptr);
~Collection();
@@ -577,7 +577,7 @@ public:
const std::string& conversation_model_id = "",
std::string conversation_id = "",
const std::string& override_tags_str = "",
- const std::string& audio_query = "") const;
+ const std::string& voice_query = "") const;
Option<bool> get_filter_ids(const std::string & filter_query, filter_result_t& filter_result) const;
@@ -603,7 +603,7 @@ public:
bool get_enable_nested_fields();
- std::shared_ptr<AQModel> get_aq_model();
+ std::shared_ptr<VQModel> get_vq_model();
Option<bool> parse_facet(const std::string& facet_field, std::vector<facet>& facets) const;
diff --git a/include/collection_manager.h b/include/collection_manager.h
index 5e181735..fa6ff31a 100644
--- a/include/collection_manager.h
+++ b/include/collection_manager.h
@@ -160,7 +160,7 @@ public:
const std::string& fallback_field_type = "",
const std::vector<std::string>& symbols_to_index = {},
const std::vector<std::string>& token_separators = {},
- const bool enable_nested_fields = false, std::shared_ptr<AQModel> model = nullptr);
+ const bool enable_nested_fields = false, std::shared_ptr<VQModel> model = nullptr);
locked_resource_view_t<Collection> get_collection(const std::string & collection_name) const;
diff --git a/include/aq_model.h b/include/vq_model.h
similarity index 90%
rename from include/aq_model.h
rename to include/vq_model.h
index e7862755..5eac550a 100644
--- a/include/aq_model.h
+++ b/include/vq_model.h
@@ -9,13 +9,13 @@
#include "string_utils.h"
#include "option.h"
-class AQModel {
+class VQModel {
protected:
int collection_ref_count = 1;
std::shared_mutex collection_ref_count_mutex;
std::string model_name;
public:
- virtual ~AQModel() = default;
+ virtual ~VQModel() = default;
virtual Option<std::string> transcribe(const std::string& audio) = 0;
void inc_collection_ref_count() {
std::unique_lock<std::shared_mutex> lock(collection_ref_count_mutex);
@@ -32,11 +32,11 @@ class AQModel {
const std::string& get_model_name() {
return model_name;
}
- AQModel(const std::string& model_name) : model_name(model_name) {}
+ VQModel(const std::string& model_name) : model_name(model_name) {}
};
-class WhisperModel : public AQModel {
+class WhisperModel : public VQModel {
private:
whisper_context* ctx = nullptr;
whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
diff --git a/include/aq_model_manager.h b/include/vq_model_manager.h
similarity index 60%
rename from include/aq_model_manager.h
rename to include/vq_model_manager.h
index 52206dcd..6d3d7cd4 100644
--- a/include/aq_model_manager.h
+++ b/include/vq_model_manager.h
@@ -1,13 +1,13 @@
#pragma once
#include <unordered_map>
-#include "aq_model.h"
+#include "vq_model.h"
#include "json.hpp"
#include "embedder_manager.h"
-class AQModelManager {
+class VQModelManager {
private:
inline static const std::string MODELS_REPO_URL = "https://models.typesense.org/public/";
static const std::string get_model_url(const std::string& model_name);
@@ -16,24 +16,24 @@ class AQModelManager {
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);
Option<bool> download_model(const std::string& model_name);
- std::unordered_map<std::string, std::shared_ptr<AQModel>> models;
- AQModelManager() = default;
+ std::unordered_map<std::string, std::shared_ptr<VQModel>> models;
+ VQModelManager() = default;
std::shared_mutex models_mutex;
std::mutex download_mutex;
public:
- static AQModelManager& get_instance() {
- static AQModelManager instance;
+ static VQModelManager& get_instance() {
+ static VQModelManager instance;
return instance;
}
- AQModelManager(AQModelManager&&) = delete;
- AQModelManager& operator=(AQModelManager&&) = delete;
- AQModelManager(const AQModelManager&) = delete;
- AQModelManager& operator=(const AQModelManager&) = delete;
- Option<std::shared_ptr<AQModel>> validate_and_init_model(const std::string& model_name);
- Option<std::shared_ptr<AQModel>> get_model(const std::string& model_name);
+ VQModelManager(VQModelManager&&) = delete;
+ VQModelManager& operator=(VQModelManager&&) = delete;
+ VQModelManager(const VQModelManager&) = delete;
+ VQModelManager& operator=(const VQModelManager&) = delete;
+ Option<std::shared_ptr<VQModel>> validate_and_init_model(const std::string& model_name);
+ Option<std::shared_ptr<VQModel>> get_model(const std::string& model_name);
void delete_model(const std::string& model_name);
void delete_all_models();
- ~AQModelManager();
+ ~VQModelManager();
void clear_unused_models();
};
diff --git a/src/aq_model.cpp b/src/aq_model.cpp
index 56596647..feac6791 100644
--- a/src/aq_model.cpp
+++ b/src/aq_model.cpp
@@ -1,4 +1,4 @@
-#include "aq_model.h"
+#include "vq_model.h"
#include <sstream>
#define DR_WAV_IMPLEMENTATION
#include "dr_wav.h"
@@ -8,7 +8,7 @@ whisper_context* WhisperModel::validate_and_load_model(const std::string& model_
return whisper_init_from_file(model_path.c_str());
}
-WhisperModel::WhisperModel(whisper_context* ctx, const std::string& model_name) : ctx(ctx), AQModel(model_name) {
+WhisperModel::WhisperModel(whisper_context* ctx, const std::string& model_name) : ctx(ctx), VQModel(model_name) {
// surpress whisper logs
whisper_log_set([](enum ggml_log_level level, const char * text, void * user_data) {
}, nullptr);
diff --git a/src/aq_model_manager.cpp b/src/aq_model_manager.cpp
index e82bd546..c377d6bd 100644
--- a/src/aq_model_manager.cpp
+++ b/src/aq_model_manager.cpp
@@ -1,19 +1,19 @@
#include <filesystem>
#include <map>
-#include "aq_model_manager.h"
+#include "vq_model_manager.h"
#include "http_client.h"
-const std::string AQModelManager::get_model_url(const std::string& model_name) {
- return MODELS_REPO_URL + "audio_query/" + model_name + ".bin";
+const std::string VQModelManager::get_model_url(const std::string& model_name) {
+ return MODELS_REPO_URL + "voice_query/" + model_name + ".bin";
}
-const std::string AQModelManager::get_config_url() {
- return MODELS_REPO_URL + "audio_query/models.json";
+const std::string VQModelManager::get_config_url() {
+ return MODELS_REPO_URL + "voice_query/models.json";
}
-const std::string AQModelManager::get_model_namespace(const std::string& model_name) {
+const std::string VQModelManager::get_model_namespace(const std::string& model_name) {
// <namespace>/<model_name> if / is present in model_name
if(model_name.find("/") != std::string::npos) {
return model_name.substr(0, model_name.find("/"));
@@ -22,7 +22,7 @@ const std::string AQModelManager::get_model_namespace(const std::string& model_n
}
}
-const Option<nlohmann::json> AQModelManager::get_config() {
+const Option<nlohmann::json> VQModelManager::get_config() {
auto config_url = get_config_url();
auto& client = HttpClient::get_instance();
std::string res;
@@ -42,24 +42,24 @@ const Option<nlohmann::json> AQModelManager::get_config() {
}
}
-const std::string AQModelManager::get_absolute_model_path(const std::string& model_name) {
- auto audio_query_home = EmbedderManager::get_model_dir();
- audio_query_home += audio_query_home.back() == '/' ? "" : "/";
- audio_query_home += "audio_query";
- std::filesystem::path path(audio_query_home);
+const std::string VQModelManager::get_absolute_model_path(const std::string& model_name) {
+ auto voice_query_home = EmbedderManager::get_model_dir();
+ voice_query_home += voice_query_home.back() == '/' ? "" : "/";
+ voice_query_home += "voice_query";
+ std::filesystem::path path(voice_query_home);
if (!std::filesystem::exists(path)) {
std::filesystem::create_directory(path);
}
auto model_namespace = get_model_namespace(model_name);
- std::filesystem::path model_path(audio_query_home.back() == '/' ? audio_query_home + model_namespace : audio_query_home + "/" + model_namespace);
+ std::filesystem::path model_path(voice_query_home.back() == '/' ? voice_query_home + model_namespace : voice_query_home + "/" + model_namespace);
if (!std::filesystem::exists(model_path)) {
std::filesystem::create_directory(model_path);
}
- return audio_query_home.back() == '/' ? audio_query_home + model_name + ".bin" : audio_query_home + "/" + model_name + ".bin";
+ return voice_query_home.back() == '/' ? voice_query_home + model_name + ".bin" : voice_query_home + "/" + model_name + ".bin";
}
-Option<bool> AQModelManager::download_model(const std::string& model_name) {
+Option<bool> VQModelManager::download_model(const std::string& model_name) {
auto model_path = get_absolute_model_path(model_name);
auto config = get_config();
@@ -92,15 +92,15 @@ Option<bool> AQModelManager::download_model(const std::string& model_name) {
return Option<bool>(true);
}
-Option<std::shared_ptr<AQModel>> AQModelManager::validate_and_init_model(const std::string& model_name) {
+Option<std::shared_ptr<VQModel>> VQModelManager::validate_and_init_model(const std::string& model_name) {
if(models.find(model_name) != models.end()) {
- return Option<std::shared_ptr<AQModel>>(models[model_name]);
+ return Option<std::shared_ptr<VQModel>>(models[model_name]);
}
auto download_res = download_model(model_name);
if (!download_res.ok()) {
- return Option<std::shared_ptr<AQModel>>(download_res.code(), download_res.error());
+ return Option<std::shared_ptr<VQModel>>(download_res.code(), download_res.error());
}
auto model_path = get_absolute_model_path(model_name);
@@ -109,29 +109,29 @@ Option<std::shared_ptr<AQModel>> AQModelManager::validate_and_init_model(const s
if (model_namespace == "whisper") {
auto whisper_ctx = WhisperModel::validate_and_load_model(model_path);
if (!whisper_ctx) {
- return Option<std::shared_ptr<AQModel>>(400, "Failed to load audio query model");
+ return Option<std::shared_ptr<VQModel>>(400, "Failed to load audio query model");
}
- auto whisper_model = std::shared_ptr<AQModel>(new WhisperModel(whisper_ctx, model_name));
+ auto whisper_model = std::shared_ptr<VQModel>(new WhisperModel(whisper_ctx, model_name));
{
std::unique_lock<std::shared_mutex> lock(models_mutex);
models[model_name] = whisper_model;
}
- return Option<std::shared_ptr<AQModel>>(whisper_model);
+ return Option<std::shared_ptr<VQModel>>(whisper_model);
} else {
- return Option<std::shared_ptr<AQModel>>(400, "Unknown model namespace");
+ return Option<std::shared_ptr<VQModel>>(400, "Unknown model namespace");
}
}
-Option<std::shared_ptr<AQModel>> AQModelManager::get_model(const std::string& model_name) {
+Option<std::shared_ptr<VQModel>> VQModelManager::get_model(const std::string& model_name) {
std::shared_lock<std::shared_mutex> lock(models_mutex);
auto model = models.find(model_name);
if (model == models.end()) {
- return Option<std::shared_ptr<AQModel>>(400, "Audio query model not found");
+ return Option<std::shared_ptr<VQModel>>(400, "Audio query model not found");
}
- return Option<std::shared_ptr<AQModel>>(model->second);
+ return Option<std::shared_ptr<VQModel>>(model->second);
}
-void AQModelManager::delete_model(const std::string& model_name) {
+void VQModelManager::delete_model(const std::string& model_name) {
std::unique_lock<std::shared_mutex> lock(models_mutex);
auto model = models.find(model_name);
if (model != models.end()) {
@@ -139,12 +139,12 @@ void AQModelManager::delete_model(const std::string& model_name) {
}
}
-void AQModelManager::delete_all_models() {
+void VQModelManager::delete_all_models() {
std::unique_lock<std::shared_mutex> lock(models_mutex);
models.clear();
}
-void AQModelManager::clear_unused_models() {
+void VQModelManager::clear_unused_models() {
std::unique_lock<std::shared_mutex> lock(models_mutex);
for (auto it = models.begin(); it != models.end();) {
if (it->second->get_collection_ref_count() == 0) {
@@ -155,6 +155,6 @@ void AQModelManager::clear_unused_models() {
}
}
-AQModelManager::~AQModelManager() {
+VQModelManager::~VQModelManager() {
delete_all_models();
}
\ No newline at end of file
diff --git a/src/collection.cpp b/src/collection.cpp
index 6ed71406..dfde66e5 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -47,17 +47,17 @@ Collection::Collection(const std::string& name, const uint32_t collection_id, co
const float max_memory_ratio, const std::string& fallback_field_type,
const std::vector<std::string>& symbols_to_index,
const std::vector<std::string>& token_separators,
- const bool enable_nested_fields, std::shared_ptr<AQModel> aq_model) :
+ const bool enable_nested_fields, std::shared_ptr<VQModel> vq_model) :
name(name), collection_id(collection_id), created_at(created_at),
next_seq_id(next_seq_id), store(store),
fields(fields), default_sorting_field(default_sorting_field), enable_nested_fields(enable_nested_fields),
max_memory_ratio(max_memory_ratio),
fallback_field_type(fallback_field_type), dynamic_fields({}),
symbols_to_index(to_char_array(symbols_to_index)), token_separators(to_char_array(token_separators)),
- index(init_index()), aq_model(aq_model) {
+ index(init_index()), vq_model(vq_model) {
- if (aq_model) {
- aq_model->inc_collection_ref_count();
+ if (vq_model) {
+ vq_model->inc_collection_ref_count();
}
this->num_documents = 0;
}
@@ -68,8 +68,8 @@ Collection::~Collection() {
delete index;
delete synonym_index;
- if (aq_model) {
- aq_model->dec_collection_ref_count();
+ if (vq_model) {
+ vq_model->dec_collection_ref_count();
}
}
@@ -455,9 +455,9 @@ nlohmann::json Collection::get_summary_json() const {
json_response["fields"] = fields_arr;
json_response["default_sorting_field"] = default_sorting_field;
- if(aq_model) {
- json_response["audio_query_model"] = nlohmann::json::object();
- json_response["audio_query_model"]["model_name"] = aq_model->get_model_name();
+ if(vq_model) {
+ json_response["voice_query_model"] = nlohmann::json::object();
+ json_response["voice_query_model"]["model_name"] = vq_model->get_model_name();
}
return json_response;
@@ -1700,7 +1700,7 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
const std::string& conversation_model_id,
std::string conversation_id,
const std::string& override_tags_str,
- const std::string& audio_query) const {
+ const std::string& voice_query) const {
std::shared_lock lock(mutex);
// setup thread local vars
@@ -1772,12 +1772,12 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
size_t num_embed_fields = 0;
std::string query = raw_query;
std::string transcribed_query;
- if(!audio_query.empty()) {
- if(!aq_model) {
- return Option<nlohmann::json>(400, "Audio query is not enabled. Please set `audio_query_model` for this collection.");
+ if(!voice_query.empty()) {
+ if(!vq_model) {
+ return Option<nlohmann::json>(400, "Audio query is not enabled. Please set `voice_query_model` for this collection.");
}
- auto transcribe_res = aq_model->transcribe(audio_query);
+ auto transcribe_res = vq_model->transcribe(voice_query);
if(!transcribe_res.ok()) {
return Option<nlohmann::json>(transcribe_res.code(), transcribe_res.error());
}
@@ -2983,9 +2983,9 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
result["request_params"]["per_page"] = per_page;
result["request_params"]["q"] = raw_query;
- if(!audio_query.empty()) {
- result["audio_query"] = nlohmann::json::object();
- result["audio_query"]["transcribed_query"] = transcribed_query;
+ if(!voice_query.empty()) {
+ result["voice_query"] = nlohmann::json::object();
+ result["voice_query"]["transcribed_query"] = transcribed_query;
}
if(!override_metadata.empty()) {
@@ -6503,6 +6503,6 @@ Option<bool> Collection::parse_and_validate_vector_query(const std::string& vect
return Option<bool>(true);
}
-std::shared_ptr<AQModel> Collection::get_aq_model() {
- return aq_model;
+std::shared_ptr<VQModel> Collection::get_vq_model() {
+ return vq_model;
}
\ No newline at end of file
diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp
index 997469c9..a5a45b6f 100644
--- a/src/collection_manager.cpp
+++ b/src/collection_manager.cpp
@@ -138,24 +138,24 @@ Collection* CollectionManager::init_collection(const nlohmann::json & collection
}
LOG(INFO) << "Found collection " << this_collection_name << " with " << num_memory_shards << " memory shards.";
- std::shared_ptr<AQModel> model = nullptr;
- if(collection_meta.count(Collection::COLLECTION_AUDIO_QUERY_MODEL) != 0) {
- nlohmann::json audio_query_model = collection_meta[Collection::COLLECTION_AUDIO_QUERY_MODEL];
+ std::shared_ptr<VQModel> model = nullptr;
+ if(collection_meta.count(Collection::COLLECTION_VOICE_QUERY_MODEL) != 0) {
+ nlohmann::json voice_query_model = collection_meta[Collection::COLLECTION_VOICE_QUERY_MODEL];
- if(!audio_query_model.is_object()) {
- LOG(ERROR) << "Parameter `audio_query_model` must be an object.";
+ if(!voice_query_model.is_object()) {
+ LOG(ERROR) << "Parameter `voice_query_model` must be an object.";
}
- if(audio_query_model.count("model_name") == 0) {
- LOG(ERROR) << "Parameter `audio_query_model.model_name` is missing.";
+ if(voice_query_model.count("model_name") == 0) {
+ LOG(ERROR) << "Parameter `voice_query_model.model_name` is missing.";
}
- if(!audio_query_model["model_name"].is_string() || audio_query_model["model_name"].get<std::string>().empty()) {
- LOG(ERROR) << "Parameter `audio_query_model.model_name` is invalid.";
+ if(!voice_query_model["model_name"].is_string() || voice_query_model["model_name"].get<std::string>().empty()) {
+ LOG(ERROR) << "Parameter `voice_query_model.model_name` is invalid.";
}
- std::string model_name = audio_query_model["model_name"].get<std::string>();
- auto model_res = AQModelManager::get_instance().validate_and_init_model(model_name);
+ std::string model_name = voice_query_model["model_name"].get<std::string>();
+ auto model_res = VQModelManager::get_instance().validate_and_init_model(model_name);
if(!model_res.ok()) {
LOG(ERROR) << "Error while loading audio query model: " << model_res.error();
} else {
@@ -442,7 +442,7 @@ Option<Collection*> CollectionManager::create_collection(const std::string& name
const std::string& fallback_field_type,
const std::vector<std::string>& symbols_to_index,
const std::vector<std::string>& token_separators,
- const bool enable_nested_fields, std::shared_ptr<AQModel> model) {
+ const bool enable_nested_fields, std::shared_ptr<VQModel> model) {
std::unique_lock lock(mutex);
if(store->contains(Collection::get_meta_key(name))) {
@@ -481,8 +481,8 @@ Option<Collection*> CollectionManager::create_collection(const std::string& name
collection_meta[Collection::COLLECTION_ENABLE_NESTED_FIELDS] = enable_nested_fields;
if(model != nullptr) {
- collection_meta[Collection::COLLECTION_AUDIO_QUERY_MODEL] = nlohmann::json::object();
- collection_meta[Collection::COLLECTION_AUDIO_QUERY_MODEL]["model_name"] = model->get_model_name();
+ collection_meta[Collection::COLLECTION_VOICE_QUERY_MODEL] = nlohmann::json::object();
+ collection_meta[Collection::COLLECTION_VOICE_QUERY_MODEL]["model_name"] = model->get_model_name();
}
rocksdb::WriteBatch batch;
@@ -1166,7 +1166,7 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& re
const char *PRIORITIZE_NUM_MATCHING_FIELDS = "prioritize_num_matching_fields";
const char *OVERRIDE_TAGS = "override_tags";
- const char *AUDIO_QUERY = "audio_query";
+ const char *VOICE_QUERY = "voice_query";
// enrich params with values from embedded params
for(auto& item: embedded_params.items()) {
@@ -1297,7 +1297,7 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& re
bool prioritize_num_matching_fields = true;
std::string override_tags;
- std::string audio_query;
+ std::string voice_query;
std::unordered_map<std::string, size_t*> unsigned_int_values = {
@@ -1340,7 +1340,7 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& re
{DROP_TOKENS_MODE, &drop_tokens_mode_str},
{OVERRIDE_TAGS, &override_tags},
{CONVERSATION_MODEL_ID, &conversation_model_id},
- {AUDIO_QUERY, &audio_query},
+ {VOICE_QUERY, &voice_query},
};
std::unordered_map<std::string, bool*> bool_values = {
@@ -1562,7 +1562,7 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& re
conversation_model_id,
conversation_id,
override_tags,
- audio_query);
+ voice_query);
uint64_t timeMillis = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - begin).count();
@@ -1727,24 +1727,24 @@ Option<Collection*> CollectionManager::create_collection(nlohmann::json& req_jso
return Option<Collection*>(parse_op.code(), parse_op.error());
}
- std::shared_ptr<AQModel> model = nullptr;
- if(req_json.count(Collection::COLLECTION_AUDIO_QUERY_MODEL) != 0) {
- nlohmann::json audio_query_model = req_json[Collection::COLLECTION_AUDIO_QUERY_MODEL];
+ std::shared_ptr<VQModel> model = nullptr;
+ if(req_json.count(Collection::COLLECTION_VOICE_QUERY_MODEL) != 0) {
+ nlohmann::json voice_query_model = req_json[Collection::COLLECTION_VOICE_QUERY_MODEL];
- if(!audio_query_model.is_object()) {
- return Option<Collection*>(400, "Parameter `audio_query_model` must be an object.");
+ if(!voice_query_model.is_object()) {
+ return Option<Collection*>(400, "Parameter `voice_query_model` must be an object.");
}
- if(audio_query_model.count("model_name") == 0) {
- return Option<Collection*>(400, "Parameter `audio_query_model.model_name` is required.");
+ if(voice_query_model.count("model_name") == 0) {
+ return Option<Collection*>(400, "Parameter `voice_query_model.model_name` is required.");
}
- if(!audio_query_model["model_name"].is_string() || audio_query_model["model_name"].get<std::string>().empty()) {
- return Option<Collection*>(400, "Parameter `audio_query_model.model_name` must be a non-empty string.");
+ if(!voice_query_model["model_name"].is_string() || voice_query_model["model_name"].get<std::string>().empty()) {
+ return Option<Collection*>(400, "Parameter `voice_query_model.model_name` must be a non-empty string.");
}
- std::string model_name = audio_query_model["model_name"].get<std::string>();
- auto model_res = AQModelManager::get_instance().validate_and_init_model(model_name);
+ std::string model_name = voice_query_model["model_name"].get<std::string>();
+ auto model_res = VQModelManager::get_instance().validate_and_init_model(model_name);
if(!model_res.ok()) {
LOG(ERROR) << "Error while loading audio query model: " << model_res.error();
return Option<Collection*>(model_res.code(), model_res.error());
@@ -2019,7 +2019,7 @@ Option<Collection*> CollectionManager::clone_collection(const string& existing_n
auto coll_create_op = create_collection(new_name, DEFAULT_NUM_MEMORY_SHARDS, existing_coll->get_fields(),
existing_coll->get_default_sorting_field(), static_cast<uint64_t>(std::time(nullptr)),
existing_coll->get_fallback_field_type(), symbols_to_index, token_separators,
- existing_coll->get_enable_nested_fields(), existing_coll->get_aq_model());
+ existing_coll->get_enable_nested_fields(), existing_coll->get_vq_model());
lock.lock();
diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cpp
index 9f9b0370..53f6a1a0 100644
--- a/test/collection_vector_search_test.cpp
+++ b/test/collection_vector_search_test.cpp
@@ -9,7 +9,7 @@
#include "conversation_model_manager.h"
#include "index.h"
#include "core_api.h"
-#include "aq_model_manager.h"
+#include "vq_model_manager.h"
class CollectionVectorTest : public ::testing::Test {
protected:
@@ -3715,7 +3715,7 @@ TEST_F(CollectionVectorTest, TestInvalidAudioQueryModel) {
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": {
+ "voice_query_model": {
"model_name": "invalid-model"
}
})"_json;
@@ -3730,7 +3730,7 @@ TEST_F(CollectionVectorTest, TestInvalidAudioQueryModel) {
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": {
+ "voice_query_model": {
"model_name": "base.en"
}
})"_json;
@@ -3744,40 +3744,40 @@ TEST_F(CollectionVectorTest, TestInvalidAudioQueryModel) {
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": "invalid"
+ "voice_query_model": "invalid"
})"_json;
collection_create_op = collectionManager.create_collection(schema_json);
ASSERT_FALSE(collection_create_op.ok());
- ASSERT_EQ(collection_create_op.error(), "Parameter `audio_query_model` must be an object.");
+ ASSERT_EQ(collection_create_op.error(), "Parameter `voice_query_model` must be an object.");
schema_json = R"({
"name": "test",
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": {
+ "voice_query_model": {
"model_name": 1
}
})"_json;
collection_create_op = collectionManager.create_collection(schema_json);
ASSERT_FALSE(collection_create_op.ok());
- ASSERT_EQ(collection_create_op.error(), "Parameter `audio_query_model.model_name` must be a non-empty string.");
+ ASSERT_EQ(collection_create_op.error(), "Parameter `voice_query_model.model_name` must be a non-empty string.");
schema_json = R"({
"name": "test",
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": {
+ "voice_query_model": {
"model_name": ""
}
})"_json;
collection_create_op = collectionManager.create_collection(schema_json);
ASSERT_FALSE(collection_create_op.ok());
- ASSERT_EQ(collection_create_op.error(), "Parameter `audio_query_model.model_name` must be a non-empty string.");
+ ASSERT_EQ(collection_create_op.error(), "Parameter `voice_query_model.model_name` must be a non-empty string.");
}
TEST_F(CollectionVectorTest, TestAudioQuery) {
@@ -3786,7 +3786,7 @@ TEST_F(CollectionVectorTest, TestAudioQuery) {
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": {
+ "voice_query_model": {
"model_name": "whisper/base.en"
}
})"_json;
@@ -3817,7 +3817,7 @@ TEST_F(CollectionVectorTest, TestAudioQuery) {
ASSERT_TRUE(results.ok());
auto results_json = results.get();
- ASSERT_EQ(results_json["audio_query"]["transcribed_query"].get<std::string>(), " This is a test recording for audio search.");
+ ASSERT_EQ(results_json["voice_query"]["transcribed_query"].get<std::string>(), " This is a test recording for audio search.");
}
TEST_F(CollectionVectorTest, TestInvalidAudioQuery) {
@@ -3826,7 +3826,7 @@ TEST_F(CollectionVectorTest, TestInvalidAudioQuery) {
"fields": [
{"name": "name", "type": "string"}
],
- "audio_query_model": {
+ "voice_query_model": {
"model_name": "whisper/base.en"
}
})"_json;