mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
c
This commit is contained in:
parent
25fcb6bc0f
commit
b3309d3d3b
2 changed files with 80 additions and 36 deletions
|
@ -1975,7 +1975,27 @@ function send_modalchat(elem)
|
||||||
lock_chat = 1;
|
lock_chat = 1;
|
||||||
const knowledge = document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n以上是关键词“" + search_queryquery + "”的搜索结果\n"
|
const knowledge = document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n以上是关键词“" + search_queryquery + "”的搜索结果\n"
|
||||||
|
|
||||||
let promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
let promptWebpage
|
||||||
|
if(document.querySelector("#iframe-wrapper > iframe").src.includes("pdfjs/index.html?file="))
|
||||||
|
{
|
||||||
|
promptWebpage = 'PDF标题:'+ article.title +'\n'
|
||||||
|
promptWebpage = promptWebpage +'PDF内容:\n'
|
||||||
|
sentences.sort((a, b) => {
|
||||||
|
if (cosineSimilarity(word,a[1]) > cosineSimilarity(word,b[1])) {
|
||||||
|
return -1
|
||||||
|
} else {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
for (let st=0;st< Math.min(6,sentences.length);++st)
|
||||||
|
{
|
||||||
|
if(keytextres.indexOf(sentences[st][1])==-1)
|
||||||
|
keytextres.unshift('第'+String(sentences[st][0])+'页'+sentences[st][2]+'第'+String(sentences[st][3])+'行:'+sentences[st][1]+'\n')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
||||||
for (el in modalele)
|
for (el in modalele)
|
||||||
{
|
{
|
||||||
if((promptWebpage + modalele[el] + '\n').length <900)
|
if((promptWebpage + modalele[el] + '\n').length <900)
|
||||||
|
@ -1990,11 +2010,13 @@ function send_modalchat(elem)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
for (let st=0;st< Math.min(3,fulltext.length);++st)
|
for (let st=0;st< Math.min(4,fulltext.length);++st)
|
||||||
{
|
{
|
||||||
if(keytextres.indexOf(fulltext[st])==-1)
|
if(keytextres.indexOf(fulltext[st])==-1)
|
||||||
keytextres.unshift(fulltext[st])
|
keytextres.unshift(fulltext[st])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
keySentencesCount = 0;
|
keySentencesCount = 0;
|
||||||
for (st in keytextres)
|
for (st in keytextres)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1975,7 +1975,27 @@ function send_modalchat(elem)
|
||||||
lock_chat = 1;
|
lock_chat = 1;
|
||||||
const knowledge = document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n以上是关键词“" + search_queryquery + "”的搜索结果\n"
|
const knowledge = document.querySelector("#chat").innerHTML.replace(/<a.*?>.*?<\/a.*?>/g, '').replace(/<hr.*/gs, '').replace(/<[^>]+>/g,"").replace(/\n\n/g,"\n") +"\n以上是关键词“" + search_queryquery + "”的搜索结果\n"
|
||||||
|
|
||||||
let promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
let promptWebpage
|
||||||
|
if(document.querySelector("#iframe-wrapper > iframe").src.includes("pdfjs/index.html?file="))
|
||||||
|
{
|
||||||
|
promptWebpage = 'PDF标题:'+ article.title +'\n'
|
||||||
|
promptWebpage = promptWebpage +'PDF内容:\n'
|
||||||
|
sentences.sort((a, b) => {
|
||||||
|
if (cosineSimilarity(word,a[1]) > cosineSimilarity(word,b[1])) {
|
||||||
|
return -1
|
||||||
|
} else {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
for (let st=0;st< Math.min(6,sentences.length);++st)
|
||||||
|
{
|
||||||
|
if(keytextres.indexOf(sentences[st][1])==-1)
|
||||||
|
keytextres.unshift('第'+String(sentences[st][0])+'页'+sentences[st][2]+'第'+String(sentences[st][3])+'行:'+sentences[st][1]+'\n')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
||||||
for (el in modalele)
|
for (el in modalele)
|
||||||
{
|
{
|
||||||
if((promptWebpage + modalele[el] + '\n').length <900)
|
if((promptWebpage + modalele[el] + '\n').length <900)
|
||||||
|
@ -1990,11 +2010,13 @@ function send_modalchat(elem)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
for (let st=0;st< Math.min(3,fulltext.length);++st)
|
for (let st=0;st< Math.min(4,fulltext.length);++st)
|
||||||
{
|
{
|
||||||
if(keytextres.indexOf(fulltext[st])==-1)
|
if(keytextres.indexOf(fulltext[st])==-1)
|
||||||
keytextres.unshift(fulltext[st])
|
keytextres.unshift(fulltext[st])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
keySentencesCount = 0;
|
keySentencesCount = 0;
|
||||||
for (st in keytextres)
|
for (st in keytextres)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue