Repository: ggerganov/llama.cpp
File: tools/server/server.cpp (C++)

Code before:
        res->n_ctx           = n_ctx;

        queue_results.send(std::move(res));
    }

    // if multimodal is enabled, send an error and return false
    bool ensure_no_mtmd(const int id_task) {
        if (mctx) {
            send_error(id_task, "This feature is not supported by multimodal", ERROR_TYPE_NOT_SUPPORTED);
            return false;
        }
        return true;
    }

    void send_partial_response(server_slot & slot, const completion_token_output & tkn, bool is_progress) {
        auto res = std::make_unique<server_task_result_cmpl_partial>();

        res->id    = slot.id_task;
        res->index = slot.index;

        if (is_progress) {
            res->is_progress        = true;
            res->progress.total     = slot.n_prompt_tokens;
            res->progress.cache     = slot.n_prompt_tokens_cache;
            res->progress.processed = slot.cache_tokens.size();
            res->progress.time_ms   = ggml_time_ms() - (slot.t_start_process_prompt / 1000);
        } else {
            res->content = tkn.text_to_send;
            res->tokens  = { tkn.tok };

            slot.update_chat_msg(res->oaicompat_msg_diffs);
        }

        res->n_decoded           = slot.n_decoded;
        res->n_prompt_tokens     = slot.n_prompt_tokens;
        res->post_sampling_probs = slot.params.post_sampling_probs;

        res->verbose               = slot.params.verbose;
        res->oaicompat             = slot.params.oaicompat;
        res->oaicompat_model       = slot.params.oaicompat_model;
        res->oaicompat_cmpl_id     = slot.params.oaicompat_cmpl_id;

        // populate res.probs_output
        if (slot.params.sampling.n_probs > 0) {
            res->prob_output = tkn; // copy the token probs
        }

        // populate timings if this is final response or timings_per_token is enabled
        if (slot.stop != STOP_TYPE_NONE || slot.params.timings_per_token) {
            res->timings = slot.get_timings();
        }

Review comment (suggestion):
nit: we tend to use `ggml_time_us()` in server.cpp, so follow the pattern:

```suggestion
            res->progress.time_ms   = (ggml_time_us() - slot.t_start_process_prompt / 1000);
```

Code after:
        res->n_ctx           = n_ctx;

        queue_results.send(std::move(res));
    }

    // if multimodal is enabled, send an error and return false
    bool ensure_no_mtmd(const int id_task) {
        if (mctx) {
            send_error(id_task, "This feature is not supported by multimodal", ERROR_TYPE_NOT_SUPPORTED);
            return false;
        }
        return true;
    }

    void send_partial_response(server_slot & slot, const completion_token_output & tkn, bool is_progress) {
        auto res = std::make_unique<server_task_result_cmpl_partial>();

        res->id    = slot.id_task;
        res->index = slot.index;

        if (is_progress) {
            res->is_progress        = true;
            res->progress.total     = slot.n_prompt_tokens;
            res->progress.cache     = slot.n_prompt_tokens_cache;
            res->progress.processed = slot.cache_tokens.size();
            res->progress.time_ms   = (ggml_time_us() - slot.t_start_process_prompt / 1000);
        } else {
            res->content = tkn.text_to_send;
            res->tokens  = { tkn.tok };

            slot.update_chat_msg(res->oaicompat_msg_diffs);
        }

        res->n_decoded           = slot.n_decoded;
        res->n_prompt_tokens     = slot.n_prompt_tokens;
        res->post_sampling_probs = slot.params.post_sampling_probs;

        res->verbose               = slot.params.verbose;
        res->oaicompat             = slot.params.oaicompat;
        res->oaicompat_model       = slot.params.oaicompat_model;
        res->oaicompat_cmpl_id     = slot.params.oaicompat_cmpl_id;

        // populate res.probs_output
        if (slot.params.sampling.n_probs > 0) {
            res->prob_output = tkn; // copy the token probs
        }

        // populate timings if this is final response or timings_per_token is enabled
        if (slot.stop != STOP_TYPE_NONE || slot.params.timings_per_token) {
            res->timings = slot.get_timings();
        }