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
Copy file name to clipboardExpand all lines: examples/server/server.cpp
+33-56Lines changed: 33 additions & 56 deletions
Original file line number
Diff line number
Diff line change
@@ -1513,70 +1513,48 @@ struct server_context {
1513
1513
}
1514
1514
tasks.push_back(std::move(task));
1515
1515
};
1516
-
1517
-
staticconstexprconstchar * error_msg = "\"prompt\" must be a string, an array of token ids or an array of prompts";
1516
+
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";
1518
1517
if (!data.contains("prompt")) {
1519
1518
throwstd::runtime_error(error_msg);
1520
1519
}
1521
-
1522
1520
json prompt = data.at("prompt");
1523
-
1524
-
// The commented out code removed the previous ability to submit a mixed array of strings and token IDs
1525
-
1526
-
// // if the prompt is a singleton (i.e. a string or a list of tokens), we only need to create single task
1527
-
// if (prompt.is_string() || json_is_array_of_numbers(prompt)) {
1528
-
// data["index"] = 0;
1529
-
// create_task(data, false, nullptr);
1530
-
// }
1531
-
// // otherwise, it's a multiple-prompt task, we break it into smaller tasks
1532
-
// else if (prompt.is_array()) {
1533
-
// std::vector<json> prompts = prompt;
1534
-
// for (size_t i = 0; i < prompts.size(); i++) {
1535
-
// const auto & e = prompts[i];
1536
-
// if (e.is_string() || json_is_array_of_numbers(e)) {
1537
-
// data["index"] = i;
1538
-
// create_task(data, true, e);
1539
-
// } else {
1540
-
// throw std::runtime_error(error_msg);
1541
-
// }
1542
-
// }
1543
-
// }
1544
-
// // invalid case
1545
-
// else {
1546
-
// throw std::runtime_error(error_msg);
1547
-
// }
1548
-
1549
-
// Single string prompt
1550
-
if (prompt.is_string()) {
1521
+
// 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
1522
+
if (prompt.is_string() || (prompt.is_array() && !prompt.empty() && !prompt[0].is_array())) {
0 commit comments