Skip to content

Commit ddf2199

Browse files
authored
[AI Search] Deduplicate reference links with uniqBy function (#54863)
1 parent bb47f55 commit ddf2199

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/search/components/input/AskAIResults.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useRef, useState } from 'react'
2+
import { uniqBy } from 'lodash-es'
23
import { executeAISearch } from '../helpers/execute-search-actions'
34
import { useRouter } from 'next/router'
45
import { useTranslation } from '@/languages/components/useTranslation'
@@ -203,7 +204,8 @@ export function AskAIResults({
203204
if (parsedLine.chunkType === 'SOURCES') {
204205
if (!isCancelled) {
205206
sourcesBuffer = sourcesBuffer.concat(parsedLine.sources)
206-
setReferences(parsedLine.sources)
207+
sourcesBuffer = uniqBy(sourcesBuffer, 'url')
208+
setReferences(sourcesBuffer)
207209
}
208210
} else if (parsedLine.chunkType === 'MESSAGE_CHUNK') {
209211
if (!isCancelled) {

0 commit comments

Comments
 (0)