You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
send_error(task, "\"prompt\" must be a string, an array of strings, an array of integers, or a mixed array of strings and integers", ERROR_TYPE_INVALID_REQUEST);
981
+
send_error(task, "\"prompt\" must be a string, an array of stringsor an array of integers", ERROR_TYPE_INVALID_REQUEST);
991
982
returnfalse;
992
983
}
993
984
}
994
985
slot.prompt = *prompt;
995
986
} else {
996
-
send_error(task, "\"prompt\" must be a string, an array of strings, an array of integers, or a mixed array of strings and integers", ERROR_TYPE_INVALID_REQUEST);
987
+
send_error(task, "\"prompt\" must be a string, an array of stringsor an array of integers", ERROR_TYPE_INVALID_REQUEST);
997
988
returnfalse;
998
989
}
999
990
}
@@ -1511,27 +1502,15 @@ struct server_context {
1511
1502
tasks.push_back(std::move(task));
1512
1503
};
1513
1504
1514
-
staticconstexprconstchar * error_msg = "\"prompt\" must be a string, an array of token ids, a mixed array of strings and token ids, or an array of prompts";
1505
+
staticconstexprconstchar * error_msg = "\"prompt\" must be a string, an array of token ids or an array of prompts";
1515
1506
if (!data.contains("prompt")) {
1516
1507
throwstd::runtime_error(error_msg);
1517
1508
}
1518
1509
1519
1510
json prompt = data.at("prompt");
1520
1511
1521
-
auto is_valid_singleton_array = [](const json& arr) {
1522
-
bool has_number = false;
1523
-
for (constauto& elem : arr) {
1524
-
if (elem.is_number()) {
1525
-
has_number = true;
1526
-
} elseif (!elem.is_string()) {
1527
-
returnfalse;
1528
-
}
1529
-
}
1530
-
return has_number;
1531
-
};
1532
-
1533
-
// if the prompt is a singleton (i.e. a string, a list of tokens, or a mixed array of strings and tokens), we only need to create a single task
1534
-
if (prompt.is_string() || (prompt.is_array() && is_valid_singleton_array(prompt))) {
1512
+
// if the prompt is a singleton (i.e. a string or a list of tokens), we only need to create single task
1513
+
if (prompt.is_string() || json_is_array_of_numbers(prompt)) {
0 commit comments