scrapbox-chatGPT
scrapboxでchatGPT backend APIを使用するUserScript
要GM_fetch
https://github.com/takker99/scrapbox-chatGPT
/takker-dist/scrapbox-chatGPT
code:mod.ts
export * from "https://raw.githubusercontent.com/takker99/scrapbox-chatGPT/0.1.0/mod.ts";
code:js
await (async () => {
const { sendMessage } = await import("https://scrapbox.io/api/code/takker-dist/scrapbox-chatGPT/mod.js");
const result = sendMessage("こんばんは。\nAPI経由でchatGPTに話しかけるテストです");
if (!result) return;
const res = await result;
if (!res.ok) {
alert(${res.value.name} ${res.value.message});
console.error(res.value);
return;
}
for await (const chat of res.value) {
if (chat.message.author.role !== "assistant") continue;
console.debug(chat.message.content.parts);
}
})();
code:2(js)
await (async () => {
const { sendMessage } = await import("https://scrapbox.io/api/code/takker-dist/scrapbox-chatGPT/mod.js");
const title = "2023/05/06";
const project = "villagepump";
const res2 = await fetch(/api/pages/${project}/${encodeURIComponent(title)}/text);
const result = sendMessage(以下に示すものは、${title}に井戸端というコミュニティに書き込まれたやりとりの一部です。これを要約した上で、あなたが興味深いと思う話題を一つ選び、関心を示した理由を述べてください。\n\n---\n\n${(await res2.text()).slice(0,2000)});
if (!result) return;
const res = await result;
if (!res.ok) {
console.error(res.value);
return;
}
for await (const chat of res.value) {
if (chat.message.author.role !== "assistant") continue;
console.debug(chat.message.content.parts);
}
})();
/villagepump/2023/05/06
#2023-05-07 06:57:43