@@ -142,6 +142,28 @@ json task_params::to_json(bool only_metrics) const {
142142 };
143143}
144144
145+ //
146+ // task_result_state
147+ //
148+ common_chat_msg task_result_state::update_chat_msg (
149+ const std::string & text_added,
150+ bool is_partial,
151+ std::vector<common_chat_msg_diff> & diffs) {
152+ generated_text += text_added;
153+ auto msg_prv_copy = chat_msg;
154+ SRV_DBG (" Parsing chat message: %s\n " , generated_text.c_str ());
155+ auto new_msg = common_chat_parse (
156+ generated_text,
157+ is_partial,
158+ chat_parser_params);
159+ if (!new_msg.empty ()) {
160+ new_msg.set_tool_call_ids (generated_tool_call_ids, gen_tool_call_id);
161+ chat_msg = new_msg;
162+ diffs = common_chat_msg_diff::compute_diffs (msg_prv_copy, new_msg.empty () ? msg_prv_copy : new_msg);
163+ }
164+ return chat_msg;
165+ }
166+
145167//
146168// server_task
147169//
@@ -714,25 +736,6 @@ json server_task_result_cmpl_final::to_json_oaicompat_chat() {
714736 return res;
715737}
716738
717- common_chat_msg task_result_state::update_chat_msg (
718- const std::string & text_added,
719- bool is_partial,
720- std::vector<common_chat_msg_diff> & diffs) {
721- generated_text += text_added;
722- auto msg_prv_copy = chat_msg;
723- SRV_DBG (" Parsing chat message: %s\n " , generated_text.c_str ());
724- auto new_msg = common_chat_parse (
725- generated_text,
726- is_partial,
727- chat_parser_params);
728- if (!new_msg.empty ()) {
729- new_msg.set_tool_call_ids (generated_tool_call_ids, gen_tool_call_id);
730- chat_msg = new_msg;
731- diffs = common_chat_msg_diff::compute_diffs (msg_prv_copy, new_msg.empty () ? msg_prv_copy : new_msg);
732- }
733- return chat_msg;
734- }
735-
736739json server_task_result_cmpl_final::to_json_oaicompat_chat_stream () {
737740 std::time_t t = std::time (0 );
738741 std::string finish_reason = " length" ;
@@ -1530,41 +1533,6 @@ json server_task_result_cmpl_partial::to_json_oaicompat_resp() {
15301533 return events;
15311534}
15321535
1533- //
1534- // server_task_result_embd
1535- //
1536- json server_task_result_embd::to_json () {
1537- return res_type == TASK_RESPONSE_TYPE_OAI_EMBD
1538- ? to_json_oaicompat ()
1539- : to_json_non_oaicompat ();
1540- }
1541-
1542- json server_task_result_embd::to_json_non_oaicompat () {
1543- return json {
1544- {" index" , index},
1545- {" embedding" , embedding},
1546- };
1547- }
1548-
1549- json server_task_result_embd::to_json_oaicompat () {
1550- return json {
1551- {" index" , index},
1552- {" embedding" , embedding[0 ]},
1553- {" tokens_evaluated" , n_tokens},
1554- };
1555- }
1556-
1557- //
1558- // server_task_result_rerank
1559- //
1560- json server_task_result_rerank::to_json () {
1561- return json {
1562- {" index" , index},
1563- {" score" , score},
1564- {" tokens_evaluated" , n_tokens},
1565- };
1566- }
1567-
15681536json server_task_result_cmpl_partial::to_json_anthropic () {
15691537 json events = json::array ();
15701538 bool first = (n_decoded == 1 );
@@ -1703,6 +1671,41 @@ json server_task_result_cmpl_partial::to_json_anthropic() {
17031671 return events;
17041672}
17051673
1674+ //
1675+ // server_task_result_embd
1676+ //
1677+ json server_task_result_embd::to_json () {
1678+ return res_type == TASK_RESPONSE_TYPE_OAI_EMBD
1679+ ? to_json_oaicompat ()
1680+ : to_json_non_oaicompat ();
1681+ }
1682+
1683+ json server_task_result_embd::to_json_non_oaicompat () {
1684+ return json {
1685+ {" index" , index},
1686+ {" embedding" , embedding},
1687+ };
1688+ }
1689+
1690+ json server_task_result_embd::to_json_oaicompat () {
1691+ return json {
1692+ {" index" , index},
1693+ {" embedding" , embedding[0 ]},
1694+ {" tokens_evaluated" , n_tokens},
1695+ };
1696+ }
1697+
1698+ //
1699+ // server_task_result_rerank
1700+ //
1701+ json server_task_result_rerank::to_json () {
1702+ return json {
1703+ {" index" , index},
1704+ {" score" , score},
1705+ {" tokens_evaluated" , n_tokens},
1706+ };
1707+ }
1708+
17061709//
17071710// server_task_result_error
17081711//
0 commit comments