thinking property
Get thinking/reasoning content (for providers that support it)
Implementation
@override
String? get thinking {
// Extract thinking content from candidates
final candidates = _rawResponse['candidates'] as List?;
if (candidates == null || candidates.isEmpty) return null;
final content = candidates.first['content'] as Map<String, dynamic>?;
if (content == null) return null;
final parts = content['parts'] as List?;
if (parts == null || parts.isEmpty) return null;
// According to Google API docs, thinking content has thought: true flag
final thinkingParts = parts
.where((part) {
final isThought = part['thought'] as bool? ?? false;
final text = part['text'] as String?;
return isThought && text != null && text.isNotEmpty;
})
.map((part) => part['text'] as String)
.toList();
return thinkingParts.isEmpty ? null : thinkingParts.join('\n');
}