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 = {
33 content : string ;
44} ;
55
6- export type KnowledgeToolOutput = { url ?: string ; content : string } [ ] ;
6+ export type KnowledgeToolOutput = {
7+ url ?: string ;
8+ content : string ;
9+ } [ ] ;
710
811export type GoogleSearchOutput = {
912 duration : { search : number ; refine : number ; response : number } ;
1013 query : string ;
1114 results : { url : string ; content : string } [ ] ;
1215} ;
1316
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+
1431export type ToolCall = {
1532 name : string ;
1633 description : string ;
@@ -19,6 +36,7 @@ export type ToolCall = {
1936 metadata ?: {
2037 category ?: string ;
2138 icon ?: string ;
39+ toolBundle ?: string ;
2240 } ;
2341} ;
2442
Original file line number Diff line number Diff line change 44 ChatEvent ,
55 GoogleSearchOutput ,
66 KnowledgeToolOutput ,
7+ TavilySearchOutput ,
78 ToolCall ,
89} from "~/lib/model/chatEvents" ;
910import { Message , promptMessage , toolCallMessage } from "~/lib/model/messages" ;
@@ -196,7 +197,6 @@ export const createMessageStore = () => {
196197 const { toolCall } = event ;
197198
198199 const sources = pullSources ( toolCall ) ;
199-
200200 if ( sources ) parsedSources . push ( ...sources ) ;
201201
202202 // if the toolCall is an output event
@@ -223,14 +223,23 @@ function pullSources(toolCall: ToolCall) {
223223
224224 const [ err , output ] = handleTry ( ( ) => JSON . parse ( toolCall . output ) ) ;
225225
226- if ( err ) return [ ] ;
226+ if ( err ) {
227+ console . error ( err ) ;
228+ return [ ] ;
229+ }
227230
228231 if ( toolCall . name === "Knowledge" ) {
229232 const o = output as KnowledgeToolOutput ;
230233 return o ;
231234 }
232235
233236 if ( toolCall . name === "Search" ) {
237+ if ( toolCall . metadata ?. toolBundle === "Tavily Search" ) {
238+ const o = output as TavilySearchOutput ;
239+
240+ return o . results ;
241+ }
242+
234243 const o = output as GoogleSearchOutput ;
235244 return o . results ;
236245 }
You can’t perform that action at this time.
0 commit comments