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
5f3e6fdfc0
commit
a20ac12dd6
1 changed files with 7 additions and 7 deletions
|
@ -747,7 +747,7 @@ def search():
|
||||||
|
|
||||||
# OPENAI GPT
|
# OPENAI GPT
|
||||||
try:
|
try:
|
||||||
url_pair = {}
|
url_pair = []
|
||||||
prompt = ""
|
prompt = ""
|
||||||
for res in results:
|
for res in results:
|
||||||
if 'url' not in res: continue
|
if 'url' not in res: continue
|
||||||
|
@ -755,7 +755,7 @@ def search():
|
||||||
if 'title' not in res: continue
|
if 'title' not in res: continue
|
||||||
if res['content'] == '': continue
|
if res['content'] == '': continue
|
||||||
new_url = 'https://url'+str(len(url_pair)+1)
|
new_url = 'https://url'+str(len(url_pair)+1)
|
||||||
url_pair[new_url] = res['url']
|
url_pair.append(res['url'])
|
||||||
res['title'] = res['title'].replace("التغريدات مع الردود بواسطة","")
|
res['title'] = res['title'].replace("التغريدات مع الردود بواسطة","")
|
||||||
res['content'] = res['content'].replace("Translate Tweet. ","")
|
res['content'] = res['content'].replace("Translate Tweet. ","")
|
||||||
res['content'] = res['content'].replace("Learn more ","")
|
res['content'] = res['content'].replace("Learn more ","")
|
||||||
|
@ -803,8 +803,8 @@ def search():
|
||||||
if 'choices' in gpt_json:
|
if 'choices' in gpt_json:
|
||||||
gpt = gpt_json['choices'][0]['text']
|
gpt = gpt_json['choices'][0]['text']
|
||||||
gpt = gpt.replace("简报:","").replace("简报:","")
|
gpt = gpt.replace("简报:","").replace("简报:","")
|
||||||
for urls in url_pair.keys():
|
for i in range(len(url_pair)-1,-1,-1):
|
||||||
gpt = gpt.replace(urls,url_pair[urls])
|
gpt = gpt.replace("https://url"+str(i),url_pair[i])
|
||||||
rgpt = gpt
|
rgpt = gpt
|
||||||
|
|
||||||
if gpt and gpt!="":
|
if gpt and gpt!="":
|
||||||
|
@ -815,9 +815,9 @@ def search():
|
||||||
rgpt = gpt
|
rgpt = gpt
|
||||||
# gpt = markdown.markdown( gpt , extensions=['footnotes'])
|
# gpt = markdown.markdown( gpt , extensions=['footnotes'])
|
||||||
|
|
||||||
for urls in url_pair.keys():
|
for i in range(len(url_pair)-1,-1,-1):
|
||||||
gpt = gpt.replace("#fn:"+urls.replace("https://url",""),url_pair[urls])
|
gpt = gpt.replace("#fn:"+str(i),url_pair[i])
|
||||||
gpt = gpt.replace("#fn:url"+urls.replace("https://url",""),url_pair[urls])
|
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{
|
||||||
|
|
Loading…
Add table
Reference in a new issue