server_task_result_cmpl_partial
| 1382 | // server_task_result_cmpl_partial |
| 1383 | // |
| 1384 | void server_task_result_cmpl_partial::update(task_result_state & state) { |
| 1385 | is_updated = true; |
| 1386 | state.update_chat_msg(content, true, oaicompat_msg_diffs); |
| 1387 | |
| 1388 | // Copy current state for use in to_json_*() (reflects state BEFORE this chunk) |
| 1389 | thinking_block_started = state.thinking_block_started; |
| 1390 | text_block_started = state.text_block_started; |
| 1391 | |
| 1392 | oai_resp_id = state.oai_resp_id; |
| 1393 | oai_resp_reasoning_id = state.oai_resp_reasoning_id; |
| 1394 | oai_resp_message_id = state.oai_resp_message_id; |
| 1395 | oai_resp_fc_id = state.oai_resp_fc_id; |
| 1396 | |
| 1397 | // track if the accumulated message has any reasoning content |
| 1398 | anthropic_has_reasoning = !state.chat_msg.reasoning_content.empty(); |
| 1399 | |
| 1400 | // Pre-compute state updates based on diffs (for next chunk) |
| 1401 | for (const common_chat_msg_diff & diff : oaicompat_msg_diffs) { |
| 1402 | if (!diff.reasoning_content_delta.empty() && !state.thinking_block_started) { |
| 1403 | state.thinking_block_started = true; |
| 1404 | } |
| 1405 | if (!diff.content_delta.empty() && !state.text_block_started) { |
| 1406 | state.text_block_started = true; |
| 1407 | } |
| 1408 | if (!diff.tool_call_delta.name.empty()) { |
| 1409 | state.oai_resp_fc_id = diff.tool_call_delta.id; |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | json server_task_result_cmpl_partial::to_json() { |
| 1415 | GGML_ASSERT(is_updated && "update() must be called before to_json()"); |