MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / generate_response

Function generate_response

smallthinker/tools/run/run.cpp:1063–1078  ·  view source on GitHub ↗

Function to generate a response based on the prompt

Source from the content-addressed store, hash-verified

1061
1062// Function to generate a response based on the prompt
1063static 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
1081static int apply_chat_template_with_error_handling(const common_chat_templates * tmpls, LlamaData & llama_data, const bool append, int & output_length, bool use_jinja) {

Callers 1

process_user_messageFunction · 0.70

Calls 3

printfFunction · 0.85
printeFunction · 0.85
generateFunction · 0.70

Tested by

no test coverage detected