mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
13 lines
No EOL
415 B
JavaScript
13 lines
No EOL
415 B
JavaScript
// const regex = / \[\d+\..*?\]\(.*?\)/g;
|
|
const regex = / \[.*?]\(.*?\)/g;
|
|
|
|
const getCitations = (res) => {
|
|
const textBlocks = res.details.adaptiveCards[0].body;
|
|
if (!textBlocks) return '';
|
|
let links = textBlocks[textBlocks.length - 1]?.text.match(regex);
|
|
if (links?.length === 0 || !links) return '';
|
|
links = links.map((link) => link.trim());
|
|
return links.join('\n');
|
|
};
|
|
|
|
module.exports = getCitations; |