File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,31 @@ export type ToolInput = {
3
3
content : string ;
4
4
} ;
5
5
6
- export type KnowledgeToolOutput = { url ?: string ; content : string } [ ] ;
6
+ export type KnowledgeToolOutput = {
7
+ url ?: string ;
8
+ content : string ;
9
+ } [ ] ;
7
10
8
11
export type GoogleSearchOutput = {
9
12
duration : { search : number ; refine : number ; response : number } ;
10
13
query : string ;
11
14
results : { url : string ; content : string } [ ] ;
12
15
} ;
13
16
17
+ export type TavilySearchOutput = {
18
+ query : string ;
19
+ follow_up_questions : string ;
20
+ answer : string ;
21
+ images : string [ ] ;
22
+ results : {
23
+ title : string ;
24
+ url : string ;
25
+ content : string ;
26
+ score : number ;
27
+ raw_content : string ;
28
+ } [ ] ;
29
+ } ;
30
+
14
31
export type ToolCall = {
15
32
name : string ;
16
33
description : string ;
@@ -19,6 +36,7 @@ export type ToolCall = {
19
36
metadata ?: {
20
37
category ?: string ;
21
38
icon ?: string ;
39
+ toolBundle ?: string ;
22
40
} ;
23
41
} ;
24
42
Original file line number Diff line number Diff line change 4
4
ChatEvent ,
5
5
GoogleSearchOutput ,
6
6
KnowledgeToolOutput ,
7
+ TavilySearchOutput ,
7
8
ToolCall ,
8
9
} from "~/lib/model/chatEvents" ;
9
10
import { Message , promptMessage , toolCallMessage } from "~/lib/model/messages" ;
@@ -196,7 +197,6 @@ export const createMessageStore = () => {
196
197
const { toolCall } = event ;
197
198
198
199
const sources = pullSources ( toolCall ) ;
199
-
200
200
if ( sources ) parsedSources . push ( ...sources ) ;
201
201
202
202
// if the toolCall is an output event
@@ -223,14 +223,23 @@ function pullSources(toolCall: ToolCall) {
223
223
224
224
const [ err , output ] = handleTry ( ( ) => JSON . parse ( toolCall . output ) ) ;
225
225
226
- if ( err ) return [ ] ;
226
+ if ( err ) {
227
+ console . error ( err ) ;
228
+ return [ ] ;
229
+ }
227
230
228
231
if ( toolCall . name === "Knowledge" ) {
229
232
const o = output as KnowledgeToolOutput ;
230
233
return o ;
231
234
}
232
235
233
236
if ( toolCall . name === "Search" ) {
237
+ if ( toolCall . metadata ?. toolBundle === "Tavily Search" ) {
238
+ const o = output as TavilySearchOutput ;
239
+
240
+ return o . results ;
241
+ }
242
+
234
243
const o = output as GoogleSearchOutput ;
235
244
return o . results ;
236
245
}
You can’t perform that action at this time.
0 commit comments