@@ -35,7 +35,7 @@ typedef struct {
3535 float nms_threshold = 0.45 ;
3636} yolo_config;
3737
38- typedef std::function<void (const std::vector<nlohmann::json> &data, bool finish)> task_callback_t ;
38+ typedef std::function<void (const std::string &data, bool finish)> task_callback_t ;
3939
4040#define CONFIG_AUTO_SET (obj, key ) \
4141 if (config_body.contains(#key)) \
@@ -202,8 +202,8 @@ class llm_task {
202202 throw std::string (" depth_anything_ RunSync error" );
203203 }
204204 std::vector<detection::Object> objects;
205- depth_anything_-> Post_Process (img_mat, mode_config_. model_type ) ;
206- std::vector<nlohmann::json> depth_anything_output;
205+ std::string depth_anything_output ;
206+ depth_anything_-> Post_Process (img_mat, mode_config_. model_type , depth_anything_output) ;
207207 if (out_callback_) out_callback_ (depth_anything_output, true );
208208 } catch (...) {
209209 SLOGW (" yolo_->Run have error!" );
@@ -265,31 +265,29 @@ class llm_depth_anything : public StackFlow {
265265 }
266266
267267 void task_output (const std::weak_ptr<llm_task> llm_task_obj_weak,
268- const std::weak_ptr<llm_channel_obj> llm_channel_weak, const std::vector<nlohmann::json> &data,
269- bool finish)
268+ const std::weak_ptr<llm_channel_obj> llm_channel_weak, const std::string &data, bool finish)
270269 {
271270 auto llm_task_obj = llm_task_obj_weak.lock ();
272271 auto llm_channel = llm_channel_weak.lock ();
273272 if (!(llm_task_obj && llm_channel)) {
274273 return ;
275274 }
275+ std::string base64_data;
276+ int len = encode_base64 (data, base64_data);
276277 if (llm_channel->enstream_ ) {
277278 static int count = 0 ;
278279 nlohmann::json data_body;
279280 data_body[" index" ] = count++;
280- for (const auto &jsonObj : data) {
281- data_body[" delta" ].push_back (jsonObj);
282- }
283- if (!finish)
284- data_body[" delta" ] = data;
285- else
286- data_body[" delta" ] = std::string (" " );
281+ // if (!finish)
282+ data_body[" delta" ] = base64_data;
283+ // else
284+ // data_body["delta"] = std::string("");
287285 data_body[" finish" ] = finish;
288286 if (finish) count = 0 ;
289287 llm_channel->send (llm_task_obj->response_format_ , data_body, LLM_NO_ERROR);
290288 } else if (finish) {
291289 // SLOGI("send utf-8");
292- llm_channel->send (llm_task_obj->response_format_ , data , LLM_NO_ERROR);
290+ llm_channel->send (llm_task_obj->response_format_ , base64_data , LLM_NO_ERROR);
293291 }
294292 }
295293
0 commit comments