notmebotz-tools
Version:
Sebuah Tools yang berfungsi untuk mendownload Video atau Foto dari media sosial, serta sebagai tools yang berguna untuk aplikasi kamu seperti untuk BOT
80 lines (77 loc) • 2.67 kB
JavaScript
const axios = require('axios');
const chatsandbox = {
chatbot: async (question, model) => {
const validModels = ["openai", "llama", "mistral", "mistral-large"];
if (!validModels.includes(model)) {
return {
author: 'Herza',
status: 400,
msg: `Invalid model selected. Please choose one of: ${validModels.join(', ')}`
};
}
const data = JSON.stringify({
"messages": [question],
"character": model
});
const config = {
method: 'POST',
url: 'https://chatsandbox.com/api/chat',
headers: {
'User-Agent': 'Mozilla/5.0 (Android 10; Mobile; rv:131.0) Gecko/131.0 Firefox/131.0',
'Content-Type': 'application/json',
'accept-language': 'id-ID',
'referer': `https://chatsandbox.com/chat/${model}`,
'origin': 'https://chatsandbox.com',
'alt-used': 'chatsandbox.com',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'priority': 'u=0',
'te': 'trailers',
'Cookie': '_ga_V22YK5WBFD=GS1.1.1734654982.3.0.1734654982.0.0.0; _ga=GA1.1.803874982.1734528677'
},
data: data
};
try {
const response = await axios.request(config);
return {
author: 'Herza',
status: 200,
msg: response.data
};
} catch (error) {
return {
author: 'Herza',
status: 500,
msg: error.message
};
}
},
text2img: async (prompt) => {
const formattedPrompt = encodeURIComponent(prompt).replace(/%20/g, '+');
const imageUrl = `https://imgen.duck.mom/prompt/${formattedPrompt}`;
try {
const response = await axios.get(imageUrl);
if (response.status === 200) {
return {
author: 'Herza',
status: 200,
msg: imageUrl
};
} else {
return {
author: 'Herza',
status: response.status,
msg: "Failed to fetch the image."
};
}
} catch (error) {
return {
author: 'Herza',
status: 500,
msg: error.message
};
}
}
};
module.exports = { chatsandbox };