@@ -80,6 +80,11 @@ std::vector<std::string> ConvertJsonToParamsVector(const Json::Value& root) {
8080 res.push_back (" --no-mmap" );
8181 }
8282 continue ;
83+ } else if (member == " ignore_eos" ) {
84+ if (root[member].asBool ()) {
85+ res.push_back (" --ignore_eos" );
86+ }
87+ continue ;
8388 }
8489
8590 res.push_back (" --" + member);
@@ -502,6 +507,23 @@ void LocalEngine::HandleEmbedding(std::shared_ptr<Json::Value> json_body,
502507
503508void LocalEngine::LoadModel (std::shared_ptr<Json::Value> json_body,
504509 http_callback&& callback) {
510+ auto model_id = json_body->get (" model" , " " ).asString ();
511+ if (model_id.empty ()) {
512+ CTL_WRN (" Model is empty" );
513+ }
514+ if (server_map_.find (model_id) != server_map_.end ()) {
515+ CTL_INF (" Model " << model_id << " is already loaded" );
516+ Json::Value error;
517+ error[" error" ] = " Model " + model_id + " is already loaded" ;
518+ Json::Value status;
519+ status[" is_done" ] = true ;
520+ status[" has_error" ] = true ;
521+ status[" is_stream" ] = false ;
522+ status[" status_code" ] = 409 ;
523+ callback (std::move (status), std::move (error));
524+ return ;
525+ }
526+
505527 CTL_INF (" Start loading model" );
506528 auto wait_for_server_up = [this ](const std::string& model,
507529 const std::string& host, int port) {
@@ -524,10 +546,7 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
524546 };
525547
526548 LOG_DEBUG << " Start to spawn llama-server" ;
527- auto model_id = json_body->get (" model" , " " ).asString ();
528- if (model_id.empty ()) {
529- CTL_WRN (" Model is empty" );
530- }
549+
531550 server_map_[model_id].host = " 127.0.0.1" ;
532551 server_map_[model_id].port = GenerateRandomInteger (39400 , 39999 );
533552 auto & s = server_map_[model_id];
@@ -545,6 +564,8 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
545564 params.push_back (" --pooling" );
546565 params.push_back (" mean" );
547566
567+ params.push_back (" --jinja" );
568+
548569 std::vector<std::string> v;
549570 v.reserve (params.size () + 1 );
550571 auto engine_dir = engine_service_.GetEngineDirPath (kLlamaRepo );
0 commit comments