@@ -14,10 +14,9 @@ import {
14
14
StepAction ,
15
15
AnswerAction ,
16
16
KnowledgeItem ,
17
- SearchResult ,
18
17
EvaluationType ,
19
18
BoostedSearchSnippet ,
20
- SearchSnippet , EvaluationResponse , Reference , SERPQuery , RepeatEvaluationType
19
+ SearchSnippet , EvaluationResponse , Reference , SERPQuery , RepeatEvaluationType , UnNormalizedSearchSnippet
21
20
} from "./types" ;
22
21
import { TrackerContext } from "./types" ;
23
22
import { search } from "./tools/jina-search" ;
@@ -254,7 +253,7 @@ async function updateReferences(thisStep: AnswerAction, allURLs: Record<string,
254
253
. replace ( / \s + / g, ' ' ) ,
255
254
title : allURLs [ normalizedUrl ] ?. title || '' ,
256
255
url : normalizedUrl ,
257
- dateTime : ref ?. dateTime || ''
256
+ dateTime : ref ?. dateTime || allURLs [ normalizedUrl ] ?. date || '' ,
258
257
} ;
259
258
} )
260
259
. filter ( Boolean ) as Reference [ ] ; // Add type assertion here
@@ -284,7 +283,7 @@ async function executeSearchQueries(
284
283
context . actionTracker . trackThink ( 'search_for' , SchemaGen . languageCode , { keywords : uniqQOnly . join ( ', ' ) } ) ;
285
284
let utilityScore = 0 ;
286
285
for ( const query of keywordsQueries ) {
287
- let results : SearchResult [ ] = [ ] ;
286
+ let results : UnNormalizedSearchSnippet [ ] = [ ] ;
288
287
const oldQuery = query . q ;
289
288
if ( onlyHostnames && onlyHostnames . length > 0 ) {
290
289
query . q = `${ query . q } site:${ onlyHostnames . join ( ' OR site:' ) } ` ;
@@ -321,15 +320,16 @@ async function executeSearchQueries(
321
320
322
321
const minResults : SearchSnippet [ ] = results
323
322
. map ( r => {
324
- const url = normalizeUrl ( 'url' in r ? r . url : r . link ) ;
323
+ const url = normalizeUrl ( 'url' in r ? r . url ! : r . link ! ) ;
325
324
if ( ! url ) return null ; // Skip invalid URLs
326
325
327
326
return {
328
327
title : r . title ,
329
328
url,
330
329
description : 'description' in r ? r . description : r . snippet ,
331
- weight : 1
332
- } ;
330
+ weight : 1 ,
331
+ date : r . date ,
332
+ } as SearchSnippet ;
333
333
} )
334
334
. filter ( Boolean ) as SearchSnippet [ ] ; // Filter out null entries and assert type
335
335
@@ -798,7 +798,7 @@ You decided to think out of the box or cut from a completely different angle.
798
798
. map ( url => normalizeUrl ( url ) )
799
799
. filter ( url => url && ! visitedURLs . includes ( url ) ) as string [ ] ;
800
800
801
- thisStep . URLTargets = [ ...new Set ( [ ...thisStep . URLTargets , ...weightedURLs . map ( r => r . url ) ] ) ] . slice ( 0 , MAX_URLS_PER_STEP ) ;
801
+ thisStep . URLTargets = [ ...new Set ( [ ...thisStep . URLTargets , ...weightedURLs . map ( r => r . url ! ) ] ) ] . slice ( 0 , MAX_URLS_PER_STEP ) ;
802
802
803
803
const uniqueURLs = thisStep . URLTargets ;
804
804
console . log ( uniqueURLs )
0 commit comments