24
24
#include < string>
25
25
#include < vector>
26
26
27
+ #include " chat-template.hpp"
27
28
#include " common.h"
28
29
#include " json.hpp"
29
30
#include " linenoise.cpp/linenoise.h"
30
31
#include " llama-cpp.h"
31
- #include " chat-template.hpp "
32
+ #include " log.h "
32
33
33
34
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(_WIN32)
34
35
[[noreturn]] static void sigint_handler (int ) {
35
- printf (" \n\033 [0m " );
36
+ printf (" \n " LOG_COL_DEFAULT );
36
37
exit (0 ); // not ideal, but it's the only way to guarantee exit in all cases
37
38
}
38
39
#endif
@@ -847,7 +848,7 @@ static int check_context_size(const llama_context_ptr & ctx, const llama_batch &
847
848
const int n_ctx = llama_n_ctx (ctx.get ());
848
849
const int n_ctx_used = llama_get_kv_cache_used_cells (ctx.get ());
849
850
if (n_ctx_used + batch.n_tokens > n_ctx) {
850
- printf (" \033 [0m \n " );
851
+ printf (LOG_COL_DEFAULT " \n " );
851
852
printe (" context size exceeded\n " );
852
853
return 1 ;
853
854
}
@@ -910,7 +911,7 @@ static int generate(LlamaData & llama_data, const std::string & prompt, std::str
910
911
batch = llama_batch_get_one (&new_token_id, 1 );
911
912
}
912
913
913
- printf (" \033 [0m " );
914
+ printf (LOG_COL_DEFAULT );
914
915
return 0 ;
915
916
}
916
917
@@ -919,7 +920,7 @@ static int read_user_input(std::string & user_input) {
919
920
#ifdef WIN32
920
921
printf (
921
922
" \r %*s"
922
- " \r\033 [0m %s" ,
923
+ " \r " LOG_COL_DEFAULT " %s" ,
923
924
get_terminal_width (), " " , prompt_prefix);
924
925
925
926
std::getline (std::cin, user_input);
@@ -956,7 +957,7 @@ static int generate_response(LlamaData & llama_data, const std::string & prompt,
956
957
const bool stdout_a_terminal) {
957
958
// Set response color
958
959
if (stdout_a_terminal) {
959
- printf (" \033 [33m " );
960
+ printf (LOG_COL_YELLOW );
960
961
}
961
962
962
963
if (generate (llama_data, prompt, response)) {
@@ -965,7 +966,7 @@ static int generate_response(LlamaData & llama_data, const std::string & prompt,
965
966
}
966
967
967
968
// End response with color reset and newline
968
- printf (" \n %s" , stdout_a_terminal ? " \033 [0m " : " " );
969
+ printf (" \n %s" , stdout_a_terminal ? LOG_COL_DEFAULT : " " );
969
970
return 0 ;
970
971
}
971
972
0 commit comments