Skip to content

Is multimodal video possible with Gemini 1.5 flash? #43

@tsaneyoshi

Description

@tsaneyoshi

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.");
}
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions