const axios = require('axios'); async function anycoder(prompt, { use_search = false, language = 'html' } = {}) { try { const _lang = ['html', 'python', 'c', 'cpp', 'markdown', 'latex', 'json', 'css', 'javascript', 'jinja2', 'typescript', 'yaml', 'dockerfile', 'shell', 'r', 'sql', 'sql-msSQL', 'sql-mySQL', 'sql-mariaDB', 'sql-sqlite', 'sql-cassandra', 'sql-plSQL', 'sql-hive', 'sql-pgSQL', 'sql-gql', 'sql-gpSQL', 'sql-sparkSQL', 'sql-esper', 'transformers.js']; if (!prompt) throw new Error('Prompt is required'); if (typeof use_search !== 'boolean') throw new Error('Search must be boolean'); if (!_lang.includes(language)) throw new Error(`Available languages: ${_lang.join(', ')}`); const session_hash = Math.random().toString(36).substring(2); const d = await axios.post(`https://akhaliq-anycoder.hf.space/gradio_api/queue/join?`, { data: [ prompt, null, null, null, null, null, null, use_search, language, null ], event_data: null, fn_index: 7, trigger_id: 14, session_hash: session_hash }); const { data } = await axios.get(`https://akhaliq-anycoder.hf.space/gradio_api/queue/data?session_hash=${session_hash}`); let result; const lines = data.split('\n\n'); for (const line of lines) { if (line.startsWith('data:')) { const d = JSON.parse(line.substring(6)); if (d.msg === 'process_completed') result = d.output.data[0]; } } return result; } catch (error) { throw new Error(error.message); } } // Usage: const resp = await anycoder('portofolio website use tailwind css. simple and minimalist'); console.log(resp);