mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-08-28 16:11:21 +02:00
big wip
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "server-task.h"
|
||||
|
||||
|
||||
#include "build-info.h"
|
||||
#include "server-chat.h"
|
||||
#include "chat.h"
|
||||
@@ -12,7 +13,6 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using json = nlohmann::ordered_json;
|
||||
|
||||
//
|
||||
// task_params
|
||||
@@ -304,7 +304,7 @@ json completion_token_output::probs_vector_to_json(const std::vector<completion_
|
||||
}
|
||||
|
||||
float completion_token_output::logarithm(float x) {
|
||||
// nlohmann::json converts -inf to null, so we need to prevent that
|
||||
// the JSON library converts -inf to null, so we need to prevent that
|
||||
return x == 0.0f ? std::numeric_limits<float>::lowest() : std::log(x);
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ json server_task_result_cmpl_final::to_json_oaicompat() {
|
||||
res["__verbose"] = to_json_non_oaicompat();
|
||||
}
|
||||
if (stats.is_set()) {
|
||||
res.push_back({"timings", stats.to_json()});
|
||||
res["timings"] = stats.to_json();
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -455,7 +455,7 @@ json server_task_result_cmpl_final::to_json_oaicompat_chat() {
|
||||
res["__verbose"] = to_json_non_oaicompat();
|
||||
}
|
||||
if (stats.is_set()) {
|
||||
res.push_back({"timings", stats.to_json()});
|
||||
res["timings"] = stats.to_json();
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -516,7 +516,7 @@ json server_task_result_cmpl_final::to_json_oaicompat_chat_stream() {
|
||||
}
|
||||
|
||||
if (stats.is_set()) {
|
||||
deltas.back().push_back({"timings", stats.to_json()});
|
||||
deltas.back()["timings"] = stats.to_json();
|
||||
}
|
||||
|
||||
// extra fields for debugging purposes
|
||||
@@ -709,7 +709,7 @@ json server_task_result_cmpl_final::to_json_oaicompat_resp_stream() {
|
||||
});
|
||||
|
||||
if (stats.is_set()) {
|
||||
server_sent_events.back().at("data").push_back({"timings", stats.to_json()});
|
||||
server_sent_events.back().at("data")["timings"] = stats.to_json();
|
||||
}
|
||||
|
||||
return server_sent_events;
|
||||
@@ -1061,10 +1061,10 @@ json server_task_result_cmpl_partial::to_json_non_oaicompat() {
|
||||
};
|
||||
// populate the timings object when needed (usually for the last response or with timings_per_token enabled)
|
||||
if (stats.is_set()) {
|
||||
res.push_back({"timings", stats.to_json()});
|
||||
res["timings"] = stats.to_json();
|
||||
}
|
||||
if (is_progress) {
|
||||
res.push_back({"prompt_progress", progress.to_json()});
|
||||
res["prompt_progress"] = progress.to_json();
|
||||
}
|
||||
if (!prob_output.probs.empty()) {
|
||||
res["completion_probabilities"] = completion_token_output::probs_vector_to_json({prob_output}, post_sampling_probs);
|
||||
@@ -1101,10 +1101,10 @@ json server_task_result_cmpl_partial::to_json_oaicompat() {
|
||||
res["__verbose"] = to_json_non_oaicompat();
|
||||
}
|
||||
if (stats.is_set()) {
|
||||
res.push_back({"timings", stats.to_json()});
|
||||
res["timings"] = stats.to_json();
|
||||
}
|
||||
if (is_progress) {
|
||||
res.push_back({"prompt_progress", progress.to_json()});
|
||||
res["prompt_progress"] = progress.to_json();
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -1155,10 +1155,10 @@ json server_task_result_cmpl_partial::to_json_oaicompat_chat() {
|
||||
}
|
||||
|
||||
if (stats.is_set()) {
|
||||
last_json.push_back({"timings", stats.to_json()});
|
||||
last_json["timings"] = stats.to_json();
|
||||
}
|
||||
if (is_progress) {
|
||||
last_json.push_back({"prompt_progress", progress.to_json()});
|
||||
last_json["prompt_progress"] = progress.to_json();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1305,10 +1305,10 @@ json server_task_result_cmpl_partial::to_json_oaicompat_resp() {
|
||||
if (!events.empty()) {
|
||||
json & data = events.back().at("data");
|
||||
if (stats.is_set()) {
|
||||
data.push_back({"timings", stats.to_json()});
|
||||
data["timings"] = stats.to_json();
|
||||
}
|
||||
if (is_progress) {
|
||||
data.push_back({"prompt_progress", progress.to_json()});
|
||||
data["prompt_progress"] = progress.to_json();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user