@@ -3,7 +3,7 @@ use std::{sync::Arc, time::Duration};
3
3
use crate :: schema:: json_schema_for;
4
4
use crate :: ui:: ToolCallCardHeader ;
5
5
use anyhow:: { Context as _, Result , anyhow} ;
6
- use assistant_tool:: { ActionLog , Tool , ToolCard , ToolResult , ToolUseStatus } ;
6
+ use assistant_tool:: { ActionLog , Tool , ToolCard , ToolResult , ToolResultOutput , ToolUseStatus } ;
7
7
use futures:: { Future , FutureExt , TryFutureExt } ;
8
8
use gpui:: {
9
9
AnyWindowHandle , App , AppContext , Context , Entity , IntoElement , Task , WeakEntity , Window ,
@@ -73,9 +73,11 @@ impl Tool for WebSearchTool {
73
73
let search_task = search_task. clone ( ) ;
74
74
async move {
75
75
let response = search_task. await . map_err ( |err| anyhow ! ( err) ) ?;
76
- serde_json:: to_string ( & response)
77
- . context ( "Failed to serialize search results" )
78
- . map ( Into :: into)
76
+ Ok ( ToolResultOutput {
77
+ content : serde_json:: to_string ( & response)
78
+ . context ( "Failed to serialize search results" ) ?,
79
+ output : Some ( serde_json:: to_value ( response) ?) ,
80
+ } )
79
81
}
80
82
} ) ;
81
83
@@ -84,6 +86,18 @@ impl Tool for WebSearchTool {
84
86
card : Some ( cx. new ( |cx| WebSearchToolCard :: new ( search_task, cx) ) . into ( ) ) ,
85
87
}
86
88
}
89
+
90
+ fn deserialize_card (
91
+ self : Arc < Self > ,
92
+ output : serde_json:: Value ,
93
+ _project : Entity < Project > ,
94
+ _window : & mut Window ,
95
+ cx : & mut App ,
96
+ ) -> Option < assistant_tool:: AnyToolCard > {
97
+ let output = serde_json:: from_value :: < WebSearchResponse > ( output) . ok ( ) ?;
98
+ let card = cx. new ( |cx| WebSearchToolCard :: new ( Task :: ready ( Ok ( output) ) , cx) ) ;
99
+ Some ( card. into ( ) )
100
+ }
87
101
}
88
102
89
103
#[ derive( RegisterComponent ) ]
0 commit comments