镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
比较提交
15 次代码提交
huggingfac
...
version3.3
| 作者 | SHA1 | 提交日期 | |
|---|---|---|---|
|
|
0fad4f44a4 | ||
|
|
1240dd6f26 | ||
|
|
d6be947177 | ||
|
|
3cfbdce9f2 | ||
|
|
1ee471ff57 | ||
|
|
25ccecf8e3 | ||
|
|
9e991bfa3e | ||
|
|
221efd0193 | ||
|
|
976b9bf65f | ||
|
|
ae5783e383 | ||
|
|
30224af042 | ||
|
|
8ff7c15cd8 | ||
|
|
ec8cc48a4d | ||
|
|
5d75c578b9 | ||
|
|
cd411c2eea |
@@ -9,12 +9,16 @@ RUN echo '[global]' > /etc/pip.conf && \
|
||||
|
||||
|
||||
WORKDIR /gpt
|
||||
COPY requirements.txt .
|
||||
|
||||
# 装载项目文件
|
||||
COPY . .
|
||||
|
||||
# 安装依赖
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
# 可选步骤,用于预热模块
|
||||
RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()'
|
||||
|
||||
# 启动
|
||||
CMD ["python3", "-u", "main.py"]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
> **Note**
|
||||
>
|
||||
> 安装依赖时,请严格选择requirements.txt中**指定的版本**。
|
||||
> 安装依赖时,请严格选择requirements.txt中**指定的版本**,并使用官方pip源:
|
||||
>
|
||||
> `pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/`
|
||||
> `pip install -r requirements.txt -i https://pypi.org/simple`
|
||||
>
|
||||
|
||||
# <img src="docs/logo.png" width="40" > GPT 学术优化 (GPT Academic)
|
||||
|
||||
@@ -46,7 +46,7 @@ MAX_RETRY = 2
|
||||
|
||||
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 同时它必须被包含在AVAIL_LLM_MODELS切换列表中 )
|
||||
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
|
||||
AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "stack-claude"]
|
||||
AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "newbing-free", "stack-claude"]
|
||||
# P.S. 其他可用的模型还包括 ["newbing-free", "jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
|
||||
|
||||
# 本地LLM模型如ChatGLM的执行方式 CPU/GPU
|
||||
|
||||
@@ -66,7 +66,7 @@ def 多文件润色(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
|
||||
with open(fp, 'r', encoding='utf-8', errors='replace') as f:
|
||||
file_content = f.read()
|
||||
# 定义注释的正则表达式
|
||||
comment_pattern = r'%.*'
|
||||
comment_pattern = r'(?<!\\)%.*'
|
||||
# 使用正则表达式查找注释,并替换为空字符串
|
||||
clean_tex_content = re.sub(comment_pattern, '', file_content)
|
||||
# 记录删除注释后的文本
|
||||
@@ -238,5 +238,3 @@ def Latex英文纠错(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
yield from 多文件润色(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en', mode='proofread')
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
|
||||
with open(fp, 'r', encoding='utf-8', errors='replace') as f:
|
||||
file_content = f.read()
|
||||
# 定义注释的正则表达式
|
||||
comment_pattern = r'%.*'
|
||||
comment_pattern = r'(?<!\\)%.*'
|
||||
# 使用正则表达式查找注释,并替换为空字符串
|
||||
clean_tex_content = re.sub(comment_pattern, '', file_content)
|
||||
# 记录删除注释后的文本
|
||||
|
||||
二进制
docs/gradio-3.32.2-py3-none-any.whl
普通文件
二进制
docs/gradio-3.32.2-py3-none-any.whl
普通文件
二进制文件未显示。
1
main.py
1
main.py
@@ -2,6 +2,7 @@ import os; os.environ['no_proxy'] = '*' # 避免代理网络产生意外污染
|
||||
|
||||
def main():
|
||||
import gradio as gr
|
||||
if gr.__version__ not in ['3.28.3','3.32.2']: assert False, "请用 pip install -r requirements.txt 安装依赖"
|
||||
from request_llm.bridge_all import predict
|
||||
from toolbox import format_io, find_free_port, on_file_uploaded, on_report_generated, get_conf, ArgsGeneralWrapper, DummyWith
|
||||
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址, 避免不小心传github被别人看到
|
||||
|
||||
@@ -202,19 +202,22 @@ if "stack-claude" in AVAIL_LLM_MODELS:
|
||||
}
|
||||
})
|
||||
if "newbing-free" in AVAIL_LLM_MODELS:
|
||||
from .bridge_newbingfree import predict_no_ui_long_connection as newbingfree_noui
|
||||
from .bridge_newbingfree import predict as newbingfree_ui
|
||||
# claude
|
||||
model_info.update({
|
||||
"newbing-free": {
|
||||
"fn_with_ui": newbingfree_ui,
|
||||
"fn_without_ui": newbingfree_noui,
|
||||
"endpoint": newbing_endpoint,
|
||||
"max_token": 4096,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
}
|
||||
})
|
||||
try:
|
||||
from .bridge_newbingfree import predict_no_ui_long_connection as newbingfree_noui
|
||||
from .bridge_newbingfree import predict as newbingfree_ui
|
||||
# claude
|
||||
model_info.update({
|
||||
"newbing-free": {
|
||||
"fn_with_ui": newbingfree_ui,
|
||||
"fn_without_ui": newbingfree_noui,
|
||||
"endpoint": newbing_endpoint,
|
||||
"max_token": 4096,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
}
|
||||
})
|
||||
except:
|
||||
print(trimmed_format_exc())
|
||||
|
||||
def LLM_CATCH_EXCEPTION(f):
|
||||
"""
|
||||
|
||||
@@ -28,8 +28,6 @@ from typing import Union
|
||||
import aiohttp
|
||||
import certifi
|
||||
import httpx
|
||||
from BingImageCreator import ImageGen
|
||||
from BingImageCreator import ImageGenAsync
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
@@ -198,9 +196,9 @@ class _ChatHubRequest:
|
||||
self,
|
||||
prompt: str,
|
||||
conversation_style: CONVERSATION_STYLE_TYPE,
|
||||
options: list | None = None,
|
||||
webpage_context: str | None = None,
|
||||
search_result: bool = False,
|
||||
options = None,
|
||||
webpage_context = None,
|
||||
search_result = False,
|
||||
) -> None:
|
||||
"""
|
||||
Updates request object
|
||||
@@ -296,9 +294,9 @@ class _Conversation:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
proxy: str | None = None,
|
||||
async_mode: bool = False,
|
||||
cookies: list[dict] | None = None,
|
||||
proxy = None,
|
||||
async_mode = False,
|
||||
cookies = None,
|
||||
) -> None:
|
||||
if async_mode:
|
||||
return
|
||||
@@ -352,8 +350,8 @@ class _Conversation:
|
||||
|
||||
@staticmethod
|
||||
async def create(
|
||||
proxy: str | None = None,
|
||||
cookies: list[dict] | None = None,
|
||||
proxy = None,
|
||||
cookies = None,
|
||||
):
|
||||
self = _Conversation(async_mode=True)
|
||||
self.struct = {
|
||||
@@ -420,11 +418,11 @@ class _ChatHub:
|
||||
def __init__(
|
||||
self,
|
||||
conversation: _Conversation,
|
||||
proxy: str = None,
|
||||
cookies: list[dict] | None = None,
|
||||
proxy = None,
|
||||
cookies = None,
|
||||
) -> None:
|
||||
self.session: aiohttp.ClientSession | None = None
|
||||
self.wss: aiohttp.ClientWebSocketResponse | None = None
|
||||
self.session = None
|
||||
self.wss = None
|
||||
self.request: _ChatHubRequest
|
||||
self.loop: bool
|
||||
self.task: asyncio.Task
|
||||
@@ -443,7 +441,7 @@ class _ChatHub:
|
||||
conversation_style: CONVERSATION_STYLE_TYPE = None,
|
||||
raw: bool = False,
|
||||
options: dict = None,
|
||||
webpage_context: str | None = None,
|
||||
webpage_context = None,
|
||||
search_result: bool = False,
|
||||
) -> Generator[str, None, None]:
|
||||
"""
|
||||
@@ -613,10 +611,10 @@ class Chatbot:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
proxy: str | None = None,
|
||||
cookies: list[dict] | None = None,
|
||||
proxy = None,
|
||||
cookies = None,
|
||||
) -> None:
|
||||
self.proxy: str | None = proxy
|
||||
self.proxy = proxy
|
||||
self.chat_hub: _ChatHub = _ChatHub(
|
||||
_Conversation(self.proxy, cookies=cookies),
|
||||
proxy=self.proxy,
|
||||
@@ -625,8 +623,8 @@ class Chatbot:
|
||||
|
||||
@staticmethod
|
||||
async def create(
|
||||
proxy: str | None = None,
|
||||
cookies: list[dict] | None = None,
|
||||
proxy = None,
|
||||
cookies = None,
|
||||
):
|
||||
self = Chatbot.__new__(Chatbot)
|
||||
self.proxy = proxy
|
||||
@@ -643,7 +641,7 @@ class Chatbot:
|
||||
wss_link: str = "wss://sydney.bing.com/sydney/ChatHub",
|
||||
conversation_style: CONVERSATION_STYLE_TYPE = None,
|
||||
options: dict = None,
|
||||
webpage_context: str | None = None,
|
||||
webpage_context = None,
|
||||
search_result: bool = False,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -669,7 +667,7 @@ class Chatbot:
|
||||
conversation_style: CONVERSATION_STYLE_TYPE = None,
|
||||
raw: bool = False,
|
||||
options: dict = None,
|
||||
webpage_context: str | None = None,
|
||||
webpage_context = None,
|
||||
search_result: bool = False,
|
||||
) -> Generator[str, None, None]:
|
||||
"""
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
gradio==3.28.3
|
||||
./docs/gradio-3.32.2-py3-none-any.whl
|
||||
tiktoken>=0.3.3
|
||||
requests[socks]
|
||||
transformers
|
||||
python-markdown-math
|
||||
beautifulsoup4
|
||||
prompt_toolkit
|
||||
latex2mathml
|
||||
python-docx
|
||||
mdtex2html
|
||||
@@ -14,4 +15,4 @@ pymupdf
|
||||
openai
|
||||
numpy
|
||||
arxiv
|
||||
|
||||
rich
|
||||
|
||||
21
toolbox.py
21
toolbox.py
@@ -764,4 +764,23 @@ def zip_folder(source_folder, dest_folder, zip_name):
|
||||
|
||||
def gen_time_str():
|
||||
import time
|
||||
return time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
|
||||
return time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
|
||||
|
||||
|
||||
class ProxyNetworkActivate():
|
||||
"""
|
||||
这段代码定义了一个名为TempProxy的空上下文管理器, 用于给一小段代码上代理
|
||||
"""
|
||||
def __enter__(self):
|
||||
from toolbox import get_conf
|
||||
proxies, = get_conf('proxies')
|
||||
if 'no_proxy' in os.environ: os.environ.pop('no_proxy')
|
||||
os.environ['HTTP_PROXY'] = proxies['http']
|
||||
os.environ['HTTPS_PROXY'] = proxies['https']
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
os.environ['no_proxy'] = '*'
|
||||
if 'HTTP_PROXY' in os.environ: os.environ.pop('HTTP_PROXY')
|
||||
if 'HTTPS_PROXY' in os.environ: os.environ.pop('HTTPS_PROXY')
|
||||
return
|
||||
4
version
4
version
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": 3.36,
|
||||
"version": 3.37,
|
||||
"show_feature": true,
|
||||
"new_feature": "修复PDF翻译的BUG, 新增HTML中英双栏对照 <-> 添加了OpenAI图片生成插件 <-> 添加了OpenAI音频转文本总结插件 <-> 通过Slack添加对Claude的支持 <-> 提供复旦MOSS模型适配(启用需额外依赖) <-> 提供docker-compose方案兼容LLAMA盘古RWKV等模型的后端 <-> 新增Live2D装饰 <-> 完善对话历史的保存/载入/删除 <-> 保存对话功能"
|
||||
"new_feature": "修复gradio复制按钮BUG <-> 修复PDF翻译的BUG, 新增HTML中英双栏对照 <-> 添加了OpenAI图片生成插件 <-> 添加了OpenAI音频转文本总结插件 <-> 通过Slack添加对Claude的支持 <-> 提供复旦MOSS模型适配(启用需额外依赖) <-> 提供docker-compose方案兼容LLAMA盘古RWKV等模型的后端 <-> 新增Live2D装饰 <-> 完善对话历史的保存/载入/删除 <-> 保存对话功能"
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户