@@ -240,38 +240,32 @@ void llamaCPP::chatCompletion(
240240 role = user_prompt;
241241
242242 json content_piece_image_data;
243+ content_piece_image_data[" data" ] = " " ;
243244
244245 auto content_piece_type = content_piece[" type" ].asString ();
245246 if (content_piece_type == " text" ) {
246247 auto text = content_piece[" text" ].asString ();
247248 formatted_output += text;
248249 } else if (content_piece_type == " image_url" ) {
249250 auto image_url = content_piece[" image_url" ][" url" ].asString ();
250- std::string
251- base64_image_data; // Declare the variable 'base64_image_data'
251+ std::string base64_image_data;
252252 if (image_url.find (" http" ) != std::string::npos) {
253- // If image url is a remote link, extract and use convert to
254- // base64
255- nitro_utils::processRemoteImage (
256- image_url, [](const std::string &base64Image) {
257- auto base64_image_data = base64Image;
258- LOG_INFO << base64_image_data;
259- });
253+ LOG_INFO << " Remote image detected but not supported yet" ;
260254 } else if (image_url.find (" data:image" ) != std::string::npos) {
261- // If image url is already in base64, use it directly
262- auto base64_image_data = nitro_utils::extractBase64 (image_url);
255+ LOG_INFO << " Base64 image detected " ;
256+ base64_image_data = nitro_utils::extractBase64 (image_url);
263257 LOG_INFO << base64_image_data;
264258 } else {
265- // If image url is a local file, convert to base64
259+ LOG_INFO << " Local image detected " ;
266260 nitro_utils::processLocalImage (
267- image_url, [](const std::string &base64Image) {
268- auto base64_image_data = base64Image;
269- LOG_INFO << base64_image_data;
261+ image_url, [&](const std::string &base64Image) {
262+ base64_image_data = base64Image;
270263 });
264+ LOG_INFO << base64_image_data;
271265 }
266+ content_piece_image_data[" data" ] = base64_image_data;
272267
273268 formatted_output += " [img-" + std::to_string (no_images) + " ]" ;
274- content_piece_image_data[" data" ] = base64_image_data;
275269 content_piece_image_data[" id" ] = no_images;
276270 data[" image_data" ].push_back (content_piece_image_data);
277271 no_images++;
0 commit comments