Update examples/server/server.cpp
This commit is contained in:
parent
6075d7862d
commit
546f850796
1 changed files with 10 additions and 7 deletions
|
@ -693,9 +693,10 @@ static void parse_options_completion(const json & body, llama_server_context & l
|
|||
llama.params.logit_bias[llama_token_eos()] = -INFINITY;
|
||||
}
|
||||
|
||||
if (body["logit_bias"].is_array()) {
|
||||
const auto & logit_bias = body.find("logit_bias");
|
||||
if (logit_bias != body.end() && logit_bias->is_array()) {
|
||||
const int n_vocab = llama_n_vocab(llama.ctx);
|
||||
for (const auto & el : body["logit_bias"]) {
|
||||
for (const auto & el : *logit_bias) {
|
||||
if (el.is_array() && el.size() == 2 && el[0].is_number_integer()) {
|
||||
llama_token tok = el[0].get<llama_token>();
|
||||
if (tok >= 0 && tok < n_vocab) {
|
||||
|
@ -710,11 +711,13 @@ static void parse_options_completion(const json & body, llama_server_context & l
|
|||
}
|
||||
|
||||
llama.params.antiprompt.clear();
|
||||
if (!body["stop"].is_null()) {
|
||||
const auto stop = body["stop"].get<std::vector<std::string>>();
|
||||
std::copy_if(stop.begin(), stop.end(),
|
||||
std::back_inserter(llama.params.antiprompt),
|
||||
[](const std::string & str) { return !str.empty(); });
|
||||
const auto & stop = body.find("stop");
|
||||
if (stop != body.end() && stop->is_array()) {
|
||||
for (const auto & word : *stop) {
|
||||
if (!word.empty()) {
|
||||
llama.params.antiprompt.push_back(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_VERBOSE("completion parameters parsed", format_generation_settings(llama));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue