mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Update webapp.py
This commit is contained in:
parent
a0d7e657b0
commit
297db17e6b
1 changed files with 14 additions and 4 deletions
|
@ -898,6 +898,7 @@ function send_chat()
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
chatTextRaw = "提问:" + word + "\n回答:";
|
chatTextRaw = "提问:" + word + "\n回答:";
|
||||||
|
text_offset = -1;
|
||||||
const prev_chat = document.getElementById('chat').innerHTML;
|
const prev_chat = document.getElementById('chat').innerHTML;
|
||||||
fetch("https://api.openai.com/v1/engines/text-davinci-003/completions", options)
|
fetch("https://api.openai.com/v1/engines/text-davinci-003/completions", options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -914,8 +915,13 @@ const prev_chat = document.getElementById('chat').innerHTML;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { choices } = JSON.parse(result);
|
const { choices } = JSON.parse(result);
|
||||||
|
if(choices[0].logprobes.text_offset[0] > text_offset)
|
||||||
|
{
|
||||||
chatTextRaw+=choices[0].text
|
chatTextRaw+=choices[0].text
|
||||||
document.querySelector("#prompt").innerHTML="";
|
text_offset = choices[0].logprobes.text_offset[choices[0].logprobes.text_offset.length - 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelector("#prompt").innerHTML="";
|
||||||
markdownToHtml(beautify(chatTextRaw), document.querySelector("#prompt"))
|
markdownToHtml(beautify(chatTextRaw), document.querySelector("#prompt"))
|
||||||
document.getElementById('chat').innerHTML = prev_chat+document.querySelector("#prompt").innerHTML;
|
document.getElementById('chat').innerHTML = prev_chat+document.querySelector("#prompt").innerHTML;
|
||||||
|
|
||||||
|
@ -983,6 +989,7 @@ function beautify(text)
|
||||||
return new_text;
|
return new_text;
|
||||||
}
|
}
|
||||||
let chatTextRaw =""
|
let chatTextRaw =""
|
||||||
|
let text_offset = -1;
|
||||||
let prompt = JSON.parse(document.querySelector("#prompt").textContent);
|
let prompt = JSON.parse(document.querySelector("#prompt").textContent);
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
|
@ -1009,8 +1016,11 @@ let prompt = JSON.parse(document.querySelector("#prompt").textContent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { choices } = JSON.parse(result);
|
const { choices } = JSON.parse(result);
|
||||||
|
if(choices[0].logprobes.text_offset[0] > text_offset)
|
||||||
|
{
|
||||||
chatTextRaw+=choices[0].text
|
chatTextRaw+=choices[0].text
|
||||||
|
text_offset = choices[0].logprobes.text_offset[choices[0].logprobes.text_offset.length - 1]
|
||||||
|
}
|
||||||
markdownToHtml(beautify(chatTextRaw), document.getElementById('chat'));
|
markdownToHtml(beautify(chatTextRaw), document.getElementById('chat'));
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue