Debian update, big model, 3 predictions

This commit is contained in:
SuspiciousActivity committed 2026-09-18 19:52:18 +02:00
1 parent c99bfc0a37
commit 5dbfba9a84
5 files changed
+44 -17

No files matched your search

+16 -3
View File
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
auto text = req.get_param_value("text");
std::istringstream iss(text);
std::vector<std::pair<fasttext::real, std::string>> predictions;
ft.predictLine(iss, predictions, 1, 0.0);
ft.predictLine(iss, predictions, 3, 0.0);
if (predictions.empty()) {
res.status = 500;
@@ -41,8 +41,21 @@ int main(int argc, char *argv[]) {
return;
}
std::string result = "{\"language\":\"" + stripLabel(predictions[0].second) +
"\",\"probability\":" + std::to_string(predictions[0].first) + "}";
std::string result = "[";
bool first = true;
for (const auto& prediction : predictions) {
std::string predictionResult = "{\"language\":\"" + stripLabel(prediction.second) +
"\",\"probability\":" + std::to_string(prediction.first) + "}";
if (!first) {
result += ",";
}
result += predictionResult;
first = false;
}
result += "]";
res.set_content(result, "application/json");
});