Merge branch 'master' into frontier

这个提交包含在:
binary-husky
2025-02-07 01:21:39 +08:00
当前提交 1acd2bf292
共有 5 个文件被更改,包括 160 次插入41 次删除

查看文件

@@ -1,11 +1,11 @@
> [!IMPORTANT] > [!IMPORTANT]
> `master主分支`最新动态(2025.2.4): 增加deepseek-r1支持;增加字体自定义功能 > `master主分支`最新动态(2025.2.4): 增加deepseek-r1支持
> `master主分支`最新动态(2025.2.2): 三分钟快速接入最强qwen2.5-max[视频](https://www.bilibili.com/video/BV1LeFuerEG4)
> `frontier开发分支`最新动态(2024.12.9): 更新对话时间线功能,优化xelatex论文翻译 > `frontier开发分支`最新动态(2024.12.9): 更新对话时间线功能,优化xelatex论文翻译
> `wiki文档`最新动态(2024.12.5): 更新ollama接入指南 > `wiki文档`最新动态(2024.12.5): 更新ollama接入指南
> >
> 2025.2.2: 三分钟快速接入最强qwen2.5-max[视频](https://www.bilibili.com/video/BV1LeFuerEG4)
> 2025.2.1: 支持自定义字体
> 2024.10.10: 突发停电,紧急恢复了提供[whl包](https://drive.google.com/drive/folders/14kR-3V-lIbvGxri4AHc8TpiA1fqsw7SK?usp=sharing)的文件服务器 > 2024.10.10: 突发停电,紧急恢复了提供[whl包](https://drive.google.com/drive/folders/14kR-3V-lIbvGxri4AHc8TpiA1fqsw7SK?usp=sharing)的文件服务器
> 2024.10.8: 版本3.90加入对llama-index的初步支持,版本3.80加入插件二级菜单功能详见wiki
> 2024.5.1: 加入Doc2x翻译PDF论文的功能,[查看详情](https://github.com/binary-husky/gpt_academic/wiki/Doc2x) > 2024.5.1: 加入Doc2x翻译PDF论文的功能,[查看详情](https://github.com/binary-husky/gpt_academic/wiki/Doc2x)
> 2024.3.11: 全力支持Qwen、GLM、DeepseekCoder等中文大语言模型 SoVits语音克隆模块,[查看详情](https://www.bilibili.com/video/BV1Rp421S7tF/) > 2024.3.11: 全力支持Qwen、GLM、DeepseekCoder等中文大语言模型 SoVits语音克隆模块,[查看详情](https://www.bilibili.com/video/BV1Rp421S7tF/)
> 2024.1.17: 安装依赖时,请选择`requirements.txt`中**指定的版本**。 安装命令:`pip install -r requirements.txt`。本项目完全开源免费,您可通过订阅[在线服务](https://github.com/binary-husky/gpt_academic/wiki/online)的方式鼓励本项目的发展。 > 2024.1.17: 安装依赖时,请选择`requirements.txt`中**指定的版本**。 安装命令:`pip install -r requirements.txt`。本项目完全开源免费,您可通过订阅[在线服务](https://github.com/binary-husky/gpt_academic/wiki/online)的方式鼓励本项目的发展。
@@ -129,20 +129,20 @@ Latex论文一键校对 | [插件] 仿Grammarly对Latex文章进行语法、拼
```mermaid ```mermaid
flowchart TD flowchart TD
A{"安装方法"} --> W1("I. 🔑直接运行 (Windows, Linux or MacOS)") A{"安装方法"} --> W1("I 🔑直接运行 (Windows, Linux or MacOS)")
W1 --> W11["1. Python pip包管理依赖"] W1 --> W11["1 Python pip包管理依赖"]
W1 --> W12["2. Anaconda包管理依赖推荐⭐"] W1 --> W12["2 Anaconda包管理依赖推荐⭐"]
A --> W2["II. 🐳使用Docker (Windows, Linux or MacOS)"] A --> W2["II 🐳使用Docker (Windows, Linux or MacOS)"]
W2 --> k1["1. 部署项目全部能力的大镜像(推荐⭐)"] W2 --> k1["1 部署项目全部能力的大镜像(推荐⭐)"]
W2 --> k2["2. 仅在线模型GPT, GLM4等镜像"] W2 --> k2["2 仅在线模型GPT, GLM4等镜像"]
W2 --> k3["3. 在线模型 + Latex的大镜像"] W2 --> k3["3 在线模型 + Latex的大镜像"]
A --> W4["IV. 🚀其他部署方法"] A --> W4["IV 🚀其他部署方法"]
W4 --> C1["1. Windows/MacOS 一键安装运行脚本(推荐⭐)"] W4 --> C1["1 Windows/MacOS 一键安装运行脚本(推荐⭐)"]
W4 --> C2["2. Huggingface, Sealos远程部署"] W4 --> C2["2 Huggingface, Sealos远程部署"]
W4 --> C4["3. ... 其他 ..."] W4 --> C4["3 其他 ..."]
``` ```
### 安装方法I直接运行 (Windows, Linux or MacOS) ### 安装方法I直接运行 (Windows, Linux or MacOS)

查看文件

@@ -57,7 +57,7 @@ def main():
# 如果WEB_PORT是-1, 则随机选取WEB端口 # 如果WEB_PORT是-1, 则随机选取WEB端口
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
from check_proxy import get_current_version from check_proxy import get_current_version
from themes.theme import adjust_theme, advanced_css, theme_declaration, js_code_clear, js_code_show_or_hide, js_code_show_or_hide_group2 from themes.theme import adjust_theme, advanced_css, theme_declaration, js_code_clear, js_code_show_or_hide
from themes.theme import js_code_for_toggle_darkmode from themes.theme import js_code_for_toggle_darkmode
from themes.theme import load_dynamic_theme, to_cookie_str, from_cookie_str, assign_user_uuid from themes.theme import load_dynamic_theme, to_cookie_str, from_cookie_str, assign_user_uuid
title_html = f"<h1 align=\"center\">GPT 学术优化 {get_current_version()}</h1>{theme_declaration}" title_html = f"<h1 align=\"center\">GPT 学术优化 {get_current_version()}</h1>{theme_declaration}"
@@ -210,7 +210,7 @@ def main():
ret.update({area_customize: gr.update(visible=("自定义菜单" in a))}) ret.update({area_customize: gr.update(visible=("自定义菜单" in a))})
return ret return ret
checkboxes_2.select(fn_area_visibility_2, [checkboxes_2], [area_customize] ) checkboxes_2.select(fn_area_visibility_2, [checkboxes_2], [area_customize] )
checkboxes_2.select(None, [checkboxes_2], None, _js=js_code_show_or_hide_group2) checkboxes_2.select(None, [checkboxes_2], None, _js="""apply_checkbox_change_for_group2""")
# 整理反复出现的控件句柄组合 # 整理反复出现的控件句柄组合
input_combo = [cookies, max_length_sl, md_dropdown, txt, txt2, top_p, temperature, chatbot, history, system_prompt, plugin_advanced_arg] input_combo = [cookies, max_length_sl, md_dropdown, txt, txt2, top_p, temperature, chatbot, history, system_prompt, plugin_advanced_arg]

查看文件

@@ -26,8 +26,8 @@ def define_gui_toolbar(AVAIL_LLM_MODELS, LLM_MODEL, INIT_SYS_PROMPT, THEME, AVAI
fontfamily_dropdown = gr.Dropdown(AVAIL_FONTS, value=get_conf("FONT"), elem_id="elem_fontfamily", label="更换字体类型").style(container=False) fontfamily_dropdown = gr.Dropdown(AVAIL_FONTS, value=get_conf("FONT"), elem_id="elem_fontfamily", label="更换字体类型").style(container=False)
fontsize_slider = gr.Slider(minimum=5, maximum=25, value=15, step=1, interactive=True, label="字体大小(默认15)", elem_id="elem_fontsize") fontsize_slider = gr.Slider(minimum=5, maximum=25, value=15, step=1, interactive=True, label="字体大小(默认15)", elem_id="elem_fontsize")
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "浮动输入区", "输入清除键", "插件参数区"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区", elem_id='cbs').style(container=False) checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "浮动输入区", "输入清除键", "插件参数区"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区", elem_id='cbs').style(container=False)
opt = ["自定义菜单"] opt = ["自定义菜单", "主标题", "副标题", "显示logo"]
value=[] value=["主标题", "副标题", "显示logo"]
if ADD_WAIFU: opt += ["添加Live2D形象"]; value += ["添加Live2D形象"] if ADD_WAIFU: opt += ["添加Live2D形象"]; value += ["添加Live2D形象"]
checkboxes_2 = gr.CheckboxGroup(opt, value=value, label="显示/隐藏自定义菜单", elem_id='cbsc').style(container=False) checkboxes_2 = gr.CheckboxGroup(opt, value=value, label="显示/隐藏自定义菜单", elem_id='cbsc').style(container=False)
dark_mode_btn = gr.Button("切换界面明暗 ☀", variant="secondary").style(size="sm") dark_mode_btn = gr.Button("切换界面明暗 ☀", variant="secondary").style(size="sm")

查看文件

@@ -128,6 +128,14 @@ function gpt_academic_change_chatbot_font(fontfamily, fontsize, fontcolor) {
} }
} }
function footer_show_hide(show) {
if (show) {
document.querySelector('footer').style.display = '';
} else {
document.querySelector('footer').style.display = 'none';
}
}
async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) { async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) {
// 第一部分,布局初始化 // 第一部分,布局初始化
remove_legacy_cookie(); remove_legacy_cookie();
@@ -179,6 +187,7 @@ async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) {
} }
} }
} }
// 字体 // 字体
gpt_academic_gradio_saveload("load", "elem_fontfamily", "js_fontfamily", null, "str"); gpt_academic_gradio_saveload("load", "elem_fontfamily", "js_fontfamily", null, "str");
gpt_academic_change_chatbot_font(getCookie("js_fontfamily"), null, null); gpt_academic_change_chatbot_font(getCookie("js_fontfamily"), null, null);
@@ -205,7 +214,93 @@ async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) {
} }
if (getCookie("js_show_title")) {
// have cookie
bool_value = getCookie("js_show_title")
bool_value = bool_value == "True";
searchString = "主标题";
tool_bar_group = "cbsc";
const true_function = function () {
document.querySelector('.prose.svelte-1ybaih5 h1').style.display = '';
}
const false_function = function () {
document.querySelector('.prose.svelte-1ybaih5 h1').style.display = 'none';
}
if (bool_value) {
// make btns appear
true_function();
// deal with checkboxes
let arr_with_clear_btn = update_array(
await get_data_from_gradio_component(tool_bar_group), searchString, "add"
)
push_data_to_gradio_component(arr_with_clear_btn, tool_bar_group, "no_conversion");
} else {
false_function();
// deal with checkboxes
let arr_without_clear_btn = update_array(
await get_data_from_gradio_component(tool_bar_group), searchString, "remove"
)
push_data_to_gradio_component(arr_without_clear_btn, tool_bar_group, "no_conversion");
}
}
if (getCookie("js_show_subtitle")) {
// have cookie
bool_value = getCookie("js_show_subtitle")
bool_value = bool_value == "True";
searchString = "副标题";
tool_bar_group = "cbsc";
const true_function = function () {
element = document.querySelector('.prose.svelte-1ybaih5 h2');
if (element) element.style.display = '';
element = document.querySelector('.prose.svelte-1ybaih5 h6');
if (element) element.style.display = '';
}
const false_function = function () {
element = document.querySelector('.prose.svelte-1ybaih5 h2');
if (element) element.style.display = 'none';
element = document.querySelector('.prose.svelte-1ybaih5 h6');
if (element) element.style.display = 'none';
}
if (bool_value) {
// make btns appear
true_function();
// deal with checkboxes
let arr_with_clear_btn = update_array(
await get_data_from_gradio_component(tool_bar_group), searchString, "add"
)
push_data_to_gradio_component(arr_with_clear_btn, tool_bar_group, "no_conversion");
} else {
false_function();
// deal with checkboxes
let arr_without_clear_btn = update_array(
await get_data_from_gradio_component(tool_bar_group), searchString, "remove"
)
push_data_to_gradio_component(arr_without_clear_btn, tool_bar_group, "no_conversion");
}
}
if (getCookie("js_show_footer")) {
// have cookie
bool_value = getCookie("js_show_footer")
searchString = "显示logo";
tool_bar_group = "cbsc";
bool_value = bool_value == "True";
if (bool_value) {
// make btns appear
footer_show_hide(true);
// deal with checkboxes
let arr_with_clear_btn = update_array(
await get_data_from_gradio_component(tool_bar_group), searchString, "add"
)
push_data_to_gradio_component(arr_with_clear_btn, tool_bar_group, "no_conversion");
} else {
footer_show_hide(false);
// deal with checkboxes
let arr_without_clear_btn = update_array(
await get_data_from_gradio_component(tool_bar_group), searchString, "remove"
)
push_data_to_gradio_component(arr_without_clear_btn, tool_bar_group, "no_conversion");
}
}
// clearButton 自动清除按钮 // clearButton 自动清除按钮
if (getCookie("js_clearbtn_show_cookie")) { if (getCookie("js_clearbtn_show_cookie")) {
// have cookie // have cookie
@@ -219,7 +314,7 @@ async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) {
let clearButton2 = document.getElementById("elem_clear2"); clearButton2.style.display = "block"; let clearButton2 = document.getElementById("elem_clear2"); clearButton2.style.display = "block";
// deal with checkboxes // deal with checkboxes
let arr_with_clear_btn = update_array( let arr_with_clear_btn = update_array(
await get_data_from_gradio_component('cbs'), "输入清除键", "add" await get_data_from_gradio_component("cbs"), "输入清除键", "add"
) )
push_data_to_gradio_component(arr_with_clear_btn, "cbs", "no_conversion"); push_data_to_gradio_component(arr_with_clear_btn, "cbs", "no_conversion");
} else { } else {
@@ -228,7 +323,7 @@ async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) {
let clearButton2 = document.getElementById("elem_clear2"); clearButton2.style.display = "none"; let clearButton2 = document.getElementById("elem_clear2"); clearButton2.style.display = "none";
// deal with checkboxes // deal with checkboxes
let arr_without_clear_btn = update_array( let arr_without_clear_btn = update_array(
await get_data_from_gradio_component('cbs'), "输入清除键", "remove" await get_data_from_gradio_component("cbs"), "输入清除键", "remove"
) )
push_data_to_gradio_component(arr_without_clear_btn, "cbs", "no_conversion"); push_data_to_gradio_component(arr_without_clear_btn, "cbs", "no_conversion");
} }
@@ -268,3 +363,47 @@ async function GptAcademicJavaScriptInit(dark, prompt, live2d, layout, tts) {
change_theme("", "") change_theme("", "")
} }
function apply_checkbox_change_for_group2(display_panel_arr) {
setTimeout(() => {
display_panel_arr = get_checkbox_selected_items("cbsc");
let searchString = "添加Live2D形象";
if (display_panel_arr.includes(searchString)) {
setCookie("js_live2d_show_cookie", "True", 365);
loadLive2D();
} else {
try {
setCookie("js_live2d_show_cookie", "False", 365);
$('.waifu').hide();
} catch (e) {
}
}
function handleDisplay(searchString, key, displayElement, showFn, hideFn) {
if (display_panel_arr.includes(searchString)) {
setCookie(key, "True", 365);
if (showFn) showFn();
if (displayElement) displayElement.style.display = '';
} else {
setCookie(key, "False", 365);
if (hideFn) hideFn();
if (displayElement) displayElement.style.display = 'none';
}
}
// 主标题
const mainTitle = document.querySelector('.prose.svelte-1ybaih5 h1');
handleDisplay("主标题", "js_show_title", mainTitle, null, null);
// 副标题
const subTitle = document.querySelector('.prose.svelte-1ybaih5 h2');
handleDisplay("副标题", "js_show_subtitle", subTitle, null, null);
// 显示logo
handleDisplay("显示logo", "js_show_footer", null, () => footer_show_hide(true), () => footer_show_hide(false));
}, 50);
}

查看文件

@@ -141,23 +141,3 @@ setTimeout(() => {
} }
""" """
js_code_show_or_hide_group2 = """
(display_panel_arr)=>{
setTimeout(() => {
display_panel_arr = get_checkbox_selected_items("cbsc");
let searchString = "添加Live2D形象";
let ele = "none";
if (display_panel_arr.includes(searchString)) {
setCookie("js_live2d_show_cookie", "True", 365);
loadLive2D();
} else {
setCookie("js_live2d_show_cookie", "False", 365);
$('.waifu').hide();
}
}, 50);
}
"""