Berikut ini adalah kode API GPT yang telah diperbaharui agar bisa merespon lebih manusiawi dalam Node.js:\n\njavascript\nimport cheerio from 'cheerio';\nimport fetch from 'node-fetch';\n\nlet handler = async (m, {\n conn,\n args,\n usedPrefix,\n text,\n command\n}) => {\n if (!text) return m.reply("Halo, ada yang bisa chiyo bantu?");\n await m.reply(wait);\n let result = await wxGpt(text);\n await m.reply(result);\n};\n\nhandler.help = ["chiyo"];\nhandler.tags = ["ai"];\nhandler.command = /^(chiyo|Chiyo)$/i;\nhandler.limit = true;\nexport default handler;\n\nasync function wxGpt(you_qus) {\n let baseURL = "https://free-api.cveoy.top/";\n try {\n const response = await fetch(baseURL + "v3/completions", {\n method: "POST",\n headers: {\n "Content-Type": "application/json",\n "origin": "https://ai1.chagpt.fun",\n "Referer": baseURL\n },\n body: JSON.stringify({\n prompt: you_qus\n })\n });\n\n const data = await response.text();\n\n if (data.includes("你当前使用的模型为gpt-3.5-turbo! 站长合作邮箱:wxgpt@qq.com")) {\n const filteredData = data.replace("你当前使用的模型为gpt-3.5-turbo! 站长合作邮箱:wxgpt@qq.com", "");\n return filteredData.trim();\n }\n\n return data.trim();\n } catch (error) {\n console.error(error);\n }\n}\n\n\nPastikan Anda telah menginstal modul-modul yang diperlukan seperti cheerio dan node-fetch sebelum menjalankan kode ini.

Kode API GPT yang Lebih Manusiawi dalam Node.js

原文地址: https://www.cveoy.top/t/topic/qf67 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录