We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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."); } }`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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.");
}
}`
The text was updated successfully, but these errors were encountered: