gemini: Add support for passing images as part of the prompt (#29203)

Release Notes:

- agent: Add support for adding images as context when using Google
Gemini
This commit is contained in:
Bennet Bo Fenner 2025-04-22 11:05:46 +02:00 committed by GitHub
parent eca6d5a04e
commit b0b620af56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -384,7 +384,14 @@ pub fn into_google(
} }
} }
language_model::MessageContent::RedactedThinking(_) => None, language_model::MessageContent::RedactedThinking(_) => None,
language_model::MessageContent::Image(_) => None, language_model::MessageContent::Image(image) => {
Some(Part::InlineDataPart(google_ai::InlineDataPart {
inline_data: google_ai::GenerativeContentBlob {
mime_type: "image/png".to_string(),
data: image.source.to_string(),
},
}))
}
language_model::MessageContent::ToolUse(tool_use) => { language_model::MessageContent::ToolUse(tool_use) => {
Some(Part::FunctionCallPart(google_ai::FunctionCallPart { Some(Part::FunctionCallPart(google_ai::FunctionCallPart {
function_call: google_ai::FunctionCall { function_call: google_ai::FunctionCall {