镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 14:36:48 +00:00
unify mutex button manifest
这个提交包含在:
@@ -2,7 +2,6 @@ from toolbox import HotReload # HotReload 的意思是热更新,修改函数
|
|||||||
from toolbox import trimmed_format_exc
|
from toolbox import trimmed_format_exc
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|
||||||
def get_crazy_functions():
|
def get_crazy_functions():
|
||||||
from crazy_functions.读文章写摘要 import 读文章写摘要
|
from crazy_functions.读文章写摘要 import 读文章写摘要
|
||||||
from crazy_functions.生成函数注释 import 批量生成函数注释
|
from crazy_functions.生成函数注释 import 批量生成函数注释
|
||||||
@@ -728,12 +727,6 @@ def get_crazy_functions():
|
|||||||
logger.error("Load function plugin failed")
|
logger.error("Load function plugin failed")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# from crazy_functions.高级功能函数模板 import 测试图表渲染
|
# from crazy_functions.高级功能函数模板 import 测试图表渲染
|
||||||
# function_plugins.update({
|
# function_plugins.update({
|
||||||
@@ -748,19 +741,6 @@ def get_crazy_functions():
|
|||||||
# logger.error(trimmed_format_exc())
|
# logger.error(trimmed_format_exc())
|
||||||
# print('Load function plugin failed')
|
# print('Load function plugin failed')
|
||||||
|
|
||||||
# try:
|
|
||||||
# from crazy_functions.chatglm微调工具 import 微调数据集生成
|
|
||||||
# function_plugins.update({
|
|
||||||
# "黑盒模型学习: 微调数据集生成 (先上传数据集)": {
|
|
||||||
# "Color": "stop",
|
|
||||||
# "AsButton": False,
|
|
||||||
# "AdvancedArgs": True,
|
|
||||||
# "ArgsReminder": "针对数据集输入(如 绿帽子*深蓝色衬衫*黑色运动裤)给出指令,例如您可以将以下命令复制到下方: --llm_to_learn=azure-gpt-3.5 --prompt_prefix='根据下面的服装类型提示,想象一个穿着者,对这个人外貌、身处的环境、内心世界、过去经历进行描写。要求:100字以内,用第二人称。' --system_prompt=''",
|
|
||||||
# "Function": HotReload(微调数据集生成)
|
|
||||||
# }
|
|
||||||
# })
|
|
||||||
# except:
|
|
||||||
# print('Load function plugin failed')
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
设置默认值:
|
设置默认值:
|
||||||
@@ -780,3 +760,23 @@ def get_crazy_functions():
|
|||||||
function_plugins[name]["Color"] = "secondary"
|
function_plugins[name]["Color"] = "secondary"
|
||||||
|
|
||||||
return function_plugins
|
return function_plugins
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_multiplex_button_functions():
|
||||||
|
"""多路复用主提交按钮的功能映射
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"常规对话":
|
||||||
|
"",
|
||||||
|
|
||||||
|
"多模型对话":
|
||||||
|
"询问多个GPT模型", # 映射到上面的 `询问多个GPT模型` 插件
|
||||||
|
|
||||||
|
"智能召回 RAG":
|
||||||
|
"Rag智能召回", # 映射到上面的 `Rag智能召回` 插件
|
||||||
|
|
||||||
|
"多媒体查询":
|
||||||
|
"多媒体智能体", # 映射到上面的 `多媒体智能体` 插件
|
||||||
|
}
|
||||||
|
|||||||
9
main.py
9
main.py
@@ -68,7 +68,7 @@ def main():
|
|||||||
functional = get_core_functions()
|
functional = get_core_functions()
|
||||||
|
|
||||||
# 高级函数插件
|
# 高级函数插件
|
||||||
from crazy_functional import get_crazy_functions
|
from crazy_functional import get_crazy_functions, get_multiplex_button_functions
|
||||||
DEFAULT_FN_GROUPS = get_conf('DEFAULT_FN_GROUPS')
|
DEFAULT_FN_GROUPS = get_conf('DEFAULT_FN_GROUPS')
|
||||||
plugins = get_crazy_functions()
|
plugins = get_crazy_functions()
|
||||||
all_plugin_groups = list(set([g for _, plugin in plugins.items() for g in plugin['Group'].split('|')]))
|
all_plugin_groups = list(set([g for _, plugin in plugins.items() for g in plugin['Group'].split('|')]))
|
||||||
@@ -114,12 +114,7 @@ def main():
|
|||||||
with gr.Row(elem_id="gpt-submit-row"):
|
with gr.Row(elem_id="gpt-submit-row"):
|
||||||
multiplex_submit_btn = gr.Button("提交", elem_id="elem_submit_visible", variant="primary")
|
multiplex_submit_btn = gr.Button("提交", elem_id="elem_submit_visible", variant="primary")
|
||||||
multiplex_sel = gr.Dropdown(
|
multiplex_sel = gr.Dropdown(
|
||||||
choices=[
|
choices=get_multiplex_button_functions().keys(), value="常规对话",
|
||||||
"常规对话",
|
|
||||||
"多模型对话",
|
|
||||||
"智能召回 RAG",
|
|
||||||
# "智能上下文",
|
|
||||||
], value="常规对话",
|
|
||||||
interactive=True, label='', show_label=False,
|
interactive=True, label='', show_label=False,
|
||||||
elem_classes='normal_mut_select', elem_id="gpt-submit-dropdown").style(container=False)
|
elem_classes='normal_mut_select', elem_id="gpt-submit-dropdown").style(container=False)
|
||||||
submit_btn = gr.Button("提交", elem_id="elem_submit", variant="primary", visible=False)
|
submit_btn = gr.Button("提交", elem_id="elem_submit", variant="primary", visible=False)
|
||||||
|
|||||||
@@ -1349,16 +1349,9 @@ async function multiplex_function_begin(multiplex_sel) {
|
|||||||
click_real_submit_btn();
|
click_real_submit_btn();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (multiplex_sel === "多模型对话") {
|
|
||||||
let _align_name_in_crazy_function_py = "询问多个GPT模型";
|
// do not delete `REPLACE_EXTENDED_MULTIPLEX_FUNCTIONS_HERE`! It will be read and replaced by Python code.
|
||||||
call_plugin_via_name(_align_name_in_crazy_function_py);
|
// REPLACE_EXTENDED_MULTIPLEX_FUNCTIONS_HERE
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (multiplex_sel === "智能召回 RAG") {
|
|
||||||
let _align_name_in_crazy_function_py = "Rag智能召回";
|
|
||||||
call_plugin_via_name(_align_name_in_crazy_function_py);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async function run_multiplex_shift(multiplex_sel){
|
async function run_multiplex_shift(multiplex_sel){
|
||||||
let key = multiplex_sel;
|
let key = multiplex_sel;
|
||||||
|
|||||||
@@ -2,6 +2,25 @@ from functools import lru_cache
|
|||||||
from toolbox import get_conf
|
from toolbox import get_conf
|
||||||
CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf("CODE_HIGHLIGHT", "ADD_WAIFU", "LAYOUT")
|
CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf("CODE_HIGHLIGHT", "ADD_WAIFU", "LAYOUT")
|
||||||
|
|
||||||
|
def inject_mutex_button_code(js_content):
|
||||||
|
from crazy_functional import get_multiplex_button_functions
|
||||||
|
fns = get_multiplex_button_functions()
|
||||||
|
|
||||||
|
template = """
|
||||||
|
if (multiplex_sel === "{x}") {
|
||||||
|
let _align_name_in_crazy_function_py = "{y}";
|
||||||
|
call_plugin_via_name(_align_name_in_crazy_function_py);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
replacement = ""
|
||||||
|
for fn in fns.keys():
|
||||||
|
if fn == "常规对话": continue
|
||||||
|
replacement += template.replace("{x}", fn).replace("{y}", fns[fn])
|
||||||
|
js_content = js_content.replace("// REPLACE_EXTENDED_MULTIPLEX_FUNCTIONS_HERE", replacement)
|
||||||
|
return js_content
|
||||||
|
|
||||||
def minimize_js(common_js_path):
|
def minimize_js(common_js_path):
|
||||||
try:
|
try:
|
||||||
import rjsmin, hashlib, glob, os
|
import rjsmin, hashlib, glob, os
|
||||||
@@ -12,6 +31,8 @@ def minimize_js(common_js_path):
|
|||||||
c_jsmin = rjsmin.jsmin
|
c_jsmin = rjsmin.jsmin
|
||||||
with open(common_js_path, "r") as f:
|
with open(common_js_path, "r") as f:
|
||||||
js_content = f.read()
|
js_content = f.read()
|
||||||
|
if common_js_path == "themes/common.js":
|
||||||
|
js_content = inject_mutex_button_code(js_content)
|
||||||
minimized_js_content = c_jsmin(js_content)
|
minimized_js_content = c_jsmin(js_content)
|
||||||
# compute sha256 hash of minimized js content
|
# compute sha256 hash of minimized js content
|
||||||
sha_hash = hashlib.sha256(minimized_js_content.encode()).hexdigest()[:8]
|
sha_hash = hashlib.sha256(minimized_js_content.encode()).hexdigest()[:8]
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户