Skip to content

Commit 7749240

Browse files
ggerganovNeo Zhang
authored andcommitted
main : print error on empty input (ggml-org#8456)
1 parent 6eb1f51 commit 7749240

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

examples/main/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,13 @@ int main(int argc, char ** argv) {
289289

290290
// Should not run without any tokens
291291
if (embd_inp.empty()) {
292-
embd_inp.push_back(llama_token_bos(model));
293-
LOG("embd_inp was considered empty and bos was added: %s\n", LOG_TOKENS_TOSTR_PRETTY(ctx, embd_inp).c_str());
292+
if (add_bos) {
293+
embd_inp.push_back(llama_token_bos(model));
294+
LOG("embd_inp was considered empty and bos was added: %s\n", LOG_TOKENS_TOSTR_PRETTY(ctx, embd_inp).c_str());
295+
} else {
296+
LOG_TEE("error: input is empty\n");
297+
return -1;
298+
}
294299
}
295300

296301
// Tokenize negative prompt

0 commit comments

Comments
 (0)