File size: 2,062 Bytes
2821330 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | module.exports.config = {
name: "geminipro",
hasPermission: 0,
version: "1.0.0",
commandCategory: "Media",
description: "Generate captions using Claude Vision API.",
usePrefix: true,
credits: "Jonell Magallanes",
cooldowns: 10
};
module.exports.run = async function ({ api, event, args }) {
try {
if (!args[0]) {
return api.sendMessage(`❌ Please provide a prompt!`, event.threadID, event.messageID);
}
if (event.type !== "message_reply" || !event.messageReply.attachments || event.messageReply.attachments.length === 0) {
return api.sendMessage(
`❌ Please reply to a message containing an image attachment.`,
event.threadID,
event.messageID
);
}
api.sendMessage("🤔 Thinking...", event.threadID, async () => {
const message = args.join(" ");
const imageURL = event.messageReply.attachments[0].url;
const apiUrl = `https://hazzey-api.vercel.app/claude-vision?message=${encodeURIComponent(message)}&image_url=${encodeURIComponent(imageURL)}`;
const axios = require("axios");
try {
const response = await axios.get(apiUrl);
if (response.data && response.data.content && response.data.content.length > 0) {
const caption = response.data.content[0].text;
return api.sendMessage(`✅ Generated Caption: ${caption}`, event.threadID, event.messageID);
} else {
return api.sendMessage(`⚠️ No valid response received from the API.`, event.threadID, event.messageID);
}
} catch (error) {
console.error(error);
return api.sendMessage(
`❌ An error occurred while processing your request: ${error.message}`,
event.threadID,
event.messageID
);
}
});
} catch (error) {
console.error(error);
return api.sendMessage(
`❌ An error occurred while processing your request: ${error.message}`,
event.threadID,
event.messageID
);
}
}; |