| const Groq = require('groq-sdk'); | |
| const handler = async (req, res) => { | |
| try { | |
| const { text } = req.query; | |
| if (!text) { | |
| return res.status(400).json({ | |
| author: 'Herza', | |
| success: false, | |
| msg: 'Missing required parameter: text' | |
| }); | |
| } | |
| const client = new Groq({ | |
| apiKey: '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', | |
| }); | |
| const chatCompletion = await client.chat.completions.create({ | |
| messages: [{ role: 'user', content: text }], | |
| model: 'deepseek-r1-distill-llama-70b', | |
| }); | |
| const result = chatCompletion.choices[0]?.message?.content || 'Maaf, saya tidak bisa menjawab itu.'; | |
| res.json({ | |
| author: 'Herza', | |
| success: true, | |
| msg: result | |
| }); | |
| } catch (error) { | |
| console.error('Error fetching from Deepseek:', error); | |
| res.status(500).json({ | |
| author: 'Herza', | |
| success: false, | |
| msg: 'Terjadi kesalahan saat menghubungi AI.' | |
| }); | |
| } | |
| }; | |
| module.exports = { | |
| name: 'DeepSeek AI', | |
| description: 'Generate responses using DeepSeek AI via Groq', | |
| type: 'GET', | |
| routes: ['api/AI/deepseek'], | |
| tags: ['ai', 'deepseek', 'groq'], | |
| parameters: ['text', 'key'], | |
| enabled: true, | |
| main: ['AI'], | |
| handler | |
| }; |