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,25 +1975,47 @@ function send_modalchat(elem)
|
|||
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"
|
||||
|
||||
let promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
||||
for (el in modalele)
|
||||
let promptWebpage
|
||||
if(document.querySelector("#iframe-wrapper > iframe").src.includes("pdfjs/index.html?file="))
|
||||
{
|
||||
if((promptWebpage + modalele[el] + '\n').length <900)
|
||||
promptWebpage = promptWebpage + modalele[el] + '\n';
|
||||
}
|
||||
promptWebpage = promptWebpage +'网页内容:\n'
|
||||
|
||||
fulltext.sort((a, b) => {
|
||||
if (cosineSimilarity(word,a) > cosineSimilarity(word,b)) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
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')
|
||||
}
|
||||
})
|
||||
for (let st=0;st< Math.min(3,fulltext.length);++st)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(keytextres.indexOf(fulltext[st])==-1)
|
||||
keytextres.unshift(fulltext[st])
|
||||
promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
||||
for (el in modalele)
|
||||
{
|
||||
if((promptWebpage + modalele[el] + '\n').length <900)
|
||||
promptWebpage = promptWebpage + modalele[el] + '\n';
|
||||
}
|
||||
promptWebpage = promptWebpage +'网页内容:\n'
|
||||
|
||||
fulltext.sort((a, b) => {
|
||||
if (cosineSimilarity(word,a) > cosineSimilarity(word,b)) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
})
|
||||
for (let st=0;st< Math.min(4,fulltext.length);++st)
|
||||
{
|
||||
if(keytextres.indexOf(fulltext[st])==-1)
|
||||
keytextres.unshift(fulltext[st])
|
||||
}
|
||||
|
||||
}
|
||||
keySentencesCount = 0;
|
||||
for (st in keytextres)
|
||||
|
|
|
@ -1975,25 +1975,47 @@ function send_modalchat(elem)
|
|||
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"
|
||||
|
||||
let promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
||||
for (el in modalele)
|
||||
let promptWebpage
|
||||
if(document.querySelector("#iframe-wrapper > iframe").src.includes("pdfjs/index.html?file="))
|
||||
{
|
||||
if((promptWebpage + modalele[el] + '\n').length <900)
|
||||
promptWebpage = promptWebpage + modalele[el] + '\n';
|
||||
}
|
||||
promptWebpage = promptWebpage +'网页内容:\n'
|
||||
|
||||
fulltext.sort((a, b) => {
|
||||
if (cosineSimilarity(word,a) > cosineSimilarity(word,b)) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
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')
|
||||
}
|
||||
})
|
||||
for (let st=0;st< Math.min(3,fulltext.length);++st)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(keytextres.indexOf(fulltext[st])==-1)
|
||||
keytextres.unshift(fulltext[st])
|
||||
promptWebpage = '网页标题:'+ article.title +'\n'+'网页布局:\n'
|
||||
for (el in modalele)
|
||||
{
|
||||
if((promptWebpage + modalele[el] + '\n').length <900)
|
||||
promptWebpage = promptWebpage + modalele[el] + '\n';
|
||||
}
|
||||
promptWebpage = promptWebpage +'网页内容:\n'
|
||||
|
||||
fulltext.sort((a, b) => {
|
||||
if (cosineSimilarity(word,a) > cosineSimilarity(word,b)) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
})
|
||||
for (let st=0;st< Math.min(4,fulltext.length);++st)
|
||||
{
|
||||
if(keytextres.indexOf(fulltext[st])==-1)
|
||||
keytextres.unshift(fulltext[st])
|
||||
}
|
||||
|
||||
}
|
||||
keySentencesCount = 0;
|
||||
for (st in keytextres)
|
||||
|
|
Loading…
Add table
Reference in a new issue