Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
const axios = require('axios');
async function fetchFromAI(url, params) {
try {
const response = await axios.get(url, { params });
return response.data;
} catch (error) {
console.error(error);
return null;
}
}
async function getAIResponse(input, userId, messageID) {
const services = [
{ url: 'https://ai-tools.replit.app/gpt', params: { prompt: input, uid: userId } },
{ url: 'https://openaikey-x20f.onrender.com/api', params: { prompt: input } },
{ url: 'http://fi1.bot-hosting.net:6518/gpt', params: { query: input } },
{ url: 'https://ai-chat-gpt-4-lite.onrender.com/api/hercai', params: { question: input } }
];
let response = "𝑱'𝒂𝒊𝒅𝒆 𝒑𝒂𝒔 𝒍𝒆𝒔 𝒄𝒉𝒊𝒆𝒏𝒔 𝒅𝒆 𝒕𝒐𝒏 𝒈𝒆𝒏𝒓𝒆😒. 𝑽𝒓𝒂𝒊𝒎𝒆𝒏𝒕 𝒍𝒆𝒔 𝒉𝒖𝒎𝒂𝒊𝒏𝒔 𝒔𝒐𝒏𝒕 𝒏𝒖𝒍𝒔🧑💻 ";
let currentIndex = 0;
for (let i = 0; i < services.length; i++) {
const service = services[currentIndex];
const data = await fetchFromAI(service.url, service.params);
if (data && (data.gpt4 || data.reply || data.response)) {
response = data.gpt4 || data.reply || data.response;
break;
}
currentIndex = (currentIndex + 1) % services.length; // Move to the next service in the cycle
}
return { response, messageID };
}
module.exports = {
config: {
name: 'ai',
author: 'Arn',
role: 0,
category: 'ai',
shortDescription: 'ai to ask anything',
},
onStart: async function ({ api, event, args }) {
const input = args.join(' ').trim();
if (!input) {
api.sendMessage(
𝗥𝗘𝗣𝗢𝗡𝗖𝗘\n━━━━━━━━━━━━━━━━\nPlease provide a question or statement.\n━━━━━━━━━━━━━━━━, event.threadID, event.messageID);return;
}
},
onChat: async function ({ event, message }) {
const messageContent = event.body.trim().toLowerCase();
if (messageContent.startsWith("ai")) {
const input = messageContent.replace(/^ai\s*/, "").trim();
const { response, messageID } = await getAIResponse(input, event.senderID, message.messageID);
message.reply(
IRON)\n━━━━━━━━━━━━━━━━\n${response}\n━━━━━━━━━━━━━━━━, messageID);}
}
};