We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9e570b2 + 0f52d31 commit fa8d39fCopy full SHA for fa8d39f
1 file changed
src/index.ts
@@ -232,10 +232,19 @@ class PerplexityServer {
232
messages: [{ role: "user", content: prompt }],
233
});
234
235
+ // response.data can have a string[] .citations
236
+ // these are referred to in the return text as numbered citations e.g. [1]
237
+ const sourcesText = response.data.citations
238
+ ? `\n## Sources\nPlease keep the numbered citations inline.\n
239
+ ${response.data.citations
240
+ .map((c: string, i: number) => `${i + 1}: ${c}`)
241
+ .join("\n")}`
242
+ : "";
243
+
244
return {
245
content: [{
246
type: "text",
- text: response.data.choices[0].message.content
247
+ text: response.data.choices[0].message.content + sourcesText,
248
}]
249
};
250
} catch (error) {
0 commit comments