Flush stdout and output ending newline if streaming.
This commit is contained in:
parent
a86c844f3f
commit
b1d9c2636a
1 changed files with 5 additions and 0 deletions
|
@ -158,12 +158,17 @@ static std::string generate(llama_context* ctx, const std::string& prompt, bool
|
|||
std::string piece = llama_token_to_piece(ctx, token);
|
||||
if (stream) {
|
||||
std::printf("%s", piece.c_str());
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
pieces.push_back(piece);
|
||||
inputs.push_back(token);
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
llama_batch_free(bat);
|
||||
|
||||
return aggregate_pieces(pieces);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue