Merge branch 'binary-husky:master' into master

This commit is contained in:
Samon Yu 2025-02-15 16:52:01 +08:00 committed by GitHub
commit f3f5f5f95d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 233 additions and 65 deletions

View File

@ -1,5 +1,5 @@
> [!IMPORTANT]
> `master主分支`最新动态(2025.2.4): 增加deepseek-r1支持
> `master主分支`最新动态(2025.2.13): 联网组件支持Jina的api / 增加deepseek-r1支持
> `frontier开发分支`最新动态(2024.12.9): 更新对话时间线功能优化xelatex论文翻译
> `wiki文档`最新动态(2024.12.5): 更新ollama接入指南
>

View File

@ -354,6 +354,8 @@ NUM_CUSTOM_BASIC_BTN = 4
DAAS_SERVER_URLS = [ f"https://niuziniu-biligpt{i}.hf.space/stream" for i in range(1,5) ]
# 在互联网搜索组件中负责将搜索结果整理成干净的Markdown
JINA_API_KEY = ""
"""
--------------- 配置关联关系说明 ---------------

View File

@ -434,36 +434,6 @@ def get_crazy_functions():
logger.error(trimmed_format_exc())
logger.error("Load function plugin failed")
# try:
# from crazy_functions.联网的ChatGPT import 连接网络回答问题
# function_plugins.update(
# {
# "连接网络回答问题(输入问题后点击该插件,需要访问谷歌)": {
# "Group": "对话",
# "Color": "stop",
# "AsButton": False, # 加入下拉菜单中
# # "Info": "连接网络回答问题(需要访问谷歌)| 输入参数是一个问题",
# "Function": HotReload(连接网络回答问题),
# }
# }
# )
# from crazy_functions.联网的ChatGPT_bing版 import 连接bing搜索回答问题
# function_plugins.update(
# {
# "连接网络回答问题中文Bing版输入问题后点击该插件": {
# "Group": "对话",
# "Color": "stop",
# "AsButton": False, # 加入下拉菜单中
# "Info": "连接网络回答问题需要访问中文Bing| 输入参数是一个问题",
# "Function": HotReload(连接bing搜索回答问题),
# }
# }
# )
# except:
# logger.error(trimmed_format_exc())
# logger.error("Load function plugin failed")
try:
from crazy_functions.SourceCode_Analyse import 解析任意code项目
@ -771,6 +741,9 @@ def get_multiplex_button_functions():
"常规对话":
"",
"查互联网后回答":
"查互联网后回答",
"多模型对话":
"询问多个GPT模型", # 映射到上面的 `询问多个GPT模型` 插件

View File

@ -175,10 +175,17 @@ def scrape_text(url, proxies) -> str:
Returns:
str: The scraped text
"""
from loguru import logger
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36',
'Content-Type': 'text/plain',
}
# 首先采用Jina进行文本提取
if get_conf("JINA_API_KEY"):
try: return jina_scrape_text(url)
except: logger.debug("Jina API 请求失败,回到旧方法")
try:
response = requests.get(url, headers=headers, proxies=proxies, timeout=8)
if response.encoding == "ISO-8859-1": response.encoding = response.apparent_encoding
@ -193,6 +200,24 @@ def scrape_text(url, proxies) -> str:
text = "\n".join(chunk for chunk in chunks if chunk)
return text
def jina_scrape_text(url) -> str:
"jina_39727421c8fa4e4fa9bd698e5211feaaDyGeVFESNrRaepWiLT0wmHYJSh-d"
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36',
'Content-Type': 'text/plain',
"X-Retain-Images": "none",
"Authorization": f'Bearer {get_conf("JINA_API_KEY")}'
}
response = requests.get("https://r.jina.ai/" + url, headers=headers, proxies=None, timeout=8)
if response.status_code != 200:
raise ValueError("Jina API 请求失败,开始尝试旧方法!" + response.text)
if response.encoding == "ISO-8859-1": response.encoding = response.apparent_encoding
result = response.text
result = result.replace("\\[", "[").replace("\\]", "]").replace("\\(", "(").replace("\\)", ")")
return response.text
def internet_search_with_analysis_prompt(prompt, analysis_prompt, llm_kwargs, chatbot):
from toolbox import get_conf
proxies = get_conf('proxies')
@ -246,23 +271,52 @@ def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
urls = search_optimizer(txt, proxies, optimizer_history, llm_kwargs, optimizer, categories, searxng_url, engines)
history = []
if len(urls) == 0:
chatbot.append((f"结论:{txt}",
"[Local Message] 受到限制无法从searxng获取信息请尝试更换搜索引擎。"))
chatbot.append((f"结论:{txt}", "[Local Message] 受到限制无法从searxng获取信息请尝试更换搜索引擎。"))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
# ------------- < 第2步依次访问网页 > -------------
from concurrent.futures import ThreadPoolExecutor
from textwrap import dedent
max_search_result = 5 # 最多收纳多少个网页的结果
if optimizer == "开启(增强)":
max_search_result = 8
chatbot.append(["联网检索中 ...", None])
for index, url in enumerate(urls[:max_search_result]):
res = scrape_text(url['link'], proxies)
prefix = f"{index}份搜索结果 [源自{url['source'][0]}搜索] {url['title'][:25]}"
history.extend([prefix, res])
res_squeeze = res.replace('\n', '...')
chatbot[-1] = [prefix + "\n\n" + res_squeeze[:500] + "......", None]
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
template = dedent("""
<details>
<summary>{TITLE}</summary>
<div class="search_result">{URL}</div>
<div class="search_result">{CONTENT}</div>
</details>
""")
buffer = ""
# 创建线程池
with ThreadPoolExecutor(max_workers=5) as executor:
# 提交任务到线程池
futures = []
for index, url in enumerate(urls[:max_search_result]):
future = executor.submit(scrape_text, url['link'], proxies)
futures.append((index, future, url))
# 处理完成的任务
for index, future, url in futures:
# 开始
prefix = f"正在加载 第{index+1}份搜索结果 [源自{url['source'][0]}搜索] {url['title'][:25]}"
string_structure = template.format(TITLE=prefix, URL=url['link'], CONTENT="正在加载,请稍后 ......")
yield from update_ui_lastest_msg(lastmsg=(buffer + string_structure), chatbot=chatbot, history=history, delay=0.1) # 刷新界面
# 获取结果
res = future.result()
# 显示结果
prefix = f"{index+1}份搜索结果 [源自{url['source'][0]}搜索] {url['title'][:25]}"
string_structure = template.format(TITLE=prefix, URL=url['link'], CONTENT=res[:1000] + "......")
buffer += string_structure
# 更新历史
history.extend([prefix, res])
yield from update_ui_lastest_msg(lastmsg=buffer, chatbot=chatbot, history=history, delay=0.1) # 刷新界面
# ------------- < 第3步ChatGPT综合 > -------------
if (optimizer != "开启(增强)"):

View File

@ -38,11 +38,12 @@ class NetworkGPT_Wrap(GptAcademicPluginTemplate):
}
return gui_definition
def execute(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
def execute(txt, llm_kwargs, plugin_kwargs:dict, chatbot, history, system_prompt, user_request):
"""
执行插件
"""
if plugin_kwargs["categories"] == "网页": plugin_kwargs["categories"] = "general"
if plugin_kwargs["categories"] == "学术论文": plugin_kwargs["categories"] = "science"
if plugin_kwargs.get("categories", None) == "网页": plugin_kwargs["categories"] = "general"
elif plugin_kwargs.get("categories", None) == "学术论文": plugin_kwargs["categories"] = "science"
else: plugin_kwargs["categories"] = "general"
yield from 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request)

View File

@ -45,28 +45,161 @@ Any folded content here. It requires an empty line just above it.
md ="""
在这种场景中您希望机器 B 能够通过轮询机制来间接地请求机器 A而实际上机器 A 只能主动向机器 B 发出请求这是一种典型的客户端-服务器轮询模式下面是如何实现这种机制的详细步骤
<details>
<summary>第0份搜索结果 [源自google搜索] 汤姆·赫兰德</summary>
<div class="search_result">https://baike.baidu.com/item/%E6%B1%A4%E5%A7%86%C2%B7%E8%B5%AB%E5%85%B0%E5%BE%B7/3687216</div>
<div class="search_result">Title: 汤姆·赫兰德
### 机器 B 的实现
URL Source: https://baike.baidu.com/item/%E6%B1%A4%E5%A7%86%C2%B7%E8%B5%AB%E5%85%B0%E5%BE%B7/3687216
1. **安装 FastAPI 和必要的依赖库**
```bash
pip install fastapi uvicorn
```
Markdown Content:
网页新闻贴吧知道网盘图片视频地图文库资讯采购百科
百度首页
登录
注册
进入词条
全站搜索
帮助
首页
秒懂百科
特色百科
知识专题
加入百科
百科团队
权威合作
个人中心
汤姆·赫兰德
播报
讨论
上传视频
英国男演员
汤姆·赫兰德Tom Holland1996年6月1日出生于英国英格兰泰晤士河畔金斯顿英国男演员2008出演音乐剧跳出我天地而崭露头角2010作为主演参加音乐剧跳出我天地的五周年特别演出2012年10月11日主演的个人首部电影海啸奇迹上映并凭该电影获得第84届美国国家评论协会奖最具突破男演员奖2016年10月15日与查理·汉纳姆西耶娜·米勒合作出演的电影 ... >>>
2. **创建 FastAPI 服务**
```python
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from uuid import uuid4
from threading import Lock
import time
目录
1早年经历
2演艺经历
影坛新星
角色多变
跨界翘楚
3个人生活
家庭
恋情
社交
4主要作品
参演电影
参演电视剧
配音作品
导演作品
杂志写真
5社会活动
6获奖记录
7人物评价
基本信息
汤姆·赫兰德Tom Holland1996年6月1日出生于英国英格兰泰晤士河畔金斯顿英国男演员 [67]
2008出演音乐剧跳出我天地而崭露头角 [1]2010作为主演参加音乐剧跳出我天地的五周年特别演出 [2]2012年10月11日主演的个人首部电影海啸奇迹上映并凭该电影获得第84届美国国家评论协会奖最具突破男演员奖 [3]2016年10月15日与查理·汉纳姆西耶娜·米勒合作出演的电影迷失Z城在纽约电影节首映 [17]2017主演的蜘蛛侠英雄归来上映他凭该电影获得第19届青少年选择奖最佳暑期电影男演员奖以及第70届英国电影和电视艺术学院奖最佳新星奖 [72]2019主演的电影蜘蛛侠英雄远征上映 [5]同年凭借该电影获得第21届青少年选择奖最佳夏日电影男演员奖 [6]2024年4月汤姆·霍兰德主演的伦敦西区新版舞台剧罗密欧与朱丽叶公布演员名单 [66]
2024......</div>
</details>
app = FastAPI()
<details>
<summary>第1份搜索结果 [源自google搜索] 汤姆·霍兰德</summary>
<div class="search_result">https://zh.wikipedia.org/zh-hans/%E6%B1%A4%E5%A7%86%C2%B7%E8%B5%AB%E5%85%B0%E5%BE%B7</div>
<div class="search_result">Title: 汤姆·赫兰德
# 字典用于存储请求和状态
requests = {}
process_lock = Lock()
URL Source: https://zh.wikipedia.org/zh-hans/%E6%B1%A4%E5%A7%86%C2%B7%E8%B5%AB%E5%85%B0%E5%BE%B7
Published Time: 2015-06-24T01:08:01Z
Markdown Content:
| 汤姆·霍兰德
Tom Holland |
| --- |
| [![Image 19](https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Tom_Holland_by_Gage_Skidmore.jpg/220px-Tom_Holland_by_Gage_Skidmore.jpg)](https://zh.wikipedia.org/wiki/File:Tom_Holland_by_Gage_Skidmore.jpg)
2016年在[圣地牙哥国际漫画展](https://zh.wikipedia.org/wiki/%E8%81%96%E5%9C%B0%E7%89%99%E5%93%A5%E5%9C%8B%E9%9A%9B%E6%BC%AB%E7%95%AB%E5%B1%95 "圣地牙哥国际漫画展")的霍兰德
|
| 男演员 |
| 昵称 | 荷兰弟[\[1\]](https://zh.wikipedia.org/zh-hans/%E6%B1%A4%E5%A7%86%C2%B7%E8%B5%AB%E5%85%B0%E5%BE%B7#cite_note-1) |
| 出生 | 汤玛斯·史丹利·霍兰德
Thomas Stanley Holland[\[2\]](https://zh.wikipedia.org/zh-hans/%E6%B1%A4%E5%A7%86%C2%B7%E8%B5%AB%E5%85%B0%E5%BE%B7#cite_note-2)
1996年6月1日28
英国[英格兰](https://zh.wikipedia.org/wiki/%E8%8B%B1%E6%A0%BC%E8%98%AD "英格兰")[泰晤士河畔金斯顿](https://zh.wikipedia.org/wiki/%E6%B3%B0%E6%99%A4......</div>
</details>
<details>
<summary>第2份搜索结果 [源自google搜索] 为什么汤姆赫兰德被称为荷兰弟</summary>
<div class="search_result">https://www.zhihu.com/question/363988307</div>
<div class="search_result">Title: 为什么汤姆赫兰德被称为荷兰弟 - 知乎
URL Source: https://www.zhihu.com/question/363988307
Markdown Content:
要说漫威演员里面谁是最牛的存在不好说各有各的看法但要说谁是最能剧透的毫无疑问是我们的汤姆赫兰德荷兰弟可以说他算得上是把剧透给玩明白了先后剧透了不少的电影桥段以至于漫威后面像防贼一样防着人家荷兰弟可大家知道吗你永远想象不到荷兰弟的嘴巴到底有多能漏风
![Image 9](https://pica.zhimg.com/50/v2-a0aa9972315519ec4975f974f01fc6ca_720w.jpg?source=1def8aca)
故事要回到侏罗纪世界2的筹备期间当时荷兰弟也参与了面试计划在剧中饰演一个角色原本这也没啥这都是好莱坞的传统了可是当时的导演胡安根本不知道荷兰弟的风光伟绩于是乎人家便屁颠屁颠把侏罗纪世界2的资料拿过来给荷兰弟虽然后面没有让荷兰弟出演这部电影但导演似乎忘了他的嘴巴是开过光的
![Image 10](https://picx.zhimg.com/50/v2-1da72b482c6a44e1826abb430d95a062_720w.jpg?source=1def8aca)
荷兰弟把剧情刻在了脑子
......</div>
</details>
<details>
<summary>第3份搜索结果 [源自google搜索] 爱戴名表被喷配不上赞达亚荷兰弟曝近照气质大变2</summary>
<div class="search_result">https://www.sohu.com/a/580380519_120702487</div>
<div class="search_result">Title: 爱戴名表被喷配不上赞达亚荷兰弟曝近照气质大变26岁资产惊人_蜘蛛侠_手表_罗伯特·唐尼
URL Source: https://www.sohu.com/a/580380519_120702487
Markdown Content:
2022-08-27 19:00 来源: [BEGEEL宾爵表](https://www.sohu.com/a/580380519_120702487?spm=smpc.content-abroad.content.1.1739375950559fBhgNpP)
发布于广东省
近日大家熟悉的荷兰弟也就演漫威超级英雄蜘蛛侠而走红的英国男星汤姆·赫兰德Tom Holland最近在没有任何预警的情况下宣布自己暂停使用社交媒体原因网络暴力已经严重影响到他的心理健康了虽然自出演蜘蛛侠以来对荷兰弟的骂声就没停过但不可否认他确实是一位才貌双全的好演员同时也是一位拥有高雅品味的地道英伦绅士从他近年名表收藏的趋势也能略知一二
![Image 37](https://p5.itc.cn/q_70/images03/20220827/86aca867047b4119ba96a59e33d2d387.jpeg)
2016美国队长3内战上映汤姆·赫兰德扮演的史上最嫩蜘蛛侠也正式登场这个美国普通学生由于意外被一只受过放射性感染的蜘蛛咬到并因此获得超能力化身邻居英雄蜘蛛侠警恶惩奸和蜘蛛侠彼得·帕克一样当时年仅20岁的荷兰弟无论戏里戏外的穿搭都是少年感十足走的阳光邻家大男孩路线手上戴的最多的就是来自卡西欧的电子表还有来自Nixon sentry的手表千元级别甚至是百元级
20岁的荷兰弟走的是邻家大男孩路线
![Image 38](https://p3.itc.cn/q_70/images03/20220827/aded82ecfb1d439a8fd4741b49a8eb9b.png)
随着荷兰弟主演的蜘蛛侠英雄归来上演第三代蜘蛛侠的话痨性格和年轻活力的形象瞬间圈粉无数荷兰弟的知名度和演艺收入都大幅度增长他的穿衣品味也渐渐从稚嫩少年风转变成轻熟绅士风从简单的T恤短袖搭配牛仔裤开始向更加丰富的造型发展其中变化最明显的就是他手腕上的表
荷兰弟的衣品日......</div>
</details>
<details>
<summary>第4份搜索结果 [源自google搜索] 荷兰弟居然要休息一年因演戏演到精神分裂</summary>
<div class="search_result">https://www.sohu.com/a/683718058_544020</div>
<div class="search_result">Title: 荷兰弟居然要休息一年因演戏演到精神分裂_Holland_Tom_工作
URL Source: https://www.sohu.com/a/683718058_544020
Markdown Content:
荷兰弟居然要休息一年因演戏演到精神分裂\_Holland\_Tom\_工作
===============
* [](http://www.sohu.com/?spm=smpc.content-abroad.nav.1.1739375954055TcEvWsY)
* [新闻](http://news.sohu.com/?spm=smpc.content-abroad.nav.2.1739375954055TcEvWsY)
* [体育](http://sports.sohu.com/?spm=smpc.content-abroad.nav.3.1739375954055TcEvWsY)
* [汽车](http://auto.sohu.com/?spm=smpc.content-abroad.nav.4.1739375954055TcEvWsY)
* [房产](http://www.focus.cn/?spm=smpc.content-abroad.nav.5.1739375954055TcEvWsY)
* [旅游](http://travel.sohu.com/?spm=smpc.content-abroad.nav.6.1739375954055TcEvWsY)
* [教育](http://learning.sohu.com/?spm=smpc.content-abroad.nav.7.1739375954055TcEvWsY)
* [时尚](http://fashion.sohu.com/?spm=smpc.content-abroad.nav.8.1739375954055TcEvWsY)
* [科技](http://it.sohu.com/?spm=smpc.content-abroad.nav.9.1739375954055TcEvWsY)
* [财经](http://business.sohu.com/?spm=smpc.content-abroad.nav.10.17393759......</div>
</details>
"""
def validate_path():

View File

@ -48,8 +48,6 @@ if __name__ == "__main__":
# plugin_test(plugin='crazy_functions.下载arxiv论文翻译摘要->下载arxiv论文并翻译摘要', main_input="1812.10695")
# plugin_test(plugin='crazy_functions.联网的ChatGPT->连接网络回答问题', main_input="谁是应急食品?")
# plugin_test(plugin='crazy_functions.解析JupyterNotebook->解析ipynb文件', main_input="crazy_functions/test_samples")
# plugin_test(plugin='crazy_functions.数学动画生成manim->动画生成', main_input="A ball split into 2, and then split into 4, and finally split into 8.")

View File

@ -48,8 +48,6 @@ if __name__ == "__main__":
# plugin_test(plugin='crazy_functions.下载arxiv论文翻译摘要->下载arxiv论文并翻译摘要', main_input="1812.10695")
# plugin_test(plugin='crazy_functions.联网的ChatGPT->连接网络回答问题', main_input="谁是应急食品?")
# plugin_test(plugin='crazy_functions.解析JupyterNotebook->解析ipynb文件', main_input="crazy_functions/test_samples")
# plugin_test(plugin='crazy_functions.数学动画生成manim->动画生成', main_input="A ball split into 2, and then split into 4, and finally split into 8.")

View File

@ -323,3 +323,12 @@
opacity: 0.8;
}
.search_result {
font-size: smaller;
font-style: italic;
margin: 0px;
padding: 1em;
line-height: 1.5;
text-wrap: wrap;
opacity: 0.8;
}