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

Function process_prompt

examples/llava/llava-cli.cpp:207–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207static void process_prompt(struct llava_context * ctx_llava, struct llava_image_embed * image_embed, gpt_params * params, const std::string & prompt) {
208 int n_past = 0;
209
210 const int max_tgt_len = params->n_predict < 0 ? 256 : params->n_predict;
211
212 // llava chat format is "<system_prompt>\nUSER:<image_embeddings>\n<textual_prompt>\nASSISTANT:"
213 eval_string(ctx_llava->ctx_llama, "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\nUSER:", params->n_batch, &n_past, true);
214 llava_eval_image_embed(ctx_llava->ctx_llama, image_embed, params->n_batch, &n_past);
215 eval_string(ctx_llava->ctx_llama, (prompt + "\nASSISTANT:").c_str(), params->n_batch, &n_past, false);
216
217 // generate the response
218
219 printf("\n");
220
221 for (int i = 0; i < max_tgt_len; i++) {
222 const char * tmp = sample(ctx_llava->ctx_llama, *params, &n_past);
223 if (strcmp(tmp, "</s>") == 0) break;
224
225 printf("%s", tmp);
226 fflush(stdout);
227 }
228
229 printf("\n");
230}
231
232
233static struct llava_context * llava_init(gpt_params * params) {

Callers 1

mainFunction · 0.85

Calls 5

eval_stringFunction · 0.85
llava_eval_image_embedFunction · 0.85
printfFunction · 0.85
sampleFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected