diff --git a/docs/app.js b/docs/app.js index 36ca032..4e4c21a 100644 --- a/docs/app.js +++ b/docs/app.js @@ -1,6 +1,7 @@ async function openAIChat(apiKey, model, messages, temperature = 0.7, top_p = 1.0, extra = {}) { const useCustom = document.getElementById('useCustomApiBase'); - const base = (useCustom && useCustom.checked ? (document.getElementById('apiBase')?.value?.trim()) : '') || 'https://api.openai.com/v1'; + let base = (useCustom && useCustom.checked ? (document.getElementById('apiBase')?.value?.trim()) : '') || 'https://api.openai.com/v1'; + if (!/\/v1\/?$/.test(base)) base = base.replace(/\/$/, '') + '/v1'; const url = base.replace(/\/$/, '') + '/chat/completions'; const res = await fetch(url, { method: 'POST', @@ -210,6 +211,19 @@ document.addEventListener('DOMContentLoaded', () => { localStorage.setItem('autotemp_use_custom_api', useCustom.checked ? '1' : '0'); }); } + // Show effective base URL + function updateEffective(){ + const eff = document.getElementById('apiBaseEffective'); + if (!eff) return; + const useCustom = document.getElementById('useCustomApiBase'); + let base = (useCustom && useCustom.checked ? (document.getElementById('apiBase')?.value?.trim()) : '') || 'https://api.openai.com/v1'; + if (!/\/v1\/?$/.test(base)) base = base.replace(/\/$/, '') + '/v1'; + eff.textContent = base.replace(/\/$/, '') + '/chat/completions'; + } + const apiBaseInput = getEl('apiBase'); + if (apiBaseInput){ apiBaseInput.addEventListener('input', updateEffective); } + if (useCustom){ useCustom.addEventListener('change', updateEffective); } + updateEffective(); // Run state and controls let running = false; let cancelled = false; diff --git a/docs/index.html b/docs/index.html index 69dc0e6..4b61afa 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,6 +31,7 @@
diff --git a/docs/style.css b/docs/style.css index fdbfe2c..c367474 100644 --- a/docs/style.css +++ b/docs/style.css @@ -56,6 +56,7 @@ pre{ white-space:pre-wrap; background:#010a06; padding:14px; border-radius:10px; .footer{ display:flex; align-items:center; gap:10px; opacity:.85 } .blink{ width:8px; height:18px; background:var(--accent); animation: blink 1s infinite } .glow{ text-shadow:0 0 8px rgba(0,255,156,.35) } +.hint{ font-size:12px; color:#a5ffd6; margin-top:6px } @keyframes blink{ 50%{ opacity:.2 } } @media(max-width:720px){ .grid-2,.grid-3{ grid-template-columns:1fr } }