MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / process_mtmd_prompt

Function process_mtmd_prompt

tools/server/server-common.cpp:716–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714}
715
716server_tokens process_mtmd_prompt(mtmd_context * mctx, std::string prompt, std::vector<raw_buffer> files) {
717 mtmd::bitmaps bitmaps;
718 for (auto & file : files) {
719 mtmd::bitmap bmp(mtmd_helper_bitmap_init_from_buf(mctx, file.data(), file.size()));
720 if (!bmp.ptr) {
721 throw std::runtime_error("Failed to load image or audio file");
722 }
723 // calculate bitmap hash (for KV caching)
724 std::string hash = fnv_hash(bmp.data(), bmp.n_bytes());
725 bmp.set_id(hash.c_str());
726 bitmaps.entries.push_back(std::move(bmp));
727 }
728 // process prompt
729 std::vector<server_tokens> inputs;
730 // multimodal
731 mtmd_input_text inp_txt = {
732 prompt.c_str(),
733 /* add_special */ true,
734 /* parse_special */ true,
735 };
736 mtmd::input_chunks chunks(mtmd_input_chunks_init());
737 auto bitmaps_c_ptr = bitmaps.c_ptr();
738 int32_t tokenized = mtmd_tokenize(mctx,
739 chunks.ptr.get(),
740 &inp_txt,
741 bitmaps_c_ptr.data(),
742 bitmaps_c_ptr.size());
743 if (tokenized != 0) {
744 throw std::runtime_error("Failed to tokenize prompt");
745 }
746 auto result = server_tokens(chunks, true);
747 return result;
748}
749
750/**
751 * break the input "prompt" object into multiple prompt if needed, then tokenize them

Callers 3

tokenize_cli_inputMethod · 0.85
tokenize_input_subpromptFunction · 0.85

Calls 12

mtmd_input_chunks_initFunction · 0.85
mtmd_tokenizeFunction · 0.85
server_tokensClass · 0.85
set_idMethod · 0.80
c_ptrMethod · 0.80
fnv_hashFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45
n_bytesMethod · 0.45
push_backMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected