function generate() { const provider = document.getElementById('provider').value.trim(); const model = document.getElementById('model').value.trim(); const apikey = document.getElementById('apikey').value.trim(); const gatewayToken = document.getElementById('gateway_token').value.trim() || crypto.randomUUID(); const telegramBot = document.getElementById('telegram_bot_token').value.trim(); const telegramUsers = document.getElementById('telegram_users').value.trim(); const customBase = document.getElementById('custom_base').value.trim(); const hfToken = document.getElementById('hf_token').value.trim(); const lines = []; lines.push('# ── Hermes-HF Environment ──'); lines.push(`# Generated: ${new Date().toISOString()}`); lines.push(''); if (hfToken) { lines.push(`HF_TOKEN=${hfToken}`); } else { lines.push('# HF_TOKEN= (needed for Dataset backup)'); } lines.push(`GATEWAY_TOKEN=${gatewayToken}`); lines.push(''); const providerMap = { openrouter: { prefix: 'openrouter/', keyVar: 'OPENROUTER_API_KEY' }, huggingface: { prefix: 'huggingface/', keyVar: 'HF_TOKEN' }, anthropic: { prefix: 'anthropic/', keyVar: 'ANTHROPIC_API_KEY' }, openai: { prefix: 'openai/', keyVar: 'OPENAI_API_KEY' }, google: { prefix: 'google/', keyVar: 'GOOGLE_API_KEY' }, deepseek: { prefix: 'deepseek/', keyVar: 'DEEPSEEK_API_KEY' }, xai: { prefix: 'xai/', keyVar: 'XAI_API_KEY' }, custom: { prefix: '', keyVar: 'OPENAI_API_KEY' }, }; const pm = providerMap[provider]; if (pm && model) { if (provider === 'custom' && customBase) { lines.push(`HERMES_MODEL=${model}`); lines.push(`CUSTOM_BASE_URL=${customBase}`); if (apikey) lines.push(`CUSTOM_API_KEY=${apikey}`); } else { lines.push(`HERMES_MODEL=${pm.prefix}${model}`); if (apikey) lines.push(`${pm.keyVar}=${apikey}`); } } else if (apikey) { lines.push(`LLM_API_KEY=${apikey}`); } if (telegramBot) { lines.push(''); lines.push(`TELEGRAM_BOT_TOKEN=${telegramBot}`); if (telegramUsers) { lines.push(`TELEGRAM_ALLOWED_USERS=${telegramUsers}`); } } lines.push(''); lines.push('BACKUP_DATASET_NAME=hermes-hf-backup'); lines.push(''); const el = document.getElementById('envOutput'); el.textContent = lines.join('\n'); document.getElementById('output').classList.add('show'); } function copyEnv() { const text = document.getElementById('envOutput').textContent; navigator.clipboard.writeText(text).then(() => { const btn = document.querySelector('.copy-btn'); const orig = btn.textContent; btn.textContent = 'Copied!'; setTimeout(() => btn.textContent = orig, 2000); }); }