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
935fcf1c60
commit
c919210493
1 changed files with 40 additions and 38 deletions
|
@ -798,50 +798,52 @@ def search():
|
||||||
"logprobs": 0,
|
"logprobs": 0,
|
||||||
"stream": False
|
"stream": False
|
||||||
}
|
}
|
||||||
gpt_response = requests.post(gpt_url, headers=gpt_headers, data=json.dumps(gpt_data))
|
gpt = json.dumps({'data':gpt_data, 'url_pair':url_pair})
|
||||||
gpt_json = gpt_response.json()
|
gpt = '<div id="prompt">' + gpt + '</div>'
|
||||||
if 'choices' in gpt_json:
|
# gpt_response = requests.post(gpt_url, headers=gpt_headers, data=json.dumps(gpt_data))
|
||||||
gpt = gpt_json['choices'][0]['text']
|
# gpt_json = gpt_response.json()
|
||||||
gpt = gpt.replace("简报:","").replace("简报:","")
|
# if 'choices' in gpt_json:
|
||||||
for i in range(len(url_pair)-1,-1,-1):
|
# gpt = gpt_json['choices'][0]['text']
|
||||||
gpt = gpt.replace("https://url"+str(i),url_pair[i])
|
# gpt = gpt.replace("简报:","").replace("简报:","")
|
||||||
rgpt = gpt
|
# for i in range(len(url_pair)-1,-1,-1):
|
||||||
|
# gpt = gpt.replace("https://url"+str(i),url_pair[i])
|
||||||
|
# rgpt = gpt
|
||||||
|
|
||||||
if gpt and gpt!="":
|
if gpt and gpt!="":
|
||||||
if original_search_query != search_query.query:
|
if original_search_query != search_query.query:
|
||||||
gpt = "Search 为您搜索:" + search_query.query + "\n\n" + gpt
|
gpt = "Search 为您搜索:" + search_query.query + "\n\n" + gpt
|
||||||
for i in range(1,16):
|
# for i in range(1,16):
|
||||||
gpt = gpt.replace("["+str(i)+"] http","[^"+str(i)+"]: http").replace("["+str(i)+"]http","[^"+str(i)+"]: http").replace("["+str(i)+"]","[^"+str(i)+"]")
|
# gpt = gpt.replace("["+str(i)+"] http","[^"+str(i)+"]: http").replace("["+str(i)+"]http","[^"+str(i)+"]: http").replace("["+str(i)+"]","[^"+str(i)+"]")
|
||||||
rgpt = gpt
|
# rgpt = gpt
|
||||||
# gpt = markdown.markdown( gpt , extensions=['footnotes'])
|
# gpt = markdown.markdown( gpt , extensions=['footnotes'])
|
||||||
|
|
||||||
for i in range(len(url_pair)-1,-1,-1):
|
# for i in range(len(url_pair)-1,-1,-1):
|
||||||
gpt = gpt.replace("#fn:"+str(i),url_pair[i])
|
# gpt = gpt.replace("#fn:"+str(i),url_pair[i])
|
||||||
gpt = gpt.replace("#fn:url"+str(i),url_pair[i])
|
# gpt = gpt.replace("#fn:url"+str(i),url_pair[i])
|
||||||
gpt = re.sub(r'<div class="footnote">(.*?)</div>', '', gpt, flags=re.DOTALL)
|
# gpt = re.sub(r'<div class="footnote">(.*?)</div>', '', gpt, flags=re.DOTALL)
|
||||||
gpt = gpt + '''<style>
|
# gpt = gpt + '''<style>
|
||||||
a.footnote-ref{
|
# a.footnote-ref{
|
||||||
position: relative;
|
# position: relative;
|
||||||
display: inline-flex;
|
# display: inline-flex;
|
||||||
align-items: center;
|
# align-items: center;
|
||||||
justify-content: center;
|
# justify-content: center;
|
||||||
font-size: 10px;
|
# font-size: 10px;
|
||||||
font-weight: 600;
|
# font-weight: 600;
|
||||||
vertical-align: top;
|
# vertical-align: top;
|
||||||
top: 5px;
|
# top: 5px;
|
||||||
margin: 2px 2px 2px;
|
# margin: 2px 2px 2px;
|
||||||
min-width: 14px;
|
# min-width: 14px;
|
||||||
height: 14px;
|
# height: 14px;
|
||||||
border-radius: 3px;
|
# border-radius: 3px;
|
||||||
color: rgb(18, 59, 182);
|
# color: rgb(18, 59, 182);
|
||||||
background: rgb(209, 219, 250);
|
# background: rgb(209, 219, 250);
|
||||||
outline: transparent solid 1px;
|
# outline: transparent solid 1px;
|
||||||
}
|
# }
|
||||||
</style>
|
# </style>
|
||||||
'''
|
# '''
|
||||||
for i in range(1, 16):
|
# for i in range(1, 16):
|
||||||
rgpt = rgpt.replace(f"[{i}]", "")
|
# rgpt = rgpt.replace(f"[{i}]", "")
|
||||||
rgpt = rgpt.replace(f"[^{i}]", "")
|
# rgpt = rgpt.replace(f"[^{i}]", "")
|
||||||
gptbox = {
|
gptbox = {
|
||||||
'infobox': original_search_query,
|
'infobox': original_search_query,
|
||||||
'id': 'gpt'+str(len(prompt)),
|
'id': 'gpt'+str(len(prompt)),
|
||||||
|
|
Loading…
Add table
Reference in a new issue