Skip to content

Commit bc70332

Browse files
committed
[update]
- update camera. - StackFlow add get_config_file_paths. - StackFlow output add \n. - sys.hwinfo add eth info.
1 parent 046b753 commit bc70332

21 files changed

Lines changed: 219 additions & 520 deletions

File tree

ext_components/StackFlow/stackflow/StackFlow.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class llm_channel_obj {
133133
} else
134134
out_body["error"] = error_msg;
135135
std::string out = out_body.dump();
136+
out += "\n";
136137
if (outuart)
137138
return output_to_uart(out);
138139
else
@@ -155,6 +156,7 @@ class llm_channel_obj {
155156
out_body["error"] = error_msg;
156157

157158
std::string out = out_body.dump();
159+
out += "\n";
158160
send_raw_to_pub(out);
159161
if (enoutput_) return send_raw_to_usr(out);
160162
return 0;
@@ -176,6 +178,7 @@ class llm_channel_obj {
176178
out_body["error"] = error_msg;
177179

178180
std::string out = out_body.dump();
181+
out += "\n";
179182
send_raw_to_pub(out);
180183
if (enoutput_) return send_raw_to_usr(out);
181184
return 0;
@@ -342,10 +345,14 @@ class StackFlow {
342345
out_body["error"] = error_msg;
343346
if (zmq_url.empty()) {
344347
pzmq _zmq(out_zmq_url_, ZMQ_PUSH);
345-
return _zmq.send_data(out_body.dump());
348+
std::string out = out_body.dump();
349+
out += "\n";
350+
return _zmq.send_data(out);
346351
} else {
347352
pzmq _zmq(zmq_url, ZMQ_PUSH);
348-
return _zmq.send_data(out_body.dump());
353+
std::string out = out_body.dump();
354+
out += "\n";
355+
return _zmq.send_data(out);
349356
}
350357
}
351358

ext_components/StackFlow/stackflow/StackFlowUtil.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,19 @@ std::string StackFlows::unit_call(const std::string &unit_name, const std::strin
263263
pzmq _call(unit_name);
264264
_call.call_rpc_action(unit_action, data, [&value](pzmq *_pzmq, const std::string &raw) { value = raw; });
265265
return value;
266+
}
267+
268+
std::list<std::string> StackFlows::get_config_file_paths(const std::string &base_model_path,
269+
const std::string &mode_name)
270+
{
271+
std::shared_ptr<std::string> base_path((std::string *)(&base_model_path), [](std::string *Npt) {});
272+
if (base_path->empty()) base_path = std::make_shared<std::string>("/opt/m5stack/data/");
273+
std::list<std::string> config_file_paths;
274+
config_file_paths.push_back(std::string("./") + mode_name + ".json");
275+
config_file_paths.push_back(std::string("./asr_mode_") + mode_name + ".json");
276+
config_file_paths.push_back((*base_path) + "../share/" + mode_name + ".json");
277+
config_file_paths.push_back((*base_path) + "../share/asr_mode_" + mode_name + ".json");
278+
config_file_paths.push_back((*base_path) + mode_name + ".json");
279+
config_file_paths.push_back((*base_path) + "asr_mode_" + mode_name + ".json");
280+
return config_file_paths;
266281
}

ext_components/StackFlow/stackflow/StackFlowUtil.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <string>
88
#include <cstring>
99
#include <unordered_map>
10+
#include <list>
1011
#define WORK_ID_NONE -100
1112

1213
#define RPC_PUSH_PARAM(_obj, _data1, _data2) \
@@ -31,4 +32,5 @@ bool decode_stream(const std::string &in, std::string &out, std::unordered_map<i
3132
int decode_base64(const std::string &in, std::string &out);
3233
int encode_base64(const std::string &in, std::string &out);
3334
std::string unit_call(const std::string &unit_name, const std::string &unit_action, const std::string &data);
35+
std::list<std::string> get_config_file_paths(const std::string &base_model_path, const std::string &mode_name);
3436
}; // namespace StackFlows

projects/llm_framework/main_asr/src/main.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ class llm_task {
9292
return -1;
9393
}
9494
nlohmann::json file_body;
95-
std::list<std::string> config_file_paths;
96-
config_file_paths.push_back(std::string("./") + model_ + ".json");
97-
config_file_paths.push_back(base_model_path_ + "../share/" + model_ + ".json");
95+
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, model_);
9896
try {
9997
for (auto file_name : config_file_paths) {
10098
std::ifstream config_file(file_name);
@@ -644,7 +642,7 @@ class llm_asr : public StackFlow {
644642
req_body["model"] = llm_task_obj->model_;
645643
req_body["response_format"] = llm_task_obj->response_format_;
646644
req_body["enoutput"] = llm_task_obj->enoutput_;
647-
req_body["inputs"] = llm_task_obj->inputs_;
645+
req_body["inputs"] = llm_task_obj->inputs_;
648646
send("asr.taskinfo", req_body, LLM_NO_ERROR, work_id);
649647
}
650648
}

projects/llm_framework/main_audio/src/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class llm_audio : public StackFlow {
139139
nlohmann::json config_body;
140140
nlohmann::json file_body;
141141
nlohmann::json error_body;
142-
std::list<std::string> config_file_paths;
143-
config_file_paths.push_back("./audio.json");
144-
config_file_paths.push_back("/opt/m5stack/share/audio.json");
142+
std::list<std::string> config_file_paths = get_config_file_paths("/opt/m5stack/data", "audio");
145143
try {
146144
config_body = nlohmann::json::parse(data);
147145
for (auto file_name : config_file_paths) {

0 commit comments

Comments
 (0)