Skip to content

Commit

Permalink
Support plugins of QianWen
Browse files Browse the repository at this point in the history
  • Loading branch information
cesaryuan committed Jul 23, 2024
1 parent 8d82f92 commit 6673954
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/bots/QianWenBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,26 @@ export default class QianWenBot extends Bot {
if ((data?.contents?.length ?? 0) == 0) {
return;
}
let content = "";
for (let contentItem of data.contents) {
if (contentItem.contentType == "plugin") {
content += "> Plugin: " + contentItem.pluginName + "\n\n";
} else if (contentItem.contentType == "text") {
content += contentItem.content + "\n\n";
} else if (contentItem.contentType == "referenceLink") {
let links = JSON.parse(contentItem.content)?.["links"] ?? [];
content +=
`> 相关链接 · ${links.length}\n` +
links
.map((link) => `> - [${link.title}](${link.url})`)
.join("\n") +
"\n\n";
} else {
content += `> *UNKNOWN CONTENT TYPE:* ${contentItem.contentType}\n`;
}
}
onUpdateResponse(callbackParam, {
content: data.contents[0].content,
content: content.trim(),
done: false,
});
if (data.stopReason === undefined || data.stopReason === "stop") {
Expand Down

0 comments on commit 6673954

Please sign in to comment.