Untitled
public
Oct 11, 2024
Never
17
1 const axios = require('axios'); 2 3 module.exports.config = { 4 name: "prompt", 5 author: "Mesbah Saxx", 6 category: "ai" 7 }; 8 9 module.exports.onStart = async function({ message, event, args }) { 10 try { 11 let imgUrl; 12 13 // Check if the message is a reply and has an attachment 14 if (event.messageReply?.attachments?.[0]?.url) { 15 const shortenedUrl = await utils.shortenURL(event.messageReply.attachments[0].url); 16 const uploadResult = await axios.get(`https://www.samirxpikachu.run.place/telegraph?url=${shortenedUrl}&senderId=${event.senderID}`); 17 imgUrl = uploadResult.data.result.link; 18 } 19 20 const prompt = args.join(" "); 21 const api = "https://www.samirxpikachu.run.place"; 22 23 let response; 24 25 // If an image is provided 26 if (imgUrl) { 27 response = await axios.get(`${api}/api/imagetoprompt?url=${imgUrl}`); 28 } 29 // If just a prompt is provided 30 else if (prompt) { 31 response = await axios.get(`${api}/llama3?prompt=${encodeURIComponent(prompt)}&system_prompt=you are a prompt generator your prompting method 1girl/1boy, name, anime/serie name, eye color, background color, clothing, hair color, masterpiece, best quality, very Aesthetic, safe, don't use more than 50 tokens`); 32 } 33 34 if (response && response.data) { 35 await message.reply(imgUrl ? response.data.prompt : response.data.completion); 36 } 37 } catch (error) { 38 await message.reply(`An error occurred while processing your request.`); 39 } 40 };