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
447770efdc
commit
b9304965ec
1 changed files with 16 additions and 11 deletions
|
@ -916,7 +916,12 @@ button.btn_more {
|
||||||
|
|
||||||
var word_last="";
|
var word_last="";
|
||||||
var lock_chat=1;
|
var lock_chat=1;
|
||||||
|
function b64EncodeUnicode(str) {
|
||||||
|
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
||||||
|
function toSolidBytes(match, p1) {
|
||||||
|
return String.fromCharCode('0x' + p1);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
function send_webchat(elem)
|
function send_webchat(elem)
|
||||||
{
|
{
|
||||||
|
@ -945,7 +950,7 @@ function send_webchat(elem)
|
||||||
optionsweb = {
|
optionsweb = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: btoa(unescape(encodeURIComponent(JSON.stringify(prompt.data))))
|
body: b64EncodeUnicode( JSON.stringify(prompt.data))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1018,7 +1023,7 @@ function send_chat(elem)
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: btoa(unescape(encodeURIComponent( JSON.stringify({
|
body: b64EncodeUnicode( JSON.stringify({
|
||||||
"prompt": prompt,
|
"prompt": prompt,
|
||||||
"max_tokens": 1000,
|
"max_tokens": 1000,
|
||||||
"temperature": 0.9,
|
"temperature": 0.9,
|
||||||
|
@ -1029,7 +1034,7 @@ function send_chat(elem)
|
||||||
"echo": false,
|
"echo": false,
|
||||||
"logprobs": 0,
|
"logprobs": 0,
|
||||||
"stream": true
|
"stream": true
|
||||||
}) )))
|
}) )
|
||||||
};
|
};
|
||||||
|
|
||||||
word=word.replaceAll("\n\n","\n").replaceAll("\n\n","\n")
|
word=word.replaceAll("\n\n","\n").replaceAll("\n\n","\n")
|
||||||
|
@ -1150,7 +1155,7 @@ function chatmore()
|
||||||
const optionsMore = {
|
const optionsMore = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: btoa(unescape(encodeURIComponent( JSON.stringify({
|
body: b64EncodeUnicode( JSON.stringify({
|
||||||
"prompt": document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n" + '以上是“''' + original_search_query + r'''”的网络知识。给出需要更多网络知识才能回答的,不含代词的完整独立问题,json数组格式["q1","q2","q3","q4"]:',
|
"prompt": document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n" + '以上是“''' + original_search_query + r'''”的网络知识。给出需要更多网络知识才能回答的,不含代词的完整独立问题,json数组格式["q1","q2","q3","q4"]:',
|
||||||
"max_tokens": 1500,
|
"max_tokens": 1500,
|
||||||
"temperature": 0.7,
|
"temperature": 0.7,
|
||||||
|
@ -1161,7 +1166,7 @@ function chatmore()
|
||||||
"echo": false,
|
"echo": false,
|
||||||
"logprobs": 0,
|
"logprobs": 0,
|
||||||
"stream": false
|
"stream": false
|
||||||
}) )))
|
}) )
|
||||||
};
|
};
|
||||||
if(document.querySelector("#chat_more").innerHTML != "") return
|
if(document.querySelector("#chat_more").innerHTML != "") return
|
||||||
fetch("https://search.kg/completions", optionsMore)
|
fetch("https://search.kg/completions", optionsMore)
|
||||||
|
@ -1191,7 +1196,7 @@ text_offset = -1;
|
||||||
const optionsIntro = {
|
const optionsIntro = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: btoa(unescape(encodeURIComponent( JSON.stringify({
|
body: b64EncodeUnicode( JSON.stringify({
|
||||||
"prompt": "你是一个叫Charles的搜索引擎机器人,用户搜索的是“''' + original_search_query + r'''”有关的信息。\n不要假定搜索结果。\n用简体中文写一句语言幽默的、含有emoji的引入语。\n机器人:",
|
"prompt": "你是一个叫Charles的搜索引擎机器人,用户搜索的是“''' + original_search_query + r'''”有关的信息。\n不要假定搜索结果。\n用简体中文写一句语言幽默的、含有emoji的引入语。\n机器人:",
|
||||||
"max_tokens": 1024,
|
"max_tokens": 1024,
|
||||||
"temperature": 0.2,
|
"temperature": 0.2,
|
||||||
|
@ -1202,7 +1207,7 @@ const optionsIntro = {
|
||||||
"echo": false,
|
"echo": false,
|
||||||
"logprobs": 0,
|
"logprobs": 0,
|
||||||
"stream": true
|
"stream": true
|
||||||
}) )))
|
}) )
|
||||||
};
|
};
|
||||||
fetch("https://search.kg/completions", optionsIntro)
|
fetch("https://search.kg/completions", optionsIntro)
|
||||||
.then((responseIntro) => {
|
.then((responseIntro) => {
|
||||||
|
@ -1221,7 +1226,7 @@ fetch("https://search.kg/completions", optionsIntro)
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: btoa(unescape(encodeURIComponent(JSON.stringify(prompt.data))))
|
body: b64EncodeUnicode(JSON.stringify(prompt.data))
|
||||||
};
|
};
|
||||||
fetch("https://search.kg/completions", options)
|
fetch("https://search.kg/completions", options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -1240,7 +1245,7 @@ fetch("https://search.kg/completions", optionsIntro)
|
||||||
const optionsPlus = {
|
const optionsPlus = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: btoa(unescape(encodeURIComponent(JSON.stringify({
|
body: b64EncodeUnicode(JSON.stringify({
|
||||||
"prompt": "围绕关键词 ''' + original_search_query + r''',结合你的知识总结归纳发表评论,可以用emoji,不得重复提及已有内容:\n" + document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n",
|
"prompt": "围绕关键词 ''' + original_search_query + r''',结合你的知识总结归纳发表评论,可以用emoji,不得重复提及已有内容:\n" + document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n",
|
||||||
"max_tokens": 1500,
|
"max_tokens": 1500,
|
||||||
"temperature": 0.7,
|
"temperature": 0.7,
|
||||||
|
@ -1251,7 +1256,7 @@ fetch("https://search.kg/completions", optionsIntro)
|
||||||
"echo": false,
|
"echo": false,
|
||||||
"logprobs": 0,
|
"logprobs": 0,
|
||||||
"stream": true
|
"stream": true
|
||||||
}))))
|
}))
|
||||||
};
|
};
|
||||||
fetch("https://search.kg/completions", optionsPlus)
|
fetch("https://search.kg/completions", optionsPlus)
|
||||||
.then((responsePlusComment) => {
|
.then((responsePlusComment) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue