@@ -488,65 +488,40 @@ void Models::StartModel(
488488 if (!http_util::HasFieldInReq (req, callback, " model" ))
489489 return ;
490490 auto model_handle = (*(req->getJsonObject ())).get (" model" , " " ).asString ();
491- StartParameterOverride params_override;
492- if (auto & o = (*(req->getJsonObject ()))[" prompt_template" ]; !o.isNull ()) {
493- params_override.custom_prompt_template = o.asString ();
494- }
495-
496- if (auto & o = (*(req->getJsonObject ()))[" cache_enabled" ]; !o.isNull ()) {
497- params_override.cache_enabled = o.asBool ();
498- }
499-
500- if (auto & o = (*(req->getJsonObject ()))[" ngl" ]; !o.isNull ()) {
501- params_override.ngl = o.asInt ();
502- }
503-
504- if (auto & o = (*(req->getJsonObject ()))[" n_parallel" ]; !o.isNull ()) {
505- params_override.n_parallel = o.asInt ();
506- }
507-
508- if (auto & o = (*(req->getJsonObject ()))[" ctx_len" ]; !o.isNull ()) {
509- params_override.ctx_len = o.asInt ();
510- }
511-
512- if (auto & o = (*(req->getJsonObject ()))[" cache_type" ]; !o.isNull ()) {
513- params_override.cache_type = o.asString ();
514- }
515491
492+ std::optional<std::string> mmproj;
516493 if (auto & o = (*(req->getJsonObject ()))[" mmproj" ]; !o.isNull ()) {
517- params_override. mmproj = o.asString ();
494+ mmproj = o.asString ();
518495 }
519496
497+ auto bypass_llama_model_path = false ;
520498 // Support both llama_model_path and model_path for backward compatible
521499 // model_path has higher priority
522500 if (auto & o = (*(req->getJsonObject ()))[" llama_model_path" ]; !o.isNull ()) {
523- params_override. model_path = o.asString ();
501+ auto model_path = o.asString ();
524502 if (auto & mp = (*(req->getJsonObject ()))[" model_path" ]; mp.isNull ()) {
525503 // Bypass if model does not exist in DB and llama_model_path exists
526- if (std::filesystem::exists (params_override. model_path . value () ) &&
504+ if (std::filesystem::exists (model_path) &&
527505 !model_service_->HasModel (model_handle)) {
528506 CTL_INF (" llama_model_path exists, bypass check model id" );
529- params_override. bypass_llama_model_path = true ;
507+ bypass_llama_model_path = true ;
530508 }
531509 }
532510 }
533511
534- if (auto & o = (*(req->getJsonObject ()))[" model_path" ]; !o.isNull ()) {
535- params_override.model_path = o.asString ();
536- }
512+ auto bypass_model_check = (mmproj.has_value () || bypass_llama_model_path);
537513
538514 auto model_entry = model_service_->GetDownloadedModel (model_handle);
539- if (!model_entry.has_value () && !params_override. bypass_model_check () ) {
515+ if (!model_entry.has_value () && !bypass_model_check) {
540516 Json::Value ret;
541517 ret[" message" ] = " Cannot find model: " + model_handle;
542518 auto resp = cortex_utils::CreateCortexHttpJsonResponse (ret);
543519 resp->setStatusCode (drogon::k400BadRequest);
544520 callback (resp);
545521 return ;
546522 }
547- std::string engine_name = params_override.bypass_model_check ()
548- ? kLlamaEngine
549- : model_entry.value ().engine ;
523+ std::string engine_name =
524+ bypass_model_check ? kLlamaEngine : model_entry.value ().engine ;
550525 auto engine_validate = engine_service_->IsEngineReady (engine_name);
551526 if (engine_validate.has_error ()) {
552527 Json::Value ret;
@@ -565,7 +540,9 @@ void Models::StartModel(
565540 return ;
566541 }
567542
568- auto result = model_service_->StartModel (model_handle, params_override);
543+ auto result = model_service_->StartModel (
544+ model_handle, *(req->getJsonObject ()) /* params_override*/ ,
545+ bypass_model_check);
569546 if (result.has_error ()) {
570547 Json::Value ret;
571548 ret[" message" ] = result.error ();
@@ -668,7 +645,7 @@ void Models::AddRemoteModel(
668645
669646 auto model_handle = (*(req->getJsonObject ())).get (" model" , " " ).asString ();
670647 auto engine_name = (*(req->getJsonObject ())).get (" engine" , " " ).asString ();
671-
648+
672649 auto engine_validate = engine_service_->IsEngineReady (engine_name);
673650 if (engine_validate.has_error ()) {
674651 Json::Value ret;
@@ -687,7 +664,7 @@ void Models::AddRemoteModel(
687664 callback (resp);
688665 return ;
689666 }
690-
667+
691668 config::RemoteModelConfig model_config;
692669 model_config.LoadFromJson (*(req->getJsonObject ()));
693670 cortex::db::Models modellist_utils_obj;
0 commit comments