client icon indicating copy to clipboard operation
client copied to clipboard

Is multimodal video possible with Gemini 1.5 flash?

Open tsaneyoshi opened this issue 1 year ago • 0 comments

if so, Can you please provide me some sample code for the multimodal video?

This is my working code, Multimodal image.

`function AiFunction($text, $instructions, $image_urls = []) { global $GOOGLE_AI_CLIENT; logInfo("Input text: " . $text); logInfo("Image URLs: " . json_encode($image_urls));

$messages = [ new TextPart($instructions . "" . $text . "") ]; foreach ($image_urls as $image_url) { if (filter_var($image_url, FILTER_VALIDATE_URL)) { $image_data = file_get_contents($image_url); if ($image_data !== false && strlen($image_data) > 0) { $messages[] = new ImagePart( MimeType::IMAGE_JPEG, base64_encode($image_data) ); } else { logInfo("Failed to fetch image data from URL: " . $image_url); } } else { logInfo("Invalid image URL: " . $image_url); } } try { $response = $GOOGLE_AI_CLIENT->geminiProFlash1_5()->generateContent(...$messages); return $response->text(); } catch (Exception $e) { logError($e->getMessage()); throw new Exception("Error processing the request."); } }`

tsaneyoshi avatar Aug 12 '24 11:08 tsaneyoshi