From 5a80565edf5cb46471711ccc53fcb6994964eb58 Mon Sep 17 00:00:00 2001 From: VA Date: Mon, 11 Nov 2024 16:54:42 +0700 Subject: [PATCH] add citations --- implementation.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/implementation.js b/implementation.js index 840f157..ad57296 100644 --- a/implementation.js +++ b/implementation.js @@ -33,6 +33,15 @@ function search_via_perplexity(params, userSettings) { }) .then((r) => r.json()) .then((response) => { - return response.choices.map((c) => c.message.content).join(' '); + const content = response.choices.map((c) => c.message.content).join(' '); + const citations = response.citations; + + return ( + content + + (citations + ? '\n\n Citations:\n' + + citations.map((c, index) => `[${index + 1}] ${c}`).join('\n') + : '') + ); }); }