server_task_result_cmpl_partial
| 1266 | // server_task_result_cmpl_partial |
| 1267 | // |
| 1268 | void server_task_result_cmpl_partial::update(task_result_state & state) { |
| 1269 | is_updated = true; |
| 1270 | state.update_chat_msg(content, true, oaicompat_msg_diffs); |
| 1271 | |
| 1272 | // Copy current state for use in to_json_*() (reflects state BEFORE this chunk) |
| 1273 | thinking_block_started = state.thinking_block_started; |
| 1274 | text_block_started = state.text_block_started; |
| 1275 | |
| 1276 | oai_resp_id = state.oai_resp_id; |
| 1277 | oai_resp_reasoning_id = state.oai_resp_reasoning_id; |
| 1278 | oai_resp_message_id = state.oai_resp_message_id; |
| 1279 | oai_resp_fc_id = state.oai_resp_fc_id; |
| 1280 | |
| 1281 | // track if the accumulated message has any reasoning content |
| 1282 | anthropic_has_reasoning = !state.chat_msg.reasoning_content.empty(); |
| 1283 | |
| 1284 | // Pre-compute state updates based on diffs (for next chunk) |
| 1285 | for (const common_chat_msg_diff & diff : oaicompat_msg_diffs) { |
| 1286 | if (!diff.reasoning_content_delta.empty() && !state.thinking_block_started) { |
| 1287 | state.thinking_block_started = true; |
| 1288 | } |
| 1289 | if (!diff.content_delta.empty() && !state.text_block_started) { |
| 1290 | state.text_block_started = true; |
| 1291 | } |
| 1292 | if (!diff.tool_call_delta.name.empty()) { |
| 1293 | state.oai_resp_fc_id = diff.tool_call_delta.id; |
| 1294 | } |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | json server_task_result_cmpl_partial::to_json() { |
| 1299 | GGML_ASSERT(is_updated && "update() must be called before to_json()"); |
nothing calls this directly
no test coverage detected