2424#include  < string> 
2525#include  < vector> 
2626
27+ #include  " chat-template.hpp" 
2728#include  " common.h" 
2829#include  " json.hpp" 
2930#include  " linenoise.cpp/linenoise.h" 
3031#include  " llama-cpp.h" 
31- #include  " chat-template.hpp " 
32+ #include  " log.h " 
3233
3334#if  defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(_WIN32)
3435[[noreturn]] static  void  sigint_handler (int ) {
35-     printf (" \n\033  [0m "  );
36+     printf (" \n "  LOG_COL_DEFAULT );
3637    exit (0 );  //  not ideal, but it's the only way to guarantee exit in all cases
3738}
3839#endif 
@@ -890,7 +891,7 @@ static int check_context_size(const llama_context_ptr & ctx, const llama_batch &
890891    const  int  n_ctx      = llama_n_ctx (ctx.get ());
891892    const  int  n_ctx_used = llama_get_kv_cache_used_cells (ctx.get ());
892893    if  (n_ctx_used + batch.n_tokens  > n_ctx) {
893-         printf (" \033 [0m \n "  );
894+         printf (LOG_COL_DEFAULT  " \n "  );
894895        printe (" context size exceeded\n "  );
895896        return  1 ;
896897    }
@@ -953,7 +954,7 @@ static int generate(LlamaData & llama_data, const std::string & prompt, std::str
953954        batch = llama_batch_get_one (&new_token_id, 1 );
954955    }
955956
956-     printf (" \033 [0m "  );
957+     printf (LOG_COL_DEFAULT );
957958    return  0 ;
958959}
959960
@@ -962,7 +963,7 @@ static int read_user_input(std::string & user_input) {
962963#ifdef  WIN32
963964    printf (
964965        " \r %*s" 
965-         " \r\033  [0m %s"  ,
966+         " \r "  LOG_COL_DEFAULT  " %s"  ,
966967        get_terminal_width (), "  "  , prompt_prefix);
967968
968969    std::getline (std::cin, user_input);
@@ -999,7 +1000,7 @@ static int generate_response(LlamaData & llama_data, const std::string & prompt,
9991000                             const  bool  stdout_a_terminal) {
10001001    //  Set response color
10011002    if  (stdout_a_terminal) {
1002-         printf (" \033 [33m "  );
1003+         printf (LOG_COL_YELLOW );
10031004    }
10041005
10051006    if  (generate (llama_data, prompt, response)) {
@@ -1008,7 +1009,7 @@ static int generate_response(LlamaData & llama_data, const std::string & prompt,
10081009    }
10091010
10101011    //  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  : " "  );
10121013    return  0 ;
10131014}
10141015
0 commit comments