mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-26 03:14:35 +00:00
server : restore numeric prompts (#7883)
This commit is contained in:
parent
dcf752707d
commit
704a35b183
@ -147,7 +147,7 @@ struct server_slot {
|
|||||||
int32_t n_prompt_tokens = 0;
|
int32_t n_prompt_tokens = 0;
|
||||||
int32_t n_prompt_tokens_processed = 0;
|
int32_t n_prompt_tokens_processed = 0;
|
||||||
|
|
||||||
std::string prompt;
|
json prompt; // can be either a string, array of strings or array of token ids
|
||||||
|
|
||||||
// when a task is submitted, we first tokenize the prompt and store it here
|
// when a task is submitted, we first tokenize the prompt and store it here
|
||||||
std::vector<llama_token> prompt_tokens;
|
std::vector<llama_token> prompt_tokens;
|
||||||
@ -822,8 +822,13 @@ struct server_context {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip the slot if it does not contains prompt
|
||||||
|
if (!slot.prompt.is_string()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// current slot's prompt
|
// current slot's prompt
|
||||||
std::string slot_prompt = slot.prompt;
|
std::string slot_prompt = slot.prompt.get<std::string>();
|
||||||
|
|
||||||
// length of the current slot's prompt
|
// length of the current slot's prompt
|
||||||
int slot_prompt_len = slot_prompt.size();
|
int slot_prompt_len = slot_prompt.size();
|
||||||
@ -957,12 +962,12 @@ struct server_context {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prompt->is_string()) {
|
if ((prompt->is_string()) ||
|
||||||
slot.prompt = prompt->get<std::string>();
|
(prompt->is_array() && prompt->size() == 1 && prompt->at(0).is_string()) ||
|
||||||
} else if (prompt->is_array() && prompt->size() == 1 && prompt->at(0).is_string()) {
|
(prompt->is_array() && !prompt->empty() && prompt->at(0).is_number_integer())) {
|
||||||
slot.prompt = prompt->at(0).get<std::string>();
|
slot.prompt = *prompt;
|
||||||
} else {
|
} else {
|
||||||
send_error(task, "\"prompt\" must be a string or an array of strings", ERROR_TYPE_INVALID_REQUEST);
|
send_error(task, "\"prompt\" must be a string or an array of integers", ERROR_TYPE_INVALID_REQUEST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user