@@ -869,6 +869,7 @@ int main(int argc, char ** argv) {
869
869
is_interacting = true ;
870
870
}
871
871
872
+ // set the color for the prompt which will be output initially
872
873
if (params.use_color ) {
873
874
printf (ANSI_COLOR_YELLOW);
874
875
}
@@ -890,7 +891,7 @@ int main(int argc, char ** argv) {
890
891
embd.clear ();
891
892
892
893
if (embd_inp.size () <= input_consumed) {
893
- // out of input, sample next token
894
+ // out of user input, sample next token
894
895
const float top_k = params.top_k ;
895
896
const float top_p = params.top_p ;
896
897
const float temp = params.temp ;
@@ -920,7 +921,7 @@ int main(int argc, char ** argv) {
920
921
// decrement remaining sampling budget
921
922
--remaining_tokens;
922
923
} else {
923
- // if here, it means we are still processing the input prompt
924
+ // some user input remains from prompt or interaction, forward it to processing
924
925
while (embd_inp.size () > input_consumed) {
925
926
embd.push_back (embd_inp[input_consumed]);
926
927
last_n_tokens.erase (last_n_tokens.begin ());
@@ -930,17 +931,17 @@ int main(int argc, char ** argv) {
930
931
break ;
931
932
}
932
933
}
933
-
934
- if (params.use_color && embd_inp.size () <= input_consumed) {
935
- printf (ANSI_COLOR_RESET);
936
- }
937
934
}
938
935
939
936
// display text
940
937
if (!input_noecho) {
941
938
for (auto id : embd) {
942
939
printf (" %s" , vocab.id_to_token [id].c_str ());
943
940
}
941
+ // reset color to default if we there is no pending user input
942
+ if (params.use_color && embd_inp.size () <= input_consumed) {
943
+ printf (ANSI_COLOR_RESET);
944
+ }
944
945
fflush (stdout);
945
946
}
946
947
0 commit comments