Function to generate a response based on the prompt
| 1061 | |
| 1062 | // Function to generate a response based on the prompt |
| 1063 | static int generate_response(LlamaData & llama_data, const std::string & prompt, std::string & response, |
| 1064 | const bool stdout_a_terminal) { |
| 1065 | // Set response color |
| 1066 | if (stdout_a_terminal) { |
| 1067 | printf(LOG_COL_YELLOW); |
| 1068 | } |
| 1069 | |
| 1070 | if (generate(llama_data, prompt, response)) { |
| 1071 | printe("failed to generate response\n"); |
| 1072 | return 1; |
| 1073 | } |
| 1074 | |
| 1075 | // End response with color reset and newline |
| 1076 | printf("\n%s", stdout_a_terminal ? LOG_COL_DEFAULT : ""); |
| 1077 | return 0; |
| 1078 | } |
| 1079 | |
| 1080 | // Helper function to apply the chat template and handle errors |
| 1081 | static int apply_chat_template_with_error_handling(const common_chat_templates * tmpls, LlamaData & llama_data, const bool append, int & output_length, bool use_jinja) { |
no test coverage detected