@@ -80,6 +80,11 @@ std::vector<std::string> ConvertJsonToParamsVector(const Json::Value& root) {
80
80
res.push_back (" --no-mmap" );
81
81
}
82
82
continue ;
83
+ } else if (member == " ignore_eos" ) {
84
+ if (root[member].asBool ()) {
85
+ res.push_back (" --ignore_eos" );
86
+ }
87
+ continue ;
83
88
}
84
89
85
90
res.push_back (" --" + member);
@@ -502,6 +507,23 @@ void LocalEngine::HandleEmbedding(std::shared_ptr<Json::Value> json_body,
502
507
503
508
void LocalEngine::LoadModel (std::shared_ptr<Json::Value> json_body,
504
509
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
+
505
527
CTL_INF (" Start loading model" );
506
528
auto wait_for_server_up = [this ](const std::string& model,
507
529
const std::string& host, int port) {
@@ -524,10 +546,7 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
524
546
};
525
547
526
548
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
+
531
550
server_map_[model_id].host = " 127.0.0.1" ;
532
551
server_map_[model_id].port = GenerateRandomInteger (39400 , 39999 );
533
552
auto & s = server_map_[model_id];
@@ -545,6 +564,8 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
545
564
params.push_back (" --pooling" );
546
565
params.push_back (" mean" );
547
566
567
+ params.push_back (" --jinja" );
568
+
548
569
std::vector<std::string> v;
549
570
v.reserve (params.size () + 1 );
550
571
auto engine_dir = engine_service_.GetEngineDirPath (kLlamaRepo );
0 commit comments