@@ -2678,38 +2678,38 @@ int main(int argc, char **argv)
2678
2678
} else {
2679
2679
const auto chunked_content_provider = [task_id, &llama](size_t , httplib::DataSink &sink) {
2680
2680
while (true ) {
2681
- task_result llama_result = llama.next_result (task_id);
2682
- if (!llama_result.error ) {
2683
- std::vector<json> result_array = format_partial_response_oaicompat ( llama_result);
2681
+ task_result llama_result = llama.next_result (task_id);
2682
+ if (!llama_result.error ) {
2683
+ std::vector<json> result_array = format_partial_response_oaicompat ( llama_result);
2684
2684
2685
- for (auto it = result_array.begin (); it != result_array.end (); ++it)
2686
- {
2687
- if (!it->empty ()) {
2688
- const std::string str =
2689
- " data: " +
2690
- it->dump (-1 , ' ' , false , json::error_handler_t ::replace) +
2691
- " \n\n " ;
2692
- LOG_VERBOSE (" data stream" , {{" to_send" , str}});
2693
- if (!sink.write (str.c_str (), str.size ())) {
2694
- return false ;
2685
+ for (auto it = result_array.begin (); it != result_array.end (); ++it)
2686
+ {
2687
+ if (!it->empty ()) {
2688
+ const std::string str =
2689
+ " data: " +
2690
+ it->dump (-1 , ' ' , false , json::error_handler_t ::replace) +
2691
+ " \n\n " ;
2692
+ LOG_VERBOSE (" data stream" , {{" to_send" , str}});
2693
+ if (!sink.write (str.c_str (), str.size ())) {
2694
+ return false ;
2695
+ }
2695
2696
}
2696
2697
}
2697
- }
2698
- if (llama_result.stop ) {
2698
+ if (llama_result.stop ) {
2699
+ break ;
2700
+ }
2701
+ } else {
2702
+ const std::string str =
2703
+ " error: " +
2704
+ llama_result.result_json .dump (-1 , ' ' , false ,
2705
+ json::error_handler_t ::replace) +
2706
+ " \n\n " ;
2707
+ LOG_VERBOSE (" data stream" , {{" to_send" , str}});
2708
+ if (!sink.write (str.c_str (), str.size ())) {
2709
+ return false ;
2710
+ }
2699
2711
break ;
2700
2712
}
2701
- } else {
2702
- const std::string str =
2703
- " error: " +
2704
- llama_result.result_json .dump (-1 , ' ' , false ,
2705
- json::error_handler_t ::replace) +
2706
- " \n\n " ;
2707
- LOG_VERBOSE (" data stream" , {{" to_send" , str}});
2708
- if (!sink.write (str.c_str (), str.size ())) {
2709
- return false ;
2710
- }
2711
- break ;
2712
- }
2713
2713
}
2714
2714
sink.done ();
2715
2715
return true ;
0 commit comments