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

* Do not index `role` and `message` for default conversation collection

* Fix using custom conversation model id

* Remove unnecessary get_conversation call

* Check model id type
This commit is contained in:
Ozan Armağan 2024-06-16 15:33:31 +03:00 committed by GitHub
parent cf5278f267
commit 9caffccfc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 14 deletions

View File

@ -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();
}

View File

@ -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",

View File

@ -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);