Closed oleteacher closed 1 year ago
Any input on this issue greatly appreciated.
This issue usually occurs when letting AI write HTML, where the AI does not respond with descriptive language but directly provides code. Therefore, adding the following code to line 301 of chat.js can solve this problem:
if (alltext == "") {
alltext = json.choices[0].delta.content.replace(/^\n+/, '');
if(alltext.indexOf("```") == -1 && (alltext.indexOf("<") != -1 || alltext.indexOf(">") != -1)){
alltext = "```\n" + alltext;
}
Thank you @gzz100
Your code seems to fix the issue. Appreciate you taking the time to provide input.
I spoke too soon :(
A student typed in the following prompt:
write example php code for flat-file texted based cms for sales pages
This was the output (screenshot):
Very strange results. Just tried the code on another workstation and it works fine. Moved to another workstation and does not work correctly, output is broken as shown above.
Have cleared cache and even renamed chatjs in index.
This is example when the script breaks outside the code box and destroys the response:
Not positive how to fix, spent hours looking into with no success. Above my tiny mind, need a god:)