/** * Name Scrape: Deepai Coder * Deskripsi: Sesuai Namanya ai Yang khusus untuk koding * Sumber Kode: https://whatsapp.com/channel/0029VbDLqe7EquiSF4STU13o * Note: Kalau Mau Di Sher Harap Kasih Sumber Link ya **/ const axios = require('axios'); const FormData = require('form-data'); const { v4: uuidv4 } = require('uuid'); class DeepAiCoder { /** * @param {string} apiKey - Token sesi (format: "tryit-..."). Bisa diambil dari cookie browser atau LocalStorage. * @param {string} model - Model AI yang digunakan (default: "gemma-4"). */ constructor(apiKey, model = 'gemma-4') { this.apiKey = apiKey; this.model = model; this.baseUrl = 'https://api.deepai.org'; this.sessionUuid = uuidv4(); this.chatStyle = 'ai-code'; this.history = []; this.baseHeaders = { 'origin': 'https://deepai.org', 'referer': 'https://deepai.org/', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', 'accept': '*/*', 'accept-language': 'id,en-US;q=0.9,en;q=0.8', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site' }; } getAuthHeaders() { return { ...this.baseHeaders, 'api-key': this.apiKey }; } async saveSession(messages) { const form = new FormData(); form.append('uuid', this.sessionUuid); form.append('title', ''); form.append('chat_style', this.chatStyle); form.append('chat_model', this.model); form.append('messages', JSON.stringify(messages)); try { await axios.post(`${this.baseUrl}/save_chat_session`, form, { headers: { ...this.baseHeaders, ...form.getHeaders() } }); } catch (error) { console.warn('[Warning] Gagal menyimpan sesi:', error.message); } } async checkSensitivity(requestId) { try { const response = await axios.get(`${this.baseUrl}/check-sensitivity`, { params: { request_id: requestId }, headers: this.baseHeaders }); return response.data; // { sensitive: false, score: 0.2 } } catch (error) { return { sensitive: false, score: 0.2 }; } } /** * Mengirim pesan ke AI dan mendapatkan respons ai * @param {string} prompt - Pertanyaan atau instruksi kode. * @returns {Promise} - Respons Markdown dari AI. */ async sendMessage(prompt) { const userMessage = { role: 'user', content: prompt }; this.history.push(userMessage); await this.saveSession(this.history); const sensitivityRequestId = uuidv4(); const form = new FormData(); form.append('chat_style', this.chatStyle); form.append('chatHistory', JSON.stringify(this.history)); form.append('model', this.model); form.append('session_uuid', this.sessionUuid); form.append('sensitivity_request_id', sensitivityRequestId); form.append('tool_activity_support', '1'); form.append('hacker_is_stinky', 'very_stinky'); // Honeypot Anti-Bot form.append('enabled_tools', JSON.stringify(["image_generator", "image_editor"])); try { console.log('[Info] Mengirim prompt ke AI...'); const response = await axios.post(`${this.baseUrl}/hacking_is_a_serious_crime`, form, { headers: { ...this.getAuthHeaders(), ...form.getHeaders() }, responseType: 'text', timeout: 60000 // Timeout 60 detik karena respons bisa cukup lama }); const assistantMessage = { role: 'assistant', content: response.data }; this.history.push(assistantMessage); const sensitivityResult = await this.checkSensitivity(sensitivityRequestId); const finalHistory = this.history.map((msg, idx) => { if (idx === this.history.length - 2 && msg.role === 'user') { return { ...msg, sensitive_score: sensitivityResult.score || 0.2 }; } return msg; }); await this.saveSession(finalHistory); return response.data; } catch (error) { this.history.pop(); const errMsg = error.response ? error.response.data : error.message; throw new Error(`Gagal mendapatkan respons dari DeepAI: ${errMsg}`); } } resetSession() { this.sessionUuid = uuidv4(); this.history = []; console.log('[Info] Sesi chat telah direset.'); } } module.exports = DeepAiCoder; //contoh penggunaan 🗿 // GANTI DENGAN API KEY / TOKEN "tryit-..." KALIAN SUKI KALAU MAU // Token ini bisa kalian ambil dari Network Tab browser -> Request Headers -> api-key ya cuki const API_KEY = 'tryit-96688139466-7827b3d69016fe0cae7c45f8f358cba3'; async function main() { const aicode = new DeepAiCoder(API_KEY); try { console.log('=== Memulai Sesi Chat AI Code ==='); const prompt = "Buatkan aku kode website uploader file sederhana menggunakan Next.js App Router dan Tailwind CSS."; console.log(`\n[User]: ${prompt}\n`); const response = await aicode.sendMessage(prompt); console.log('=== Respons AI ==='); console.log(response); } catch (error) { console.error('Terjadi kesalahan:', error.message); } } main();