Fix conversation model id generation (#1790)

* Fix conversation model id generation

* Fix typo
This commit is contained in:
Ozan Armağan 2024-06-19 19:27:59 +03:00 committed by GitHub
parent 34e864d4a8
commit 63f0b8025d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 10 deletions

View File

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

View File

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