forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_stop_cmd.cc
More file actions
30 lines (25 loc) · 825 Bytes
/
model_stop_cmd.cc
File metadata and controls
30 lines (25 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "model_stop_cmd.h"
#include <json/value.h>
#include "utils/curl_utils.h"
#include "utils/logging_utils.h"
#include "utils/url_parser.h"
namespace commands {
void ModelStopCmd::Exec(const std::string& host, int port,
const std::string& model_handle) {
auto url = url_parser::Url{
/* .protocol = */ "http",
/* .host = */ host + ":" + std::to_string(port),
/* .pathParams = */ {"v1", "models", "stop"},
/* .queries = */ {},
};
Json::Value json_data;
json_data["model"] = model_handle;
auto data_str = json_data.toStyledString();
auto res = curl_utils::SimplePostJson(url.ToFullPath(), data_str);
if (res.has_error()) {
CLI_LOG_ERROR("Failed to stop model: " << res.error());
return;
}
CLI_LOG("Model stopped!");
}
}; // namespace commands