diff --git a/src/lib/components/chat/Messages/Citations.svelte b/src/lib/components/chat/Messages/Citations.svelte index 041a419bf..b09f51482 100644 --- a/src/lib/components/chat/Messages/Citations.svelte +++ b/src/lib/components/chat/Messages/Citations.svelte @@ -100,7 +100,7 @@
{#each citations as citation, idx} diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 0a5b72e36..4d1e92f04 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -55,15 +55,12 @@ export const replaceTokens = (content, sourceIds, char, user) => { // Remove sourceIds from the content and replace them with ... if (Array.isArray(sourceIds)) { - sourceIds.forEach((sourceId) => { - // Escape special characters in the sourceId - const escapedSourceId = escapeRegExp(sourceId); - + sourceIds.forEach((sourceId, idx) => { // Create a token based on the exact `[sourceId]` string - const sourceToken = `\\[${escapedSourceId}\\]`; // Escape special characters for RegExp + const sourceToken = `\\[${idx}\\]`; // Escape special characters for RegExp const sourceRegex = new RegExp(sourceToken, 'g'); // Match all occurrences of [sourceId] - content = content.replace(sourceRegex, ``); + content = content.replace(sourceRegex, ``); }); }