Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is multimodal video possible with Gemini 1.5 flash? #43

Open
tsaneyoshi opened this issue Aug 12, 2024 · 0 comments
Open

Is multimodal video possible with Gemini 1.5 flash? #43

tsaneyoshi opened this issue Aug 12, 2024 · 0 comments

Comments

@tsaneyoshi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant