Spaces:
Running on Zero
Running on Zero
Update index.html
Browse files- index.html +21 -3
index.html
CHANGED
|
@@ -493,12 +493,11 @@ function renderBot(el,raw){
|
|
| 493 |
let thinkHtml='',ans=raw;
|
| 494 |
const tOpen=raw.indexOf('<think>'),tClose=raw.indexOf('</think>');
|
| 495 |
const dOpen=raw.indexOf('<details>'),sClose=raw.indexOf('</summary>'),dClose=raw.indexOf('</details>');
|
|
|
|
| 496 |
if(tOpen>=0&&tClose>tOpen){
|
| 497 |
-
// Thinking ์๋ฃ โ ์ ์ด์ ๋ธ๋ก + ๋ต๋ณ ํ์
|
| 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 |
-
// ์์ง thinking ์ค โ ์บ๋ฆญํฐ ์๋ง ํ์ (๋ด์ฉ ์จ๊น)
|
| 502 |
const thinkLen=raw.length-tOpen-7;
|
| 503 |
ans='';
|
| 504 |
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>`;
|
|
@@ -506,6 +505,20 @@ function renderBot(el,raw){
|
|
| 506 |
const body=dClose>sClose?raw.slice(sClose+10,dClose):raw.slice(sClose+10);
|
| 507 |
const chain=body.replace(/^> ?/gm,'').replace(/<[^>]+>/g,'').trim();
|
| 508 |
ans=dClose>0?raw.slice(dClose+10).trim():'';thinkHtml=buildThink(chain);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
}
|
| 510 |
b.innerHTML=thinkHtml+md(ans);
|
| 511 |
}
|
|
@@ -513,7 +526,12 @@ function buildThink(chain){
|
|
| 513 |
if(!chain)return'';
|
| 514 |
return`<div class="think-blk" onclick="this.classList.toggle('open')"><div class="think-hdr">๐ง Reasoning Chain (${chain.length} chars)</div><div class="think-body">${esc(chain)}</div></div>`;
|
| 515 |
}
|
| 516 |
-
function stripThink(t){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
|
| 518 |
// Marked.js
|
| 519 |
(function setupMarked(){
|
|
|
|
| 493 |
let thinkHtml='',ans=raw;
|
| 494 |
const tOpen=raw.indexOf('<think>'),tClose=raw.indexOf('</think>');
|
| 495 |
const dOpen=raw.indexOf('<details>'),sClose=raw.indexOf('</summary>'),dClose=raw.indexOf('</details>');
|
| 496 |
+
|
| 497 |
if(tOpen>=0&&tClose>tOpen){
|
|
|
|
| 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 |
ans='';
|
| 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>`;
|
|
|
|
| 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 if(raw.match(/Thinking Process:|Thinking process:|\*\*Thinking Process|1\. \*\*Analyze/)){
|
| 509 |
+
// NIPA plain-text thinking detection
|
| 510 |
+
const apList=['\n\n์๋
','\n\n๋ฐ๊ฐ','\n\n๋ค,','\n\nHello','\n\nHi ','\n\nI ','\n\n---\n','\n\n**Answer','\n\n**Response'];
|
| 511 |
+
let splitIdx=-1;
|
| 512 |
+
for(const ap of apList){const idx=raw.indexOf(ap);if(idx>0){splitIdx=idx;break;}}
|
| 513 |
+
if(splitIdx>0){
|
| 514 |
+
const chain=raw.slice(0,splitIdx).trim();
|
| 515 |
+
ans=raw.slice(splitIdx).trim();
|
| 516 |
+
thinkHtml=buildThink(chain);
|
| 517 |
+
}else{
|
| 518 |
+
// Still reasoning โ show char count only
|
| 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);
|
| 524 |
}
|
|
|
|
| 526 |
if(!chain)return'';
|
| 527 |
return`<div class="think-blk" onclick="this.classList.toggle('open')"><div class="think-hdr">๐ง Reasoning Chain (${chain.length} chars)</div><div class="think-body">${esc(chain)}</div></div>`;
|
| 528 |
}
|
| 529 |
+
function stripThink(t){
|
| 530 |
+
t=t.replace(/^<details>[\s\S]*?<\/details>\n\n/,'').replace(/^<think>[\s\S]*?<\/think>\s*/,'');
|
| 531 |
+
// Strip plain-text thinking
|
| 532 |
+
t=t.replace(/^๐ง Reasoning.*?\n?/,'');
|
| 533 |
+
return t;
|
| 534 |
+
}
|
| 535 |
|
| 536 |
// Marked.js
|
| 537 |
(function setupMarked(){
|