@@ -116,7 +116,6 @@ const updateWorkspaceAttributesSchema = schema.object({
116116
117117// Declare a variable outside the route handler to cache the model.
118118let semanticExtractor : any = null ;
119- let answerer : any = null ;
120119
121120export function registerRoutes ( {
122121 client,
@@ -369,18 +368,6 @@ export function registerRoutes({
369368 const { query, links } = req . body ;
370369
371370 console . log ( '-------------Enter semanticSearch (Node.js)-------------' ) ;
372- if ( ! answerer ) {
373- const startTime = performance . now ( ) ;
374- answerer = await pipeline (
375- 'question-answering' ,
376- 'Xenova/tiny-random-RoFormerForQuestionAnswering'
377- ) ;
378- const endTime = performance . now ( ) ;
379- const loadingTimeMs = endTime - startTime ;
380-
381- console . log ( 'Answer loaded and ready for inference.' ) ;
382- console . log ( `Answer loading took: ${ loadingTimeMs . toFixed ( 2 ) } ms` ) ;
383- }
384371
385372 // Load the model only once and reuse it later
386373 if ( ! semanticExtractor ) {
@@ -448,27 +435,6 @@ export function registerRoutes({
448435 . map ( ( { embedding, ...rest } ) => rest ) ;
449436 console . log ( 'semanticSearchResult: ' , semanticSearchResult ) ;
450437
451- const qaResults = [ ] ;
452-
453- for ( const link of links ) {
454- const answer = await answerer ( query , link . description ) ;
455- if ( answer && answer . answer ) {
456- qaResults . push ( {
457- linkId : link . id ,
458- title : link . title ,
459- description : link . description ,
460- answer : answer . answer ,
461- score : answer . score ,
462- } ) ;
463- }
464- }
465-
466- qaResults . sort ( ( a , b ) => b . score - a . score ) ;
467-
468- const finalQaResults = qaResults . slice ( 0 , 5 ) . filter ( ( item ) => item . score > 0.1 ) ;
469-
470- console . log ( 'Question Answering: ' , finalQaResults ) ;
471-
472438 return res . ok ( { body : semanticSearchResult } ) ;
473439 } catch ( error ) {
474440 console . error ( 'Error during semantic search:' , error ) ;
0 commit comments