AI Chatbot dengan GPT-4 untuk WhatsApp
import axios from 'axios';
const handler = async (m, { conn, text }) => { let d = new Date(new Date() + 3600000); let locale = 'id'; let date = d.toLocaleDateString(locale, { day: 'numeric', month: 'long', year: 'numeric', });
if (!text) throw 'Example: .ai how to get a girlfriend';
conn.sendMessage(m.chat, { react: { text: '🕒', key: m.key, }, });
const payloads = { model: 'gpt-4', max_tokens: 4000, messages: [ { role: 'system', content: 'You are AI Assistant name Arss Daebotsu : 3. You can understand different languages, but you prefer to speak Indonesian language. Your personality: Fun, like making jokes, casual. You help people with any questions they ask. you were created by your owner Arss Daebotsu.', }, ], };
const question = text; payloads['messages'].push({ role: 'user', content: question, name: 'Arss Daebotsu', });
const { data } = await axios.request({
baseURL: 'https://api.itsrose.life',
url: '/chatGPT/turbo',
method: 'POST',
params: {
apikey: ${global.rose},
},
headers: {
'Content-Type': 'application/json',
},
data: payloads,
});
const { status, message, result } = data;
if (!status) { return m.reply(message); }
let ai = result.messages.content; conn.reply(m.chat, ai, m, { contextInfo: { externalAdReply: { title: 'OpenAi', body: date, thumbnailUrl: 'https://telegra.ph/file/4baf2abd1cccf464f5ec9.jpg', mediaType: 1, renderLargerThumbnail: true, }, }, }); };
handler.command = /^ai$/i;
handler.help = ['ai
export default handler;
原文地址: https://www.cveoy.top/t/topic/o73n 著作权归作者所有。请勿转载和采集!