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
@@ -890,7 +891,7 @@ static int check_context_size(const llama_context_ptr & ctx, const llama_batch &
890
891
const int n_ctx = llama_n_ctx (ctx.get ());
891
892
const int n_ctx_used = llama_get_kv_cache_used_cells (ctx.get ());
892
893
if (n_ctx_used + batch.n_tokens > n_ctx) {
893
- printf (" \033 [0m \n " );
894
+ printf (LOG_COL_DEFAULT " \n " );
894
895
printe (" context size exceeded\n " );
895
896
return 1 ;
896
897
}
@@ -953,7 +954,7 @@ static int generate(LlamaData & llama_data, const std::string & prompt, std::str
953
954
batch = llama_batch_get_one (&new_token_id, 1 );
954
955
}
955
956
956
- printf (" \033 [0m " );
957
+ printf (LOG_COL_DEFAULT );
957
958
return 0 ;
958
959
}
959
960
@@ -962,7 +963,7 @@ static int read_user_input(std::string & user_input) {
962
963
#ifdef WIN32
963
964
printf (
964
965
" \r %*s"
965
- " \r\033 [0m %s" ,
966
+ " \r " LOG_COL_DEFAULT " %s" ,
966
967
get_terminal_width (), " " , prompt_prefix);
967
968
968
969
std::getline (std::cin, user_input);
@@ -999,7 +1000,7 @@ static int generate_response(LlamaData & llama_data, const std::string & prompt,
999
1000
const bool stdout_a_terminal) {
1000
1001
// Set response color
1001
1002
if (stdout_a_terminal) {
1002
- printf (" \033 [33m " );
1003
+ printf (LOG_COL_YELLOW );
1003
1004
}
1004
1005
1005
1006
if (generate (llama_data, prompt, response)) {
@@ -1008,7 +1009,7 @@ static int generate_response(LlamaData & llama_data, const std::string & prompt,
1008
1009
}
1009
1010
1010
1011
// End response with color reset and newline
1011
- printf (" \n %s" , stdout_a_terminal ? " \033 [0m " : " " );
1012
+ printf (" \n %s" , stdout_a_terminal ? LOG_COL_DEFAULT : " " );
1012
1013
return 0 ;
1013
1014
}
1014
1015
0 commit comments