Spaces:
Running on Zero
Running on Zero
Update index.html
Browse files- index.html +38 -16
index.html
CHANGED
|
@@ -486,6 +486,31 @@ function appendBot(){
|
|
| 486 |
document.getElementById('msgs').appendChild(el);
|
| 487 |
scrollDown();return el;
|
| 488 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
function renderBot(el,raw){
|
| 490 |
const t=new Date().toLocaleTimeString('en',{hour:'2-digit',minute:'2-digit'});
|
| 491 |
el.querySelector('.msg-time').textContent=t;
|
|
@@ -498,26 +523,23 @@ function renderBot(el,raw){
|
|
| 498 |
const chain=raw.slice(tOpen+7,tClose).trim();ans=raw.slice(tClose+8).trim();
|
| 499 |
thinkHtml=buildThink(chain);
|
| 500 |
}else if(tOpen>=0){
|
| 501 |
-
const thinkLen=raw.length-tOpen-7;
|
| 502 |
-
|
| 503 |
-
thinkHtml=`<div class="think-blk"><div class="think-hdr" style="cursor:default;">🧠 REASONING CHAIN (${thinkLen} CHARS) <span class="typing" style="display:inline-flex;gap:4px;vertical-align:middle;margin-left:6px;"><span></span><span></span><span></span></span></div></div>`;
|
| 504 |
}else if(dOpen>=0&&sClose>dOpen){
|
| 505 |
const body=dClose>sClose?raw.slice(sClose+10,dClose):raw.slice(sClose+10);
|
| 506 |
const chain=body.replace(/^> ?/gm,'').replace(/<[^>]+>/g,'').trim();
|
| 507 |
ans=dClose>0?raw.slice(dClose+10).trim():'';thinkHtml=buildThink(chain);
|
| 508 |
-
}else
|
| 509 |
-
//
|
| 510 |
-
const
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
ans='';
|
| 520 |
-
thinkHtml=`<div class="think-blk"><div class="think-hdr" style="cursor:default;">🧠 REASONING (${raw.length} CHARS) <span class="typing" style="display:inline-flex;gap:4px;vertical-align:middle;margin-left:6px;"><span></span><span></span><span></span></span></div></div>`;
|
| 521 |
}
|
| 522 |
}
|
| 523 |
b.innerHTML=thinkHtml+md(ans);
|
|
|
|
| 486 |
document.getElementById('msgs').appendChild(el);
|
| 487 |
scrollDown();return el;
|
| 488 |
}
|
| 489 |
+
function isThinkLine(l){
|
| 490 |
+
l=l.trim();
|
| 491 |
+
if(!l)return true;
|
| 492 |
+
const starts=['The user','the user','This is','this is','I should','I need to','Let me','let me',
|
| 493 |
+
'My task','my task',"I'll ",'I will','Since ','since ','Now,','now,','So,','so,','First,','first,',
|
| 494 |
+
'Okay','okay','Alright','Hmm','Wait','Actually','The question','the question','The input',
|
| 495 |
+
'The request','The prompt','Thinking Process','**Thinking','Step ','step ','Approach:','Analysis:',
|
| 496 |
+
'Reasoning:','1. **','2. **','3. **','4. **','5. **'];
|
| 497 |
+
for(const s of starts)if(l.startsWith(s))return true;
|
| 498 |
+
if((l.startsWith('- ')||l.startsWith('* ')||l.startsWith('○ '))&&!/[\u1100-\uD7AF\uAC00-\uD7A3]/.test(l.slice(0,30)))return true;
|
| 499 |
+
return false;
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
function splitThinkAnswer(raw){
|
| 503 |
+
const lines=raw.split('\n');
|
| 504 |
+
for(let i=0;i<lines.length;i++){
|
| 505 |
+
const l=lines[i].trim();
|
| 506 |
+
if(!isThinkLine(lines[i])){
|
| 507 |
+
if(/[\uAC00-\uD7A3]/.test(l.slice(0,10))){return[lines.slice(0,i).join('\n').trim(),lines.slice(i).join('\n').trim()];}
|
| 508 |
+
if(i>2&&lines.slice(Math.max(0,i-2),i).every(x=>!x.trim())){return[lines.slice(0,i).join('\n').trim(),lines.slice(i).join('\n').trim()];}
|
| 509 |
+
}
|
| 510 |
+
}
|
| 511 |
+
return['',raw];
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
function renderBot(el,raw){
|
| 515 |
const t=new Date().toLocaleTimeString('en',{hour:'2-digit',minute:'2-digit'});
|
| 516 |
el.querySelector('.msg-time').textContent=t;
|
|
|
|
| 523 |
const chain=raw.slice(tOpen+7,tClose).trim();ans=raw.slice(tClose+8).trim();
|
| 524 |
thinkHtml=buildThink(chain);
|
| 525 |
}else if(tOpen>=0){
|
| 526 |
+
const thinkLen=raw.length-tOpen-7;ans='';
|
| 527 |
+
thinkHtml=`<div class="think-blk"><div class="think-hdr" style="cursor:default;">🧠 REASONING (${thinkLen} CHARS) <span class="typing" style="display:inline-flex;gap:4px;vertical-align:middle;margin-left:6px;"><span></span><span></span><span></span></span></div></div>`;
|
|
|
|
| 528 |
}else if(dOpen>=0&&sClose>dOpen){
|
| 529 |
const body=dClose>sClose?raw.slice(sClose+10,dClose):raw.slice(sClose+10);
|
| 530 |
const chain=body.replace(/^> ?/gm,'').replace(/<[^>]+>/g,'').trim();
|
| 531 |
ans=dClose>0?raw.slice(dClose+10).trim():'';thinkHtml=buildThink(chain);
|
| 532 |
+
}else{
|
| 533 |
+
// Plain-text thinking detection
|
| 534 |
+
const firstLine=raw.trim().split('\n')[0]||'';
|
| 535 |
+
if(isThinkLine(firstLine)&&raw.length>20){
|
| 536 |
+
const[think,answer]=splitThinkAnswer(raw);
|
| 537 |
+
if(think&&answer){
|
| 538 |
+
thinkHtml=buildThink(think);ans=answer;
|
| 539 |
+
}else if(think&&!answer){
|
| 540 |
+
ans='';
|
| 541 |
+
thinkHtml=`<div class="think-blk"><div class="think-hdr" style="cursor:default;">🧠 REASONING (${raw.length} CHARS) <span class="typing" style="display:inline-flex;gap:4px;vertical-align:middle;margin-left:6px;"><span></span><span></span><span></span></span></div></div>`;
|
| 542 |
+
}
|
|
|
|
|
|
|
| 543 |
}
|
| 544 |
}
|
| 545 |
b.innerHTML=thinkHtml+md(ans);
|