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

Do not index `role` and `message` for default conversation collection (#1786)

Ozan Armağan9caffccfc855
diff --git a/src/collection.cpp b/src/collection.cpp
index d1c561bc..692ac682 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -2888,13 +2888,9 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
return Option<nlohmann::json>(add_conversation_op.code(), add_conversation_op.error());
}
- auto get_conversation_op = ConversationManager::get_instance().get_conversation(add_conversation_op.get());
- if(!get_conversation_op.ok()) {
- return Option<nlohmann::json>(get_conversation_op.code(), get_conversation_op.error());
- }
if(exclude_fields.count("conversation_history") == 0) {
- result["conversation"]["conversation_history"] = get_conversation_op.get();
+ result["conversation"]["conversation_history"] = conversation_history;
}
result["conversation"]["conversation_id"] = add_conversation_op.get();
}
diff --git a/src/conversation_model_manager.cpp b/src/conversation_model_manager.cpp
index 562034dd..77592f7d 100644
--- a/src/conversation_model_manager.cpp
+++ b/src/conversation_model_manager.cpp
@@ -175,11 +175,13 @@ Option<Collection*> ConversationModelManager::get_default_conversation_collectio
},
{
"name": "role",
- "type": "string"
+ "type": "string",
+ "index": false
},
{
"name": "message",
- "type": "string"
+ "type": "string",
+ "index: false
},
{
"name": "timestamp",
diff --git a/src/core_api.cpp b/src/core_api.cpp
index e12711ab..d0bcae52 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -971,13 +971,8 @@ bool post_multi_search(const std::shared_ptr<http_req>& req, const std::shared_p
return false;
}
- auto get_conversation_op = ConversationManager::get_instance().get_conversation(add_conversation_op.get());
- if(!get_conversation_op.ok()) {
- res->set_400(get_conversation_op.error());
- return false;
- }
if(!exclude_conversation_history) {
- response["conversation"]["conversation_history"] = get_conversation_op.get();
+ response["conversation"]["conversation_history"] = new_conversation_history;
}
response["conversation"]["conversation_id"] = add_conversation_op.get();
@@ -2994,7 +2989,15 @@ bool post_conversation_model(const std::shared_ptr<http_req>& req, const std::sh
return false;
}
- const std::string& model_id = req->metadata;
+ std::string model_id = "";
+ try {
+ nlohmann::json parsed_json = nlohmann::json::parse(req->body);
+ if(parsed_json.count("id") != 0 && parsed_json["id"].is_string()) {
+ model_id = parsed_json["id"].get<std::string>();
+ }
+ } catch(const std::exception& e) {
+
+ }
auto add_model_op = ConversationModelManager::add_model(req_json, model_id);