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
91ee8a3d71
commit
5471cf8f0f
1 changed files with 2 additions and 4 deletions
|
@ -712,7 +712,6 @@ def search():
|
||||||
tmp_prompt = new_url +'\n'+ res['title'] +'\n'+ res['content']
|
tmp_prompt = new_url +'\n'+ res['title'] +'\n'+ res['content']
|
||||||
if len(prompt)+len(tmp_prompt)<=1500:
|
if len(prompt)+len(tmp_prompt)<=1500:
|
||||||
prompt += tmp_prompt +'\n'
|
prompt += tmp_prompt +'\n'
|
||||||
print("prompt:"+prompt+"\n以上是搜索引擎对关键词 " + search_query.query + " 的结果,用简体中文分条总结简报,在文中用markdown脚注指向内容来源链接:")
|
|
||||||
if prompt != "":
|
if prompt != "":
|
||||||
gpt = ""
|
gpt = ""
|
||||||
gpt_url = "https://api.openai.com/v1/engines/text-davinci-003/completions"
|
gpt_url = "https://api.openai.com/v1/engines/text-davinci-003/completions"
|
||||||
|
@ -733,16 +732,15 @@ def search():
|
||||||
"logprobs": 0,
|
"logprobs": 0,
|
||||||
"stream": False
|
"stream": False
|
||||||
}
|
}
|
||||||
print(gpt_response)
|
|
||||||
gpt_response = requests.post(gpt_url, headers=gpt_headers, data=json.dumps(gpt_data))
|
gpt_response = requests.post(gpt_url, headers=gpt_headers, data=json.dumps(gpt_data))
|
||||||
gpt_json = gpt_response.json()
|
gpt_json = gpt_response.json()
|
||||||
if 'choices' in gpt_json:
|
if 'choices' in gpt_json:
|
||||||
gpt = gpt_json['choices'][0]['text']
|
gpt = gpt_json['choices'][0]['text']
|
||||||
for urls in url_pair.keys():
|
for urls in url_pair.keys():
|
||||||
gpt.replace(urls,url_pair[urls])
|
gpt = gpt.replace(urls,url_pair[urls])
|
||||||
if gpt and gpt!="":
|
if gpt and gpt!="":
|
||||||
gptbox = {
|
gptbox = {
|
||||||
'infobox': 'New Search',
|
'infobox': 'GPT3',
|
||||||
'id': 'gpt'+str(len(prompt)),
|
'id': 'gpt'+str(len(prompt)),
|
||||||
'content': gpt,
|
'content': gpt,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue