Skip to content

Commit

Permalink
add citations
Browse files Browse the repository at this point in the history
  • Loading branch information
vietanhlehuu committed Nov 11, 2024
1 parent f395280 commit 5a80565
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
: '')
);
});
}

0 comments on commit 5a80565

Please sign in to comment.