Spaces:
Running
Running
Delete assets/ModelsModal-BHYO3jHv.js
Browse files1import{a as e,c as t,i as n,l as r,r as i}from"./index-nEc30Kgp.js";var a=t(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),o=r(),s=n();function c({isOpen:t,onClose:n}){let[r,c]=(0,o.useState)(null),[l,u]=(0,o.useState)(!1),d=(0,o.useCallback)(async()=>{u(!0);try{let e=await fetch(i(`/api/models`));if(e.ok){let t=await e.json();c(t)}}catch{}finally{u(!1)}},[]);return(0,o.useEffect)(()=>{if(!t)return;d();let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n,d]),t?(0,s.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`models-modal-title`,onClick:e=>{e.target===e.currentTarget&&n()},className:`fixed inset-0 z-50 flex items-center justify-center bg-slate-950/45 p-4 sm:p-6`,children:(0,s.jsxs)(`div`,{className:`w-full max-w-2xl max-h-[85vh] flex flex-col rounded-xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-[#161920] shadow-xl overflow-hidden`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-6 py-4 border-b border-slate-200 dark:border-slate-800`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{id:`models-modal-title`,className:`font-[family-name:var(--font-display)] text-lg font-semibold text-slate-900 dark:text-slate-50`,children:`Models Used`}),(0,s.jsx)(`p`,{className:`text-xs text-slate-500 dark:text-slate-400 mt-0.5`,children:`Uncached combinations cycle through these free models automatically on errors or rate limits.`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:d,"aria-label":`Refresh model pool status`,className:`p-2 rounded-lg text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors cursor-pointer`,children:(0,s.jsx)(a,{className:`w-4 h-4 ${l?`animate-spin`:``}`})}),(0,s.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close models dialog`,className:`p-2 rounded-lg text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors cursor-pointer`,children:(0,s.jsx)(e,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-5`,children:r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 pb-4 border-b border-slate-100 dark:border-slate-800`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Cached Recipes`}),(0,s.jsx)(`div`,{className:`mt-1 text-xl font-semibold font-[family-name:var(--font-mono)] tabular-nums text-slate-900 dark:text-white`,children:r.stats.totalRecipes})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Known Elements`}),(0,s.jsx)(`div`,{className:`mt-1 text-xl font-semibold font-[family-name:var(--font-mono)] tabular-nums text-slate-900 dark:text-white`,children:r.stats.totalElements})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`OpenRouter Key`}),(0,s.jsx)(`div`,{className:`mt-1 text-sm font-semibold text-slate-900 dark:text-white`,children:r.openRouterConfigured?`Configured`:r.geminiFallbackAvailable?`Using fallback`:`Not set`})]})]}),!r.openRouterConfigured&&(0,s.jsxs)(`div`,{className:`p-4 rounded-lg border border-amber-200 dark:border-amber-900/70 bg-amber-50/70 dark:bg-amber-950/25 text-xs text-amber-900 dark:text-amber-200 leading-relaxed`,children:[(0,s.jsx)(`strong`,{children:`OPENROUTER_API_KEY`}),` is not set in server environment secrets yet. Add it to your server secrets to route uncached combinations through the OpenRouter free-model rotation below.`,r.geminiFallbackAvailable?` Until then, uncached combinations temporarily fall back to the server backup model.`:` Cached and custom recipes remain available.`]}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-slate-200 dark:border-slate-800 text-slate-500 dark:text-slate-400`,children:[(0,s.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Order`}),(0,s.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Model ID`}),(0,s.jsx)(`th`,{className:`py-2 pr-3 font-medium text-right`,children:`Hits`}),(0,s.jsx)(`th`,{className:`py-2 pr-3 font-medium text-right`,children:`Errors`}),(0,s.jsx)(`th`,{className:`py-2 font-medium text-right`,children:`State`})]})}),(0,s.jsx)(`tbody`,{className:`divide-y divide-slate-100 dark:divide-slate-800/80`,children:r.models.map((e,t)=>{let n=t===r.nextModelIndex;return(0,s.jsxs)(`tr`,{className:`align-top`,children:[(0,s.jsxs)(`td`,{className:`py-2.5 pr-3 font-[family-name:var(--font-mono)] tabular-nums text-slate-500 dark:text-slate-400`,children:[t+1,n?` →`:``]}),(0,s.jsxs)(`td`,{className:`py-2.5 pr-3`,children:[(0,s.jsx)(`div`,{className:`font-[family-name:var(--font-mono)] text-slate-900 dark:text-slate-100 break-all`,children:e.id}),e.lastError&&(0,s.jsxs)(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400 line-clamp-1`,children:[`Last error: `,e.lastError]})]}),(0,s.jsx)(`td`,{className:`py-2.5 pr-3 text-right font-[family-name:var(--font-mono)] tabular-nums text-slate-700 dark:text-slate-300`,children:e.successCount}),(0,s.jsx)(`td`,{className:`py-2.5 pr-3 text-right font-[family-name:var(--font-mono)] tabular-nums text-slate-700 dark:text-slate-300`,children:e.errorCount}),(0,s.jsx)(`td`,{className:`py-2.5 text-right whitespace-nowrap`,children:e.inCooldown?(0,s.jsxs)(`span`,{className:`text-amber-700 dark:text-amber-400 font-medium font-[family-name:var(--font-mono)] tabular-nums`,children:[`Cooldown `,e.cooldownRemainingSec,`s`]}):n?(0,s.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400 font-semibold`,children:`Next up`}):(0,s.jsx)(`span`,{className:`text-slate-500 dark:text-slate-400`,children:`Ready`})})]},e.id)})})]})})]}):(0,s.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Loading model rotation pool...`})})]})}):null}export{c as ModelsModal};assets/ModelsModal-BHYO3jHv.jsDeleted-1