♻️ Refactor the thought insight to support new API

This commit is contained in:
2025-11-15 16:59:22 +08:00
parent ea8e7ead2d
commit 645a6dca93
8 changed files with 1397 additions and 124 deletions

View File

@@ -30,9 +30,9 @@ class _FunctionCallsSectionState extends State<FunctionCallsSection> {
if (widget.isStreaming) {
return widget.streamingFunctionCalls.isNotEmpty;
} else {
return widget.thought!.chunks.isNotEmpty &&
widget.thought!.chunks.any(
(chunk) => chunk.type == ThinkingChunkType.functionCall,
return widget.thought!.parts.isNotEmpty &&
widget.thought!.parts.any(
(part) => part.type == ThinkingMessagePartType.functionCall,
);
}
}
@@ -115,13 +115,14 @@ class _FunctionCallsSectionState extends State<FunctionCallsSection> {
),
),
] else ...[
...widget.thought!.chunks
...widget.thought!.parts
.where(
(chunk) =>
chunk.type == ThinkingChunkType.functionCall,
(part) =>
part.type ==
ThinkingMessagePartType.functionCall,
)
.map(
(chunk) => Container(
(part) => Container(
width: double.infinity,
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.only(bottom: 4),
@@ -138,7 +139,7 @@ class _FunctionCallsSectionState extends State<FunctionCallsSection> {
child: SelectableText(
JsonEncoder.withIndent(
' ',
).convert(chunk.data),
).convert(part.functionCall?.toJson() ?? {}),
style: GoogleFonts.robotoMono(
fontSize: 11,
color: