Spaces:
Running
Running
Upload index.html with huggingface_hub
Browse files- index.html +18 -12
index.html
CHANGED
|
@@ -654,26 +654,30 @@ function renderBot(el,raw,elapsed,tokens,speed){
|
|
| 654 |
let thinkHtml='',ans=raw,thinkChars=0;
|
| 655 |
const tOpen=raw.indexOf('<think>'),tClose=raw.indexOf('</think>');
|
| 656 |
const dOpen=raw.indexOf('<details>'),sClose=raw.indexOf('</summary>'),dClose=raw.indexOf('</details>');
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
}else if(tOpen>=0){
|
| 662 |
-
|
| 663 |
-
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>`;
|
| 664 |
}else if(dOpen>=0&&sClose>dOpen){
|
| 665 |
const body=dClose>sClose?raw.slice(sClose+10,dClose):raw.slice(sClose+10);
|
| 666 |
const chain=body.replace(/^> ?/gm,'').replace(/<[^>]+>/g,'').trim();
|
| 667 |
ans=dClose>0?raw.slice(dClose+10).trim():'';thinkHtml=buildThink(chain);thinkChars=chain.length;
|
|
|
|
|
|
|
|
|
|
| 668 |
}else{
|
| 669 |
const firstLine=raw.trim().split('\n')[0]||'';
|
| 670 |
if(isThinkLine(firstLine)&&raw.length>20){
|
| 671 |
const[think,answer]=splitThinkAnswer(raw);
|
| 672 |
if(think&&answer){thinkHtml=buildThink(think);ans=answer;thinkChars=think.length;}
|
| 673 |
-
else if(think&&!answer){
|
| 674 |
-
ans='';
|
| 675 |
-
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>`;
|
| 676 |
-
}
|
| 677 |
}
|
| 678 |
}
|
| 679 |
b.innerHTML=thinkHtml+md(ans);
|
|
@@ -691,8 +695,10 @@ function buildThink(chain){
|
|
| 691 |
}
|
| 692 |
function stripThink(t){
|
| 693 |
t=t.replace(/^<details>[\s\S]*?<\/details>\n\n/,'').replace(/^<think>[\s\S]*?<\/think>\s*/,'');
|
| 694 |
-
//
|
| 695 |
-
t=t.replace(/^
|
|
|
|
|
|
|
| 696 |
return t;
|
| 697 |
}
|
| 698 |
|
|
|
|
| 654 |
let thinkHtml='',ans=raw,thinkChars=0;
|
| 655 |
const tOpen=raw.indexOf('<think>'),tClose=raw.indexOf('</think>');
|
| 656 |
const dOpen=raw.indexOf('<details>'),sClose=raw.indexOf('</summary>'),dClose=raw.indexOf('</details>');
|
| 657 |
+
const THINKING='<div class="think-blk"><div class="think-hdr" style="cursor:default;">๐ญ ์๊ฐ ์ค<span class="typing" style="display:inline-flex;gap:4px;vertical-align:middle;margin-left:8px;"><span></span><span></span><span></span></span></div></div>';
|
| 658 |
+
const hasKo=s=>/[๊ฐ-ํฃ]/.test(s);
|
| 659 |
+
|
| 660 |
+
if(tClose>=0){
|
| 661 |
+
// Darwin: </think> ๊ธฐ์ค ๋ถ๋ฆฌ (<think> ์์ ํ๊ทธ๋ chat_template ์ด prompt ์ ๋ฃ์ด, ์ถ๋ ฅ์ ๋ณดํต </think> ๋ง)
|
| 662 |
+
const cstart=tOpen>=0?tOpen+7:0;
|
| 663 |
+
const chain=raw.slice(cstart,tClose).replace(/<think>/g,'').trim();
|
| 664 |
+
ans=raw.slice(tClose+8).trim();thinkChars=chain.length;
|
| 665 |
+
thinkHtml=ans?buildThink(chain):THINKING; // ๋ต๋ณ ์ ์ด๋ฉด '์๊ฐ ์ค'
|
| 666 |
}else if(tOpen>=0){
|
| 667 |
+
ans='';thinkHtml=THINKING; // <think> ๋ง (์คํธ๋ฆฌ๋ฐ ์ค)
|
|
|
|
| 668 |
}else if(dOpen>=0&&sClose>dOpen){
|
| 669 |
const body=dClose>sClose?raw.slice(sClose+10,dClose):raw.slice(sClose+10);
|
| 670 |
const chain=body.replace(/^> ?/gm,'').replace(/<[^>]+>/g,'').trim();
|
| 671 |
ans=dClose>0?raw.slice(dClose+10).trim():'';thinkHtml=buildThink(chain);thinkChars=chain.length;
|
| 672 |
+
}else if(raw.trim()&&!hasKo(raw.slice(0,300))&&isThinkLine(raw.trim().split('\n')[0])){
|
| 673 |
+
// </think> ์์ง + ํ๊ธ ์์ = ์์ด ์ฌ๊ณ ์์ฑ ์ค โ '์๊ฐ ์ค' ์ ๋๋ฉ์ด์
(์์ด ์จ๊น)
|
| 674 |
+
ans='';thinkHtml=THINKING;
|
| 675 |
}else{
|
| 676 |
const firstLine=raw.trim().split('\n')[0]||'';
|
| 677 |
if(isThinkLine(firstLine)&&raw.length>20){
|
| 678 |
const[think,answer]=splitThinkAnswer(raw);
|
| 679 |
if(think&&answer){thinkHtml=buildThink(think);ans=answer;thinkChars=think.length;}
|
| 680 |
+
else if(think&&!answer){ans='';thinkHtml=THINKING;}
|
|
|
|
|
|
|
|
|
|
| 681 |
}
|
| 682 |
}
|
| 683 |
b.innerHTML=thinkHtml+md(ans);
|
|
|
|
| 695 |
}
|
| 696 |
function stripThink(t){
|
| 697 |
t=t.replace(/^<details>[\s\S]*?<\/details>\n\n/,'').replace(/^<think>[\s\S]*?<\/think>\s*/,'');
|
| 698 |
+
// Darwin: </think> ๋จ๋
(์์ ํ๊ทธ ์์) โ </think> ๊น์ง์ ์ฌ๊ณ ๊ณผ์ ์ ๊ฑฐ
|
| 699 |
+
t=t.replace(/^[\s\S]*?<\/think>\s*/,'');
|
| 700 |
+
// Strip plain-text thinking markers
|
| 701 |
+
t=t.replace(/^๐ง Reasoning.*?\n?/,'').replace(/^๐ญ ์๊ฐ.*?\n?/,'');
|
| 702 |
return t;
|
| 703 |
}
|
| 704 |
|