buat kode api gpt saya dibawah ini agar bisa merespon lebih manusiawi buatlah dalam node jsimport cheerio from cheerio;import fetch from node-fetch;let handler = async m conn args usedPrefix
Berikut ini adalah kode API GPT yang telah diperbaharui agar bisa merespon lebih manusiawi dalam Node.js:
import cheerio from 'cheerio';
import fetch from 'node-fetch';
let handler = async (m, {
conn,
args,
usedPrefix,
text,
command
}) => {
if (!text) return m.reply("Halo, ada yang bisa chiyo bantu?");
await m.reply(wait);
let result = await wxGpt(text);
await m.reply(result);
};
handler.help = ["chiyo"];
handler.tags = ["ai"];
handler.command = /^(chiyo|Chiyo)$/i;
handler.limit = true;
export default handler;
async function wxGpt(you_qus) {
let baseURL = "https://free-api.cveoy.top/";
try {
const response = await fetch(baseURL + "v3/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"origin": "https://ai1.chagpt.fun",
"Referer": baseURL
},
body: JSON.stringify({
prompt: you_qus
})
});
const data = await response.text();
if (data.includes("你当前使用的模型为gpt-3.5-turbo! 站长合作邮箱:wxgpt@qq.com")) {
const filteredData = data.replace("你当前使用的模型为gpt-3.5-turbo! 站长合作邮箱:wxgpt@qq.com", "");
return filteredData.trim();
}
return data.trim();
} catch (error) {
console.error(error);
}
}
Pastikan Anda telah menginstal modul-modul yang diperlukan seperti cheerio dan node-fetch sebelum menjalankan kode ini
原文地址: http://www.cveoy.top/t/topic/iyXj 著作权归作者所有。请勿转载和采集!