gemini: Send thought signatures back to API (#32064)

This is a follow-up to:
- #31925 
- #31902

Release Notes:

- Support Gemini thought signatures
This commit is contained in:
Oleksiy Syvokon 2025-06-16 17:24:44 +03:00 committed by GitHub
parent b749d9302f
commit 41e9f3148c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -437,14 +437,29 @@ pub fn into_google(
content
.into_iter()
.flat_map(|content| match content {
language_model::MessageContent::Text(text)
| language_model::MessageContent::Thinking { text, .. } => {
language_model::MessageContent::Text(text) => {
if !text.is_empty() {
vec![Part::TextPart(google_ai::TextPart { text })]
} else {
vec![]
}
}
language_model::MessageContent::Thinking {
text: _,
signature: Some(signature),
} => {
if !signature.is_empty() {
vec![Part::ThoughtPart(google_ai::ThoughtPart {
thought: true,
thought_signature: signature,
})]
} else {
vec![]
}
}
language_model::MessageContent::Thinking { .. } => {
vec![]
}
language_model::MessageContent::RedactedThinking(_) => vec![],
language_model::MessageContent::Image(image) => {
vec![Part::InlineDataPart(google_ai::InlineDataPart {
@ -664,7 +679,12 @@ impl GoogleEventMapper {
)));
}
Part::FunctionResponsePart(_) => {}
Part::ThoughtPart(_) => {}
Part::ThoughtPart(part) => {
events.push(Ok(LanguageModelCompletionEvent::Thinking {
text: "(Encrypted thought)".to_string(), // TODO: Can we populate this from thought summaries?
signature: Some(part.thought_signature),
}));
}
});
}
}