File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -2654,10 +2654,12 @@ static std::unique_ptr<server_res_generator> handle_completions_impl(
26542654 }
26552655
26562656 // next responses are streamed
2657+ // to be sent immediately
2658+ json first_result_json = first_result->to_json ();
26572659 if (res_type == TASK_RESPONSE_TYPE_ANTHROPIC) {
2658- res->data = format_anthropic_sse (first_result-> to_json () );
2660+ res->data = format_anthropic_sse (first_result_json );
26592661 } else {
2660- res->data = format_oai_sse (first_result-> to_json ()); // to be sent immediately
2662+ res->data = format_oai_sse (first_result_json);
26612663 }
26622664 res->status = 200 ;
26632665 res->content_type = " text/event-stream" ;
@@ -2698,8 +2700,8 @@ static std::unique_ptr<server_res_generator> handle_completions_impl(
26982700 }
26992701
27002702 // send the results
2701- json res_json = result->to_json ();
27022703 if (result->is_error ()) {
2704+ json res_json = result->to_json ();
27032705 if (res_type == TASK_RESPONSE_TYPE_ANTHROPIC) {
27042706 output = format_anthropic_sse ({
27052707 {" event" , " error" },
@@ -2716,6 +2718,7 @@ static std::unique_ptr<server_res_generator> handle_completions_impl(
27162718 || dynamic_cast <server_task_result_cmpl_final*>(result.get ()) != nullptr
27172719 );
27182720 result->update (states[result->get_index ()]); // update generation state
2721+ json res_json = result->to_json ();
27192722 if (res_type == TASK_RESPONSE_TYPE_ANTHROPIC) {
27202723 output = format_anthropic_sse (res_json);
27212724 } else {
You can’t perform that action at this time.
0 commit comments