fix: improve citation deduplication logic for non-knowledge citations (#5981)

This commit is contained in:
SuYao 2025-05-14 13:51:25 +08:00 committed by GitHub
parent e9afab7725
commit 0d38fabfac

View File

@ -236,10 +236,11 @@ const formatCitationsFromBlock = (block: CitationMessageBlock | undefined): Cita
})
)
}
// 4. Deduplicate by URL and Renumber Sequentially
// 4. Deduplicate non-knowledge citations by URL and Renumber Sequentially
const urlSet = new Set<string>()
return formattedCitations
.filter((citation) => {
if (citation.type === 'knowledge') return true
if (!citation.url || urlSet.has(citation.url)) return false
urlSet.add(citation.url)
return true