MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / insert

Method insert

src/common/AutoModel/modeling_qwen3vl.cpp:59–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59bool Qwen3VL::insert(chat_meta_info_t& meta_info, lm_uniform_input_t& input, std::function<bool()> is_cancelled) {
60 // preprocess
61 constexpr int image_soft_token_id = 151655;
62 this->profiler_list[TKOEN_ENCODE_TIME].start();
63 std::string templated_text;
64 if (input.messages.empty() && input.prompt.empty()) {
65 header_print("WARNING", "No messages or prompt provided");
66 return false;
67 }
68
69 constexpr bool DEBUG_IMAGE_PREPROCESS = false;
70 qwen3vl_image_payload_t image_payload;
71 image_payload.num_images = 0;
72 if (input.images.size() > 0) {
73
74
75 // header_print("info", "Processing images...");
76
77 // time_utils::time_point preprocess_start = time_utils::now();
78 for(const auto& img_str : input.images){
79 qwen3vl_image_t image = this->load_image(img_str);
80
81 preprocess_image(image, image_payload._data__processed);
82 // Push the image AFTER preprocessing so grid_h and grid_w are set
83 image_payload.images.push_back(image);
84 image_payload.num_images++;
85 }
86 }
87 if (!input.messages.empty()) { // already a formated messages, usually from REST API
88 json qwenvl_message = json::array();
89 for (const auto& item : input.messages) {
90 if (!item.contains("images")) {
91 qwenvl_message.push_back(item);
92 continue;
93 }
94
95 json newContent = json::array();
96 for (const auto& img : item["images"]) {
97 newContent.push_back({
98 {"type", "image"},
99 {"image", img}
100 });
101 }
102 newContent.push_back({
103 {"type", "text"},
104 {"text", item["content"]}
105 });
106
107 json newItem = {
108 {"role", item["role"]},
109 {"content", newContent}
110 };
111
112 qwenvl_message.push_back(newItem);
113 }
114 templated_text = this->apply_chat_template(qwenvl_message, input.tools);
115 int total_images = 0;
116 for (auto& message : qwenvl_message) {

Callers 1

generate_with_promptMethod · 0.95

Calls 15

load_imageMethod · 0.95
apply_chat_templateMethod · 0.95
load_image_base64Method · 0.95
push_backMethod · 0.80
encodeMethod · 0.80
eraseMethod · 0.80
clearMethod · 0.80
_shared_insertMethod · 0.80
startMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected