This commit is contained in:
Joseph Cheung 2023-02-27 12:48:18 +08:00
parent 8d340b1287
commit 93bf05871d
2 changed files with 11 additions and 4 deletions

File diff suppressed because one or more lines are too long

View file

@ -702,7 +702,7 @@ def search():
search_type = '任务' search_type = '任务'
net_search = False net_search = False
net_search_str = 'false' net_search_str = 'false'
else: elif len(original_query)>10:
prompt = "任务:写诗 写故事 写代码 写论文摘要 模仿推特用户 生成搜索广告 回答问题 聊天话题 搜索网页 搜索视频 搜索地图 搜索新闻 查看食谱 搜索商品 写歌词 写论文 模仿名人 翻译语言 摘要文章 讲笑话 做数学题 搜索图片 播放音乐 查看天气\n1.判断是以上任务的哪一个2.判断是否需要联网回答3.给出搜索关键词\n" prompt = "任务:写诗 写故事 写代码 写论文摘要 模仿推特用户 生成搜索广告 回答问题 聊天话题 搜索网页 搜索视频 搜索地图 搜索新闻 查看食谱 搜索商品 写歌词 写论文 模仿名人 翻译语言 摘要文章 讲笑话 做数学题 搜索图片 播放音乐 查看天气\n1.判断是以上任务的哪一个2.判断是否需要联网回答3.给出搜索关键词\n"
prompt = prompt + "提问:" + search_query.query + '答案用json数组例如["写诗","","详细关键词"]来表述\n答案:' prompt = prompt + "提问:" + search_query.query + '答案用json数组例如["写诗","","详细关键词"]来表述\n答案:'
acts = ['写诗', '写故事', '写代码', '写论文摘要', '模仿推特用户', '生成搜索广告', '回答问题', '聊天话题', '搜索网页', '搜索视频', '搜索地图', '搜索新闻', '查看食谱', '搜索商品', '写歌词', '写论文', '模仿名人', '翻译语言', '摘要文章', '讲笑话', '做数学题', '搜索图片', '播放音乐', '查看天气'] acts = ['写诗', '写故事', '写代码', '写论文摘要', '模仿推特用户', '生成搜索广告', '回答问题', '聊天话题', '搜索网页', '搜索视频', '搜索地图', '搜索新闻', '查看食谱', '搜索商品', '写歌词', '写论文', '模仿名人', '翻译语言', '摘要文章', '讲笑话', '做数学题', '搜索图片', '播放音乐', '查看天气']
@ -728,7 +728,8 @@ def search():
"logprobs": 0, "logprobs": 0,
"stream": False "stream": False
} }
gpt_response = requests.post(gpt_url, headers=gpt_headers, data=json.dumps(gpt_data)) if prompt and prompt !='' :
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']
@ -740,7 +741,7 @@ def search():
if gpt!="": if gpt!="":
search_query.query = gpt search_query.query = gpt
if 'Google' not in original_search_query and 'google' not in original_search_query and '谷歌' not in original_search_query and ('Google' in search_query.query or 'google' in search_query.query or '谷歌' in search_query.query): if 'Google' not in original_search_query and 'google' not in original_search_query and '谷歌' not in original_search_query and ('Google' in search_query.query or 'google' in search_query.query or '谷歌' in search_query.query):
search_query.query.replace("Google","").replace("google","").replace("谷歌","") search_query.query=search_query.query.replace("Google","").replace("google","").replace("谷歌","")
else: else:
gpt_judge = [] gpt_judge = []
for tmpj in gpt.split(): for tmpj in gpt.split():
@ -1305,6 +1306,11 @@ for(let i=prompt.url_pair.length;i>=0;--i)
new_text = new_text.replace("httpsurl"+String(i),prompt.url_pair[i]) new_text = new_text.replace("httpsurl"+String(i),prompt.url_pair[i])
new_text = new_text.replace("url"+String(i),prompt.url_pair[i]) new_text = new_text.replace("url"+String(i),prompt.url_pair[i])
} }
new_text = new_text.replace(/(https?:\/\/(?!url\d)\S+)/g, '');
new_text = new_text.replaceAll('(链接)', '');
new_text = new_text.replaceAll('[]', '');
new_text = new_text.replaceAll('((', '(');
new_text = new_text.replaceAll('))', ')');
return new_text; return new_text;
} }