Spaces:
Paused
Paused
πππππππ πππππππ β‘
commited on
Update ai-gemini.js
Browse files- plugins/ai-gemini.js +13 -9
plugins/ai-gemini.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
| 1 |
const config = require('../config');
|
| 2 |
const { cmd, commands } = require('../command');
|
| 3 |
-
const { fetchJson } = require('../lib/functions');
|
| 4 |
|
| 5 |
cmd({
|
| 6 |
pattern: "bot",
|
|
@@ -35,15 +36,18 @@ cmd({
|
|
| 35 |
}) => {
|
| 36 |
try {
|
| 37 |
if (!q) return reply("Please ask a question or provide input for the AI.");
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
} catch (error) {
|
| 46 |
-
console.error(error);
|
| 47 |
reply(`An error occurred: ${error.message}`);
|
| 48 |
}
|
| 49 |
});
|
|
|
|
| 1 |
+
|
| 2 |
+
const axios = require('axios');
|
| 3 |
const config = require('../config');
|
| 4 |
const { cmd, commands } = require('../command');
|
|
|
|
| 5 |
|
| 6 |
cmd({
|
| 7 |
pattern: "bot",
|
|
|
|
| 36 |
}) => {
|
| 37 |
try {
|
| 38 |
if (!q) return reply("Please ask a question or provide input for the AI.");
|
| 39 |
+
const userInput = q.trim();
|
| 40 |
+
if (userInput === "") return reply("Please provide a valid input.");
|
| 41 |
+
const apiUrl = `https://api.giftedtech.web.id/api/ai/geminiaipro?apikey=gifted&q=${encodeURIComponent(userInput)}`;
|
| 42 |
+
const response = await axios.get(apiUrl);
|
| 43 |
+
console.log('API Response:', response.data);
|
| 44 |
+
if (!response.data || !response.data.message) {
|
| 45 |
+
return reply("No response from the AI or invalid API response.");
|
| 46 |
+
}
|
| 47 |
+
const aiResponse = response.data.message.trim();
|
| 48 |
+
return reply(`\`π€ GEMINI AI RESPONSE:\` \n\n${aiResponse}`);
|
| 49 |
} catch (error) {
|
| 50 |
+
console.error('Error:', error);
|
| 51 |
reply(`An error occurred: ${error.message}`);
|
| 52 |
}
|
| 53 |
});
|