镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 14:36:48 +00:00
internet gpt minor bug fix
这个提交包含在:
@@ -37,8 +37,8 @@ def searxng_request(query, proxies, categories='general', searxng_url=None):
|
|||||||
json_result = response.json()
|
json_result = response.json()
|
||||||
for result in json_result['results']:
|
for result in json_result['results']:
|
||||||
item = {
|
item = {
|
||||||
"title": result["title"],
|
"title": result.get("title", ""),
|
||||||
"content": result["content"],
|
"content": result.get("content", ""),
|
||||||
"link": result["url"],
|
"link": result["url"],
|
||||||
}
|
}
|
||||||
results.append(item)
|
results.append(item)
|
||||||
@@ -80,8 +80,7 @@ def scrape_text(url, proxies) -> str:
|
|||||||
def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||||
|
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
chatbot.append((f"请结合互联网信息回答以下问题:{txt}",
|
chatbot.append((f"请结合互联网信息回答以下问题:{txt}", None))
|
||||||
"[Local Message] 请注意,您正在调用一个[函数插件]的模板,该模板可以实现ChatGPT联网信息综合。该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板。您若希望分享新的功能模组,请不吝PR!"))
|
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
|
|
||||||
# ------------- < 第1步:爬取搜索引擎的结果 > -------------
|
# ------------- < 第1步:爬取搜索引擎的结果 > -------------
|
||||||
@@ -98,10 +97,12 @@ def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
|||||||
return
|
return
|
||||||
# ------------- < 第2步:依次访问网页 > -------------
|
# ------------- < 第2步:依次访问网页 > -------------
|
||||||
max_search_result = 5 # 最多收纳多少个网页的结果
|
max_search_result = 5 # 最多收纳多少个网页的结果
|
||||||
|
chatbot.append([f"联网检索中 ...", None])
|
||||||
for index, url in enumerate(urls[:max_search_result]):
|
for index, url in enumerate(urls[:max_search_result]):
|
||||||
res = scrape_text(url['link'], proxies)
|
res = scrape_text(url['link'], proxies)
|
||||||
history.extend([f"第{index}份搜索结果:", res])
|
history.extend([f"第{index}份搜索结果:", res])
|
||||||
chatbot.append([f"第{index}份搜索结果:", res[:500]+"......"])
|
res_squeeze = res.replace('\n', '...')
|
||||||
|
chatbot[-1] = [f"第{index}份搜索结果:\n\n" + res_squeeze[:500] + "......", None]
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
|
|
||||||
# ------------- < 第3步:ChatGPT综合 > -------------
|
# ------------- < 第3步:ChatGPT综合 > -------------
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户