2020#include " commands/run_cmd.h"
2121#include " commands/server_start_cmd.h"
2222#include " commands/server_stop_cmd.h"
23- #include " config/yaml_config.h"
2423#include " services/engine_service.h"
2524#include " utils/file_manager_utils.h"
2625#include " utils/logging_utils.h"
@@ -35,6 +34,7 @@ constexpr const auto kSubcommands = "Subcommands";
3534} // namespace
3635CommandLineParser::CommandLineParser ()
3736 : app_(" Cortex.cpp CLI" ),
37+ model_service_{ModelService (std::make_shared<DownloadService>())},
3838 engine_service_{EngineService (std::make_shared<DownloadService>())} {}
3939
4040bool CommandLineParser::SetupCommand (int argc, char ** argv) {
@@ -152,7 +152,7 @@ void CommandLineParser::SetupCommonCommands() {
152152 chat_cmd->add_option (" model_id" , cml_data_.model_id , " " );
153153 chat_cmd->add_option (" -m,--message" , cml_data_.msg ,
154154 " Message to chat with model" );
155- chat_cmd->callback ([this , chat_cmd] {
155+ chat_cmd->callback ([& , chat_cmd] {
156156 if (cml_data_.model_id .empty ()) {
157157 CLI_LOG (" [model_id] is required\n " );
158158 CLI_LOG (chat_cmd->help ());
@@ -164,10 +164,10 @@ void CommandLineParser::SetupCommonCommands() {
164164 std::stoi (cml_data_.config .apiServerPort ),
165165 cml_data_.model_id );
166166 } else {
167- commands::ChatCompletionCmd (). Exec (
168- cml_data_.config .apiServerHost ,
169- std::stoi (cml_data_.config .apiServerPort ), cml_data_.model_id ,
170- cml_data_.msg );
167+ commands::ChatCompletionCmd (model_service_)
168+ . Exec ( cml_data_.config .apiServerHost ,
169+ std::stoi (cml_data_.config .apiServerPort ), cml_data_.model_id ,
170+ cml_data_.msg );
171171 }
172172 });
173173}
@@ -198,15 +198,15 @@ void CommandLineParser::SetupModelCommands() {
198198 " models start [model_id]" );
199199 model_start_cmd->add_option (" model_id" , cml_data_.model_id , " " );
200200 model_start_cmd->group (kSubcommands );
201- model_start_cmd->callback ([this , model_start_cmd]() {
201+ model_start_cmd->callback ([& , model_start_cmd]() {
202202 if (cml_data_.model_id .empty ()) {
203203 CLI_LOG (" [model_id] is required\n " );
204204 CLI_LOG (model_start_cmd->help ());
205205 return ;
206206 };
207- commands::ModelStartCmd (). Exec (cml_data_. config . apiServerHost ,
208- std::stoi (cml_data_.config .apiServerPort ) ,
209- cml_data_.model_id );
207+ commands::ModelStartCmd (model_service_)
208+ . Exec (cml_data_.config .apiServerHost ,
209+ std::stoi (cml_data_. config . apiServerPort ), cml_data_.model_id );
210210 });
211211
212212 auto stop_model_cmd =
@@ -215,15 +215,15 @@ void CommandLineParser::SetupModelCommands() {
215215 " models stop [model_id]" );
216216 stop_model_cmd->group (kSubcommands );
217217 stop_model_cmd->add_option (" model_id" , cml_data_.model_id , " " );
218- stop_model_cmd->callback ([this , stop_model_cmd]() {
218+ stop_model_cmd->callback ([& , stop_model_cmd]() {
219219 if (cml_data_.model_id .empty ()) {
220220 CLI_LOG (" [model_id] is required\n " );
221221 CLI_LOG (stop_model_cmd->help ());
222222 return ;
223223 };
224- commands::ModelStopCmd (). Exec (cml_data_. config . apiServerHost ,
225- std::stoi (cml_data_.config .apiServerPort ) ,
226- cml_data_.model_id );
224+ commands::ModelStopCmd (model_service_)
225+ . Exec (cml_data_.config .apiServerHost ,
226+ std::stoi (cml_data_. config . apiServerPort ), cml_data_.model_id );
227227 });
228228
229229 auto list_models_cmd =
0 commit comments