MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / send_final_response

Method send_final_response

examples/server/server.cpp:1172–1217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1170 }
1171
1172 void send_final_response(llama_client_slot &slot)
1173 {
1174 std::lock_guard<std::mutex> lock(mutex_results);
1175 task_result res;
1176 res.id = slot.task_id;
1177 res.error = false;
1178 res.stop = true;
1179
1180 res.result_json = json
1181 {
1182 {"content", !slot.params.stream ? slot.generated_text : ""},
1183 {"slot_id", slot.id},
1184 {"stop", true},
1185 {"model", params.model_alias},
1186 {"tokens_predicted", slot.n_decoded},
1187 {"tokens_evaluated", slot.num_prompt_tokens},
1188 {"generation_settings", get_formated_generation(slot)},
1189 {"prompt", slot.prompt},
1190 {"truncated", slot.truncated},
1191 {"stopped_eos", slot.stopped_eos},
1192 {"stopped_word", slot.stopped_word},
1193 {"stopped_limit", slot.stopped_limit},
1194 {"stopping_word", slot.stopping_word},
1195 {"tokens_cached", slot.n_past},
1196 {"timings", slot.get_formated_timings()}
1197 };
1198
1199 if (slot.sparams.n_probs > 0)
1200 {
1201 std::vector<completion_token_output> probs = {};
1202 if (!slot.params.stream && slot.stopped_word)
1203 {
1204 const std::vector<llama_token> stop_word_toks = llama_tokenize(ctx, slot.stopping_word, false);
1205 probs = std::vector<completion_token_output>(slot.generated_token_probs.begin(), slot.generated_token_probs.end() - stop_word_toks.size());
1206 }
1207 else
1208 {
1209 probs = std::vector<completion_token_output>(
1210 slot.generated_token_probs.begin(),
1211 slot.generated_token_probs.begin() + slot.sent_token_probs_index);
1212 }
1213 res.result_json["completion_probabilities"] = probs_vector_to_json(ctx, probs);
1214 }
1215
1216 queue_results.push_back(res);
1217 }
1218
1219 void send_embedding(llama_client_slot &slot)
1220 {

Callers

nothing calls this directly

Calls 7

probs_vector_to_jsonFunction · 0.85
get_formated_timingsMethod · 0.80
llama_tokenizeFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected