This commit is contained in:
Joseph Cheung 2023-03-02 12:14:37 +08:00
parent f86d142f18
commit 3a2702e973
2 changed files with 1057 additions and 28 deletions

File diff suppressed because one or more lines are too long

View file

@ -1389,11 +1389,9 @@ function modal_open(url, num)
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTemp+=choices[0].message.content
chatTemp+=choices[0].text
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n")
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
@ -1727,11 +1725,10 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTemp+=choices[0].text chatTemp+=choices[0].message.content
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n")
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
@ -1852,11 +1849,10 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTemp+=choices[0].text chatTemp+=choices[0].message.content
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n")
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
@ -1944,11 +1940,10 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTemp+=choices[0].text chatTemp+=choices[0].message.content
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n")
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
@ -2175,10 +2170,9 @@ fetch("https://search.kg/completions", optionsIntro)
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTextRawPlusComment+=choices[0].text chatTextRawPlusComment+=choices[0].message.content
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
markdownToHtml(beautify(chatTextRawPlusComment), document.getElementById('chat')); markdownToHtml(beautify(chatTextRawPlusComment), document.getElementById('chat'));
@ -2199,10 +2193,9 @@ fetch("https://search.kg/completions", optionsIntro)
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTextRaw+=choices[0].text chatTextRaw+=choices[0].message.content
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
markdownToHtml(beautify(chatTextRaw), document.getElementById('chat')); markdownToHtml(beautify(chatTextRaw), document.getElementById('chat'));
@ -2233,10 +2226,9 @@ fetch("https://search.kg/completions", optionsIntro)
try{choices=JSON.parse(half+result)['choices'];half = '';} try{choices=JSON.parse(half+result)['choices'];half = '';}
catch(e){choices=JSON.parse(result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';}
}catch(e){half+=result} }catch(e){half+=result}
if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) if(choices && choices.length>0)
{ {
chatTextRawIntro+=choices[0].text chatTextRawIntro+=choices[0].message.content
text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1]
} }
markdownToHtml(beautify(chatTextRawIntro+'\n'), document.getElementById('chat_intro')); markdownToHtml(beautify(chatTextRawIntro+'\n'), document.getElementById('chat_intro'));