镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-10 16:36:48 +00:00
比较提交
7 次代码提交
version3.3
...
version3.3
| 作者 | SHA1 | 提交日期 | |
|---|---|---|---|
|
|
4783fd6f37 | ||
|
|
9a4b56277c | ||
|
|
5eea959103 | ||
|
|
856df8fb62 | ||
|
|
8e59412c47 | ||
|
|
8f571ff68f | ||
|
|
e4c4b28ddf |
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# <img src="docs/logo.png" width="40" > ChatGPT 学术优化
|
# <img src="docs/logo.png" width="40" > ChatGPT 学术优化
|
||||||
|
|
||||||
**如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发issue或者pull requests**
|
**如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发pull requests**
|
||||||
|
|
||||||
If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a README in [English|](docs/README_EN.md)[日本語|](docs/README_JP.md)[Русский|](docs/README_RS.md)[Français](docs/README_FR.md) translated by this project itself.
|
If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a README in [English|](docs/README_EN.md)[日本語|](docs/README_JP.md)[Русский|](docs/README_RS.md)[Français](docs/README_FR.md) translated by this project itself.
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ def get_crazy_functions():
|
|||||||
from crazy_functions.总结word文档 import 总结word文档
|
from crazy_functions.总结word文档 import 总结word文档
|
||||||
from crazy_functions.解析JupyterNotebook import 解析ipynb文件
|
from crazy_functions.解析JupyterNotebook import 解析ipynb文件
|
||||||
from crazy_functions.对话历史存档 import 对话历史存档
|
from crazy_functions.对话历史存档 import 对话历史存档
|
||||||
|
from crazy_functions.批量Markdown翻译 import Markdown英译中
|
||||||
function_plugins = {
|
function_plugins = {
|
||||||
|
|
||||||
"解析整个Python项目": {
|
"解析整个Python项目": {
|
||||||
@@ -81,8 +82,14 @@ def get_crazy_functions():
|
|||||||
"Color": "stop", # 按钮颜色
|
"Color": "stop", # 按钮颜色
|
||||||
"Function": HotReload(读文章写摘要)
|
"Function": HotReload(读文章写摘要)
|
||||||
},
|
},
|
||||||
|
"Markdown/Readme英译中": {
|
||||||
|
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
||||||
|
"Color": "stop",
|
||||||
|
"Function": HotReload(Markdown英译中)
|
||||||
|
},
|
||||||
"批量生成函数注释": {
|
"批量生成函数注释": {
|
||||||
"Color": "stop", # 按钮颜色
|
"Color": "stop", # 按钮颜色
|
||||||
|
"AsButton": False, # 加入下拉菜单中
|
||||||
"Function": HotReload(批量生成函数注释)
|
"Function": HotReload(批量生成函数注释)
|
||||||
},
|
},
|
||||||
"[多线程Demo] 解析此项目本身(源码自译解)": {
|
"[多线程Demo] 解析此项目本身(源码自译解)": {
|
||||||
@@ -110,7 +117,6 @@ def get_crazy_functions():
|
|||||||
from crazy_functions.Latex全文翻译 import Latex中译英
|
from crazy_functions.Latex全文翻译 import Latex中译英
|
||||||
from crazy_functions.Latex全文翻译 import Latex英译中
|
from crazy_functions.Latex全文翻译 import Latex英译中
|
||||||
from crazy_functions.批量Markdown翻译 import Markdown中译英
|
from crazy_functions.批量Markdown翻译 import Markdown中译英
|
||||||
from crazy_functions.批量Markdown翻译 import Markdown英译中
|
|
||||||
|
|
||||||
function_plugins.update({
|
function_plugins.update({
|
||||||
"批量翻译PDF文档(多线程)": {
|
"批量翻译PDF文档(多线程)": {
|
||||||
@@ -175,12 +181,7 @@ def get_crazy_functions():
|
|||||||
"AsButton": False, # 加入下拉菜单中
|
"AsButton": False, # 加入下拉菜单中
|
||||||
"Function": HotReload(Markdown中译英)
|
"Function": HotReload(Markdown中译英)
|
||||||
},
|
},
|
||||||
"[测试功能] 批量Markdown英译中(输入路径或上传压缩包)": {
|
|
||||||
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
|
||||||
"Color": "stop",
|
|
||||||
"AsButton": False, # 加入下拉菜单中
|
|
||||||
"Function": HotReload(Markdown英译中)
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,33 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
|
|||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
|
|
||||||
|
|
||||||
|
def get_files_from_everything(txt):
|
||||||
|
import glob, os
|
||||||
|
|
||||||
|
success = True
|
||||||
|
if txt.startswith('http'):
|
||||||
|
# 网络的远程文件
|
||||||
|
txt = txt.replace("https://github.com/", "https://raw.githubusercontent.com/")
|
||||||
|
txt = txt.replace("/blob/", "/")
|
||||||
|
import requests
|
||||||
|
from toolbox import get_conf
|
||||||
|
proxies, = get_conf('proxies')
|
||||||
|
r = requests.get(txt, proxies=proxies)
|
||||||
|
with open('./gpt_log/temp.md', 'wb+') as f: f.write(r.content)
|
||||||
|
project_folder = './gpt_log/'
|
||||||
|
file_manifest = ['./gpt_log/temp.md']
|
||||||
|
elif txt.endswith('.md'):
|
||||||
|
# 直接给定文件
|
||||||
|
file_manifest = [txt]
|
||||||
|
project_folder = os.path.dirname(txt)
|
||||||
|
elif os.path.exists(txt):
|
||||||
|
# 本地路径,递归搜索
|
||||||
|
project_folder = txt
|
||||||
|
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
|
||||||
|
else:
|
||||||
|
success = False
|
||||||
|
|
||||||
|
return success, file_manifest, project_folder
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
@@ -98,6 +124,7 @@ def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|||||||
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
||||||
try:
|
try:
|
||||||
import tiktoken
|
import tiktoken
|
||||||
|
import glob, os
|
||||||
except:
|
except:
|
||||||
report_execption(chatbot, history,
|
report_execption(chatbot, history,
|
||||||
a=f"解析项目: {txt}",
|
a=f"解析项目: {txt}",
|
||||||
@@ -105,19 +132,21 @@ def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
return
|
return
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
|
||||||
if os.path.exists(txt):
|
success, file_manifest, project_folder = get_files_from_everything(txt)
|
||||||
project_folder = txt
|
|
||||||
else:
|
if not success:
|
||||||
|
# 什么都没有
|
||||||
if txt == "": txt = '空空如也的输入栏'
|
if txt == "": txt = '空空如也的输入栏'
|
||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
return
|
return
|
||||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
|
|
||||||
if len(file_manifest) == 0:
|
if len(file_manifest) == 0:
|
||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
return
|
return
|
||||||
|
|
||||||
yield from 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en->zh')
|
yield from 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en->zh')
|
||||||
|
|
||||||
|
|
||||||
@@ -135,6 +164,7 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|||||||
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
||||||
try:
|
try:
|
||||||
import tiktoken
|
import tiktoken
|
||||||
|
import glob, os
|
||||||
except:
|
except:
|
||||||
report_execption(chatbot, history,
|
report_execption(chatbot, history,
|
||||||
a=f"解析项目: {txt}",
|
a=f"解析项目: {txt}",
|
||||||
@@ -142,18 +172,13 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
return
|
return
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
success, file_manifest, project_folder = get_files_from_everything(txt)
|
||||||
if os.path.exists(txt):
|
if not success:
|
||||||
project_folder = txt
|
# 什么都没有
|
||||||
else:
|
|
||||||
if txt == "": txt = '空空如也的输入栏'
|
if txt == "": txt = '空空如也的输入栏'
|
||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
return
|
return
|
||||||
if txt.endswith('.md'):
|
|
||||||
file_manifest = [txt]
|
|
||||||
else:
|
|
||||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
|
|
||||||
if len(file_manifest) == 0:
|
if len(file_manifest) == 0:
|
||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
|
|||||||
@@ -88,14 +88,14 @@ class NewBingHandle(Process):
|
|||||||
if a not in self.local_history:
|
if a not in self.local_history:
|
||||||
self.local_history.append(a)
|
self.local_history.append(a)
|
||||||
prompt += a + '\n'
|
prompt += a + '\n'
|
||||||
if b not in self.local_history:
|
# if b not in self.local_history:
|
||||||
self.local_history.append(b)
|
# self.local_history.append(b)
|
||||||
prompt += b + '\n'
|
# prompt += b + '\n'
|
||||||
|
|
||||||
# 问题
|
# 问题
|
||||||
prompt += question
|
prompt += question
|
||||||
self.local_history.append(question)
|
self.local_history.append(question)
|
||||||
|
print('question:', prompt)
|
||||||
# 提交
|
# 提交
|
||||||
async for final, response in self.newbing_model.ask_stream(
|
async for final, response in self.newbing_model.ask_stream(
|
||||||
prompt=question,
|
prompt=question,
|
||||||
@@ -108,7 +108,8 @@ class NewBingHandle(Process):
|
|||||||
else:
|
else:
|
||||||
print('-------- receive final ---------')
|
print('-------- receive final ---------')
|
||||||
self.child.send('[Finish]')
|
self.child.send('[Finish]')
|
||||||
|
# self.local_history.append(response)
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
@@ -244,7 +245,7 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
|||||||
for response in newbing_handle.stream_chat(query=inputs, history=history_feedin, system_prompt=system_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
|
for response in newbing_handle.stream_chat(query=inputs, history=history_feedin, system_prompt=system_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
|
||||||
chatbot[-1] = (inputs, preprocess_newbing_out(response))
|
chatbot[-1] = (inputs, preprocess_newbing_out(response))
|
||||||
yield from update_ui(chatbot=chatbot, history=history, msg="NewBing响应缓慢,尚未完成全部响应,请耐心完成后再提交新问题。")
|
yield from update_ui(chatbot=chatbot, history=history, msg="NewBing响应缓慢,尚未完成全部响应,请耐心完成后再提交新问题。")
|
||||||
|
if response == "[Local Message]: 等待NewBing响应中 ...": response = "[Local Message]: NewBing响应异常,请刷新界面重试 ..."
|
||||||
history.extend([inputs, preprocess_newbing_out(response)])
|
history.extend([inputs, response])
|
||||||
yield from update_ui(chatbot=chatbot, history=history, msg="完成全部响应,请提交新问题。")
|
yield from update_ui(chatbot=chatbot, history=history, msg="完成全部响应,请提交新问题。")
|
||||||
|
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户