mirror of
https://github.com/typesense/typesense.git
synced 2025-05-22 14:55:26 +08:00
Fix conversation model id generation (#1790)
* Fix conversation model id generation * Fix typo
This commit is contained in:
parent
34e864d4a8
commit
63f0b8025d
@ -2989,15 +2989,7 @@ bool post_conversation_model(const std::shared_ptr<http_req>& req, const std::sh
|
||||
return false;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
}
|
||||
std::string model_id = req->metadata;
|
||||
|
||||
auto add_model_op = ConversationModelManager::add_model(req_json, model_id);
|
||||
|
||||
|
@ -547,7 +547,16 @@ int HttpServer::catch_all_handler(h2o_handler_t *_h2o_handler, h2o_req_t *req) {
|
||||
}
|
||||
|
||||
if(rpath->action == "conversations/models:create") {
|
||||
request->metadata = sole::uuid4().str();
|
||||
try {
|
||||
nlohmann::json body_json = nlohmann::json::parse(request->body);
|
||||
if(body_json.count("id") != 0 && body_json["id"].is_string()) {
|
||||
request->metadata = body_json["id"].get<std::string>();
|
||||
} else {
|
||||
request->metadata = sole::uuid4().str();
|
||||
}
|
||||
} catch (const nlohmann::json::parse_error& e) {
|
||||
request->metadata = sole::uuid4().str();
|
||||
}
|
||||
}
|
||||
|
||||
if(req->proceed_req == nullptr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user