Skip to content

Commit 422ed2f

Browse files
committed
[update] format code. sys add rmmode method.
1 parent e2f8967 commit 422ed2f

File tree

11 files changed

+56
-46
lines changed

11 files changed

+56
-46
lines changed

projects/llm_framework/main_asr/src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class llm_task {
9292
return -1;
9393
}
9494
nlohmann::json file_body;
95-
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
95+
std::list<std::string> config_file_paths =
96+
get_config_file_paths(base_model_path_, base_model_config_path_, model_);
9697
try {
9798
for (auto file_name : config_file_paths) {
9899
std::ifstream config_file(file_name);

projects/llm_framework/main_audio/src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ class llm_audio : public StackFlow {
141141
nlohmann::json error_body;
142142
std::string base_model_path;
143143
std::string base_model_config_path;
144-
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path, base_model_config_path, "audio");
144+
std::list<std::string> config_file_paths =
145+
get_config_file_paths(base_model_path, base_model_config_path, "audio");
145146
try {
146147
config_body = nlohmann::json::parse(data);
147148
for (auto file_name : config_file_paths) {

projects/llm_framework/main_kws/src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class llm_task {
9898
}
9999

100100
nlohmann::json file_body;
101-
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
101+
std::list<std::string> config_file_paths =
102+
get_config_file_paths(base_model_path_, base_model_config_path_, model_);
102103
try {
103104
for (auto file_name : config_file_paths) {
104105
std::ifstream config_file(file_name);
@@ -486,7 +487,7 @@ class llm_kws : public StackFlow {
486487
req_body["model"] = llm_task_obj->model_;
487488
req_body["response_format"] = llm_task_obj->response_format_;
488489
req_body["enoutput"] = llm_task_obj->enoutput_;
489-
req_body["inputs"] = llm_task_obj->inputs_;
490+
req_body["inputs"] = llm_task_obj->inputs_;
490491
send("kws.taskinfo", req_body, LLM_NO_ERROR, work_id);
491492
}
492493
}

projects/llm_framework/main_llm/src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class llm_task {
8585
return -1;
8686
}
8787
nlohmann::json file_body;
88-
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
88+
std::list<std::string> config_file_paths =
89+
get_config_file_paths(base_model_path_, base_model_config_path_, model_);
8990
try {
9091
for (auto file_name : config_file_paths) {
9192
std::ifstream config_file(file_name);
@@ -489,7 +490,7 @@ class llm_llm : public StackFlow {
489490
req_body["model"] = llm_task_obj->model_;
490491
req_body["response_format"] = llm_task_obj->response_format_;
491492
req_body["enoutput"] = llm_task_obj->enoutput_;
492-
req_body["inputs"] = llm_task_obj->inputs_;
493+
req_body["inputs"] = llm_task_obj->inputs_;
493494
send("llm.taskinfo", req_body, LLM_NO_ERROR, work_id);
494495
}
495496
}

projects/llm_framework/main_melotts/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class llm_tts : public StackFlow {
428428
}
429429
next_data = &tmp_msg2;
430430
}
431-
std::string user_msg = sample_unescapeString(*next_data);
431+
std::string user_msg = sample_unescapeString(*next_data);
432432
std::vector<std::string> tmp_data = llm_task_obj->lexicon_->splitEachChar(user_msg);
433433
for (auto cutf8 : tmp_data) {
434434
if (is_breakpoint(cutf8)) {

projects/llm_framework/main_sys/src/event_loop.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,25 @@ int _sys_hwinfo(int com_id, const nlohmann::json &json_obj)
160160
std::vector<ifconfig_t> ifcs;
161161
ifconfig(ifcs);
162162
std::vector<nlohmann::json> jifcs;
163-
for (auto& item : ifcs)
164-
{
163+
for (auto &item : ifcs) {
165164
nlohmann::json eth_info;
166-
eth_info["name"] = item.name;
167-
eth_info["ip"] = item.ip;
165+
eth_info["name"] = item.name;
166+
eth_info["ip"] = item.ip;
168167
char eth_ip_buff[128] = {0};
169168
sprintf(eth_ip_buff, "/sys/class/net/%s/speed", item.name);
170169
FILE *file = fopen(eth_ip_buff, "r");
171170
memset(eth_ip_buff, 0, sizeof(eth_ip_buff));
172-
if(file != NULL)
173-
{
171+
if (file != NULL) {
174172
int size = fread(eth_ip_buff, 1, sizeof(eth_ip_buff), file);
175-
if(size > 0)
176-
eth_ip_buff[size-1] = '\0';
173+
if (size > 0) eth_ip_buff[size - 1] = '\0';
177174
fclose(file);
178175
}
179176
eth_info["speed"] = eth_ip_buff;
180177
jifcs.push_back(eth_info);
181178
}
182179
data_body["eth_info"] = jifcs;
183-
out_body["data"] = data_body;
184-
std::string out = out_body.dump();
180+
out_body["data"] = data_body;
181+
std::string out = out_body.dump();
185182
zmq_com_send(com_id, out);
186183
return 0;
187184
}
@@ -254,6 +251,15 @@ int sys_lsmode(int com_id, const nlohmann::json &json_obj)
254251
return out;
255252
}
256253

254+
int sys_rmmode(int com_id, const nlohmann::json &json_obj)
255+
{
256+
std::string rmmode_name = json_obj["data"];
257+
const std::string command = "dpkg -P llm-" + rmmode_name;
258+
int out = system(command.c_str());
259+
usr_print_error(json_obj["request_id"], json_obj["work_id"], "{\"code\":0, \"message\":\"\"}", com_id);
260+
return out;
261+
}
262+
257263
int sys_lstask(int com_id, const nlohmann::json &json_obj)
258264
{
259265
int out;
@@ -349,6 +355,7 @@ int sys_update(int com_id, const nlohmann::json &json_obj)
349355
"{\"code\":-10, \"message\":\"Not available at the moment.\"}", com_id);
350356
return out;
351357
}
358+
352359
int sys_upgrade(int com_id, const nlohmann::json &json_obj)
353360
{
354361
int out;
@@ -521,6 +528,7 @@ void server_work()
521528
key_sql["sys.reset"] = sys_reset;
522529
key_sql["sys.reboot"] = sys_reboot;
523530
key_sql["sys.version"] = sys_version;
531+
key_sql["sys.rmmode"] = sys_rmmode;
524532
}
525533

526534
void server_stop_work()
@@ -554,8 +562,7 @@ void unit_action_match(int com_id, const std::string &json_str)
554562
usr_print_error("0", "sys", "{\"code\":-2, \"message\":\"json format error\"}", com_id);
555563
return;
556564
}
557-
if(work_id.empty())
558-
work_id = "sys";
565+
if (work_id.empty()) work_id = "sys";
559566
std::string action;
560567
error = doc["action"].get_string(action);
561568
if (error) {

projects/llm_framework/main_sys/src/serial_com.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class serial_com : public zmq_bus_com {
4141

4242
void send_data(const std::string &data)
4343
{
44-
if(exit_flage)
45-
linux_uart_write(uart_fd, data.length(), (void *)data.c_str());
44+
if (exit_flage) linux_uart_write(uart_fd, data.length(), (void *)data.c_str());
4645
}
4746

4847
void reace_data_event()
@@ -55,7 +54,7 @@ class serial_com : public zmq_bus_com {
5554
struct timeval timeout = {0, 500000};
5655
if ((select(uart_fd + 1, &readfds, NULL, NULL, &timeout) <= 0) || (!FD_ISSET(uart_fd, &readfds))) continue;
5756
ssize_t len = linux_uart_read(uart_fd, buff.size(), buff.data());
58-
if(len <= 0) continue;
57+
if (len <= 0) continue;
5958
{
6059
try {
6160
select_json_str(std::string(buff.data(), len),

projects/llm_framework/main_sys/src/tcp_com.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class tcp_com : public zmq_bus_com {
4242
void send_data(const std::string& data)
4343
{
4444
// tcp_server_mutex.lock();
45-
// if (exit_flage)
45+
// if (exit_flage)
4646
// {
4747
// auto tcp_channel = channel.lock();
4848
// if(tcp_channel)
@@ -52,8 +52,7 @@ class tcp_com : public zmq_bus_com {
5252
// }
5353
// tcp_server_mutex.unlock();
5454
auto tcp_channel = channel.lock();
55-
if(tcp_channel)
56-
{
55+
if (tcp_channel) {
5756
tcp_channel->write(data);
5857
}
5958
}
@@ -62,7 +61,7 @@ class tcp_com : public zmq_bus_com {
6261
void onConnection(const SocketChannelPtr& channel)
6362
{
6463
if (channel->isConnected()) {
65-
auto p_com = channel->newContextPtr<tcp_com>();
64+
auto p_com = channel->newContextPtr<tcp_com>();
6665
p_com->channel = channel;
6766
p_com->work(zmq_s_format, counter_port.fetch_add(1));
6867
if (counter_port.load() > 65535) counter_port.store(8000);
@@ -77,13 +76,12 @@ void onConnection(const SocketChannelPtr& channel)
7776

7877
void onMessage(const SocketChannelPtr& channel, Buffer* buf)
7978
{
80-
int len = (int)buf->size();
81-
char* data = (char*)buf->data();
79+
int len = (int)buf->size();
80+
char* data = (char*)buf->data();
8281
auto p_com = channel->getContextPtr<tcp_com>();
8382
p_com->tcp_server_mutex.lock();
8483
try {
85-
p_com->select_json_str(std::string(data, len),
86-
std::bind(&tcp_com::on_data, p_com, std::placeholders::_1));
84+
p_com->select_json_str(std::string(data, len), std::bind(&tcp_com::on_data, p_com, std::placeholders::_1));
8785
} catch (...) {
8886
std::string out_str;
8987
out_str += "{\"request_id\": \"0\",\"work_id\": \"sys\",\"created\": ";

projects/llm_framework/main_tokenizer/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
int main()
1010
{
1111
if (access("./_tokenizer.py", F_OK) == 0) {
12-
char *args[] = {(char*)"python3", (char*)"./_tokenizer.py", NULL};
12+
char *args[] = {(char *)"python3", (char *)"./_tokenizer.py", NULL};
1313
if (execvp("python3", args) == -1) {
1414
perror("execvp");
1515
return 1;
1616
}
1717
} else if (access("/opt/m5stack/share/_tokenizer.py", F_OK) == 0) {
18-
char *args[] = {(char*)"python3", (char*)"/opt/m5stack/share/_tokenizer.py", NULL};
18+
char *args[] = {(char *)"python3", (char *)"/opt/m5stack/share/_tokenizer.py", NULL};
1919
if (execvp("python3", args) == -1) {
2020
perror("execvp");
2121
return 1;

projects/llm_framework/main_vlm/src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ class llm_task {
8989
return -1;
9090
}
9191
nlohmann::json file_body;
92-
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
92+
std::list<std::string> config_file_paths =
93+
get_config_file_paths(base_model_path_, base_model_config_path_, model_);
9394
try {
9495
for (auto file_name : config_file_paths) {
9596
std::ifstream config_file(file_name);
@@ -502,7 +503,7 @@ class llm_llm : public StackFlow {
502503
req_body["model"] = llm_task_obj->model_;
503504
req_body["response_format"] = llm_task_obj->response_format_;
504505
req_body["enoutput"] = llm_task_obj->enoutput_;
505-
req_body["inputs"] = llm_task_obj->inputs_;
506+
req_body["inputs"] = llm_task_obj->inputs_;
506507
send("vlm.taskinfo", req_body, LLM_NO_ERROR, work_id);
507508
}
508509
}

0 commit comments

Comments
 (0)