429 auto-retry: wait in queue instead of erroring
Browse files148 unmodified lines1491501511521531541556 unmodified lines1621631641651661671686 unmodified lines17517617717817918018135 unmodified lines217218219220221217222223224225226227228229230231148 unmodified lines n2:"Korean prompts lose count: “a red apple” gives one in English, five or six in Korean.", n3:"This Space runs on shared CPU hardware, so it is slower than the numbers above.", ft:"We did not train this model. Ours is the CPU packaging, the 3-step setting, the re-quantization, and the measurements.", wait:"Someone else is generating. Waiting for your turn…", ex:["a red apple on a wooden table, photorealistic","a misty pine forest at sunrise, cinematic","a calico cat asleep on a windowsill, soft light","a ceramic coffee cup, studio product shot"]}, ko:{tag:"CPU만으로 이미지 생성. GPU도 CUDA도 파이썬도 필요 없습니다.", h1:"<b>그래픽카드 없이</b> 사진급 이미지를 <b>46초</b>에.",6 unmodified lines n2:"한국어에서 개수를 흘립니다. “빨간 사과”가 영어로는 1개, 한국어로는 대여섯 개가 나옵니다.", n3:"이 데모는 공용 CPU에서 돌아 위 수치보다 느립니다.", ft:"저희가 모델을 학습시킨 게 아닙니다. 저희 것은 CPU 패키징, 3스텝 설정, 재양자화, 그리고 측정값입니다.", wait:"다른 분이 생성 중입니다. 차례를 기다립니다…", ex:["나무 탁자 위의 빨간 사과, 사실적인 사진","해 뜰 무렵 안개 낀 소나무 숲, 영화적인","창가에서 자는 삼색 고양이, 부드러운 빛","도자기 커피잔, 스튜디오 제품 사진"]}, zh:{tag:"仅用 CPU 生成图像。无需 GPU、CUDA 或 Python。", h1:"<b>无需显卡</b>,<b>46 秒</b>生成照片级图像。",6 unmodified lines n2:"中文/韩文提示词会丢失数量信息。", n3:"本演示运行在共享 CPU 上,比上述数据慢。", ft:"我们没有训练该模型。我们做的是 CPU 封装、3 步设置、重新量化以及这些实测数据。", wait:"其他人正在生成。正在等待您的回合…", ex:["木桌上的红苹果,照片级真实","日出时分雾气弥漫的松林,电影感","窗台上熟睡的三花猫,柔和光线","陶瓷咖啡杯,棚拍产品图"]}};let L="en";35 unmodified lines let w=2; bar.style.width="2%"; const tk=setInterval(()=>{w=Math.min(93,w+1.6);bar.style.width=w+"%";},900); try{ let r,tries=0; while(true){ const r=await fetch("/api/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}); r=await fetch("/api/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}); if(r.status!==429) break; tries++; if(tries>40) throw new Error("timeout waiting for a free slot"); mt.innerHTML=`<span>⏳ ${T[L].wait} (${tries})</span>`; await new Promise(s=>setTimeout(s,8000)); } if(!r.ok){throw new Error((await r.text()).slice(0,180));} const d=await r.json(); img.src=d.image; img.style.display="block"; ph.style.display="none";index.html+12-1