MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / eval_message

Function eval_message

subprojects/llama.cpp/tools/mtmd/mtmd-cli.cpp:230–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230static int eval_message(mtmd_cli_context & ctx, common_chat_msg & msg) {
231 bool add_bos = ctx.chat_history.empty();
232 auto formatted_chat = chat_add_and_format(ctx, msg);
233 LOG_DBG("formatted_chat.prompt: %s\n", formatted_chat.c_str());
234
235 mtmd_input_text text;
236 text.text = formatted_chat.c_str();
237 text.add_special = add_bos;
238 text.parse_special = true;
239
240 if (g_is_interrupted) return 0;
241
242 mtmd::input_chunks chunks(mtmd_input_chunks_init());
243 auto bitmaps_c_ptr = ctx.bitmaps.c_ptr();
244 int32_t res = mtmd_tokenize(ctx.ctx_vision.get(),
245 chunks.ptr.get(), // output
246 &text, // text
247 bitmaps_c_ptr.data(),
248 bitmaps_c_ptr.size());
249 if (res != 0) {
250 LOG_ERR("Unable to tokenize prompt, res = %d\n", res);
251 return 1;
252 }
253
254 ctx.bitmaps.entries.clear();
255
256 llama_pos new_n_past;
257 if (mtmd_helper_eval_chunks(ctx.ctx_vision.get(),
258 ctx.lctx, // lctx
259 chunks.ptr.get(), // chunks
260 ctx.n_past, // n_past
261 0, // seq_id
262 ctx.n_batch, // n_batch
263 true, // logits_last
264 &new_n_past)) {
265 LOG_ERR("Unable to eval prompt\n");
266 return 1;
267 }
268
269 ctx.n_past = new_n_past;
270
271 LOG("\n");
272
273 return 0;
274}
275
276int main(int argc, char ** argv) {
277 ggml_time_init();

Callers 1

mainFunction · 0.85

Calls 10

chat_add_and_formatFunction · 0.85
mtmd_input_chunks_initFunction · 0.85
mtmd_tokenizeFunction · 0.85
mtmd_helper_eval_chunksFunction · 0.85
c_ptrMethod · 0.80
emptyMethod · 0.65
getMethod · 0.65
sizeMethod · 0.65
clearMethod · 0.65
dataMethod · 0.45

Tested by

no test coverage detected