镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
update
这个提交包含在:
131
app.py
131
app.py
@@ -1,9 +1,9 @@
|
||||
import os; os.environ['no_proxy'] = '*' # 避免代理网络产生意外污染
|
||||
|
||||
help_menu_description = \
|
||||
"""Github源代码开源和更新[地址🚀](https://github.com/binary-husky/gpt_academic),
|
||||
"""Github源代码开源和更新[地址🚀](https://github.com/binary-husky/gpt_academic),
|
||||
感谢热情的[开发者们❤️](https://github.com/binary-husky/gpt_academic/graphs/contributors).
|
||||
</br></br>常见问题请查阅[项目Wiki](https://github.com/binary-husky/gpt_academic/wiki),
|
||||
</br></br>常见问题请查阅[项目Wiki](https://github.com/binary-husky/gpt_academic/wiki),
|
||||
如遇到Bug请前往[Bug反馈](https://github.com/binary-husky/gpt_academic/issues).
|
||||
</br></br>普通对话使用说明: 1. 输入问题; 2. 点击提交
|
||||
</br></br>基础功能区使用说明: 1. 输入文本; 2. 点击任意基础功能区按钮
|
||||
@@ -15,27 +15,27 @@ help_menu_description = \
|
||||
|
||||
def main():
|
||||
import subprocess, sys
|
||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'https://fastly.jsdelivr.net/gh/binary-husky/gradio-fix@gpt-academic/release/gradio-3.32.7-py3-none-any.whl'])
|
||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'https://public.agent-matrix.com/publish/gradio-3.32.8-py3-none-any.whl'])
|
||||
import gradio as gr
|
||||
if gr.__version__ not in ['3.32.6', '3.32.7']:
|
||||
if gr.__version__ not in ['3.32.8']:
|
||||
raise ModuleNotFoundError("使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements.txt.")
|
||||
from request_llms.bridge_all import predict
|
||||
from toolbox import format_io, find_free_port, on_file_uploaded, on_report_generated, get_conf, ArgsGeneralWrapper, load_chat_cookies, DummyWith
|
||||
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址
|
||||
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION')
|
||||
CHATBOT_HEIGHT, LAYOUT, AVAIL_LLM_MODELS, AUTO_CLEAR_TXT = get_conf('CHATBOT_HEIGHT', 'LAYOUT', 'AVAIL_LLM_MODELS', 'AUTO_CLEAR_TXT')
|
||||
ENABLE_AUDIO, AUTO_CLEAR_TXT, PATH_LOGGING, AVAIL_THEMES, THEME = get_conf('ENABLE_AUDIO', 'AUTO_CLEAR_TXT', 'PATH_LOGGING', 'AVAIL_THEMES', 'THEME')
|
||||
ENABLE_AUDIO, AUTO_CLEAR_TXT, PATH_LOGGING, AVAIL_THEMES, THEME, ADD_WAIFU = get_conf('ENABLE_AUDIO', 'AUTO_CLEAR_TXT', 'PATH_LOGGING', 'AVAIL_THEMES', 'THEME', 'ADD_WAIFU')
|
||||
DARK_MODE, NUM_CUSTOM_BASIC_BTN, SSL_KEYFILE, SSL_CERTFILE = get_conf('DARK_MODE', 'NUM_CUSTOM_BASIC_BTN', 'SSL_KEYFILE', 'SSL_CERTFILE')
|
||||
INIT_SYS_PROMPT = get_conf('INIT_SYS_PROMPT')
|
||||
|
||||
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
||||
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
||||
from check_proxy import get_current_version
|
||||
from themes.theme import adjust_theme, advanced_css, theme_declaration
|
||||
from themes.theme import js_code_for_css_changing, js_code_for_darkmode_init, js_code_for_toggle_darkmode, js_code_for_persistent_cookie_init
|
||||
from themes.theme import adjust_theme, advanced_css, theme_declaration, js_code_clear, js_code_reset, js_code_show_or_hide, js_code_show_or_hide_group2
|
||||
from themes.theme import js_code_for_css_changing, js_code_for_toggle_darkmode, js_code_for_persistent_cookie_init
|
||||
from themes.theme import load_dynamic_theme, to_cookie_str, from_cookie_str, init_cookie
|
||||
title_html = f"<h1 align=\"center\">GPT 学术优化 {get_current_version()}</h1>{theme_declaration}"
|
||||
|
||||
|
||||
# 问询记录, python 版本建议3.9+(越新越好)
|
||||
import logging, uuid
|
||||
os.makedirs(PATH_LOGGING, exist_ok=True)
|
||||
@@ -67,7 +67,7 @@ def main():
|
||||
proxy_info = check_proxy(proxies)
|
||||
|
||||
gr_L1 = lambda: gr.Row().style()
|
||||
gr_L2 = lambda scale, elem_id: gr.Column(scale=scale, elem_id=elem_id)
|
||||
gr_L2 = lambda scale, elem_id: gr.Column(scale=scale, elem_id=elem_id, min_width=400)
|
||||
if LAYOUT == "TOP-DOWN":
|
||||
gr_L1 = lambda: DummyWith()
|
||||
gr_L2 = lambda scale, elem_id: gr.Row()
|
||||
@@ -79,7 +79,7 @@ def main():
|
||||
with gr.Blocks(title="GPT 学术优化", theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
|
||||
gr.HTML(title_html)
|
||||
gr.HTML('''<center><a href="https://huggingface.co/spaces/qingxu98/gpt-academic?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>请您打开此页面后务必点击上方的“复制空间”(Duplicate Space)按钮!<font color="#FF00FF">使用时,先在输入框填入API-KEY然后回车。</font><br/>切忌在“复制空间”(Duplicate Space)之前填入API_KEY或进行提问,否则您的API_KEY将极可能被空间所有者攫取!<br/>支持任意数量的OpenAI的密钥和API2D的密钥共存,例如输入"OpenAI密钥1,API2D密钥2",然后提交,即可同时使用两种模型接口。</center>''')
|
||||
secret_css, dark_mode, persistent_cookie = gr.Textbox(visible=False), gr.Textbox(DARK_MODE, visible=False), gr.Textbox(visible=False)
|
||||
secret_css, dark_mode, py_pickle_cookie = gr.Textbox(visible=False), gr.Textbox(DARK_MODE, visible=False), gr.Textbox(visible=False)
|
||||
cookies = gr.State(load_chat_cookies())
|
||||
with gr_L1():
|
||||
with gr_L2(scale=2, elem_id="gpt-chat"):
|
||||
@@ -96,11 +96,12 @@ def main():
|
||||
resetBtn = gr.Button("重置", elem_id="elem_reset", variant="secondary"); resetBtn.style(size="sm")
|
||||
stopBtn = gr.Button("停止", elem_id="elem_stop", variant="secondary"); stopBtn.style(size="sm")
|
||||
clearBtn = gr.Button("清除", elem_id="elem_clear", variant="secondary", visible=False); clearBtn.style(size="sm")
|
||||
if ENABLE_AUDIO:
|
||||
if ENABLE_AUDIO:
|
||||
with gr.Row():
|
||||
audio_mic = gr.Audio(source="microphone", type="numpy", elem_id="elem_audio", streaming=True, show_label=False).style(container=False)
|
||||
with gr.Row():
|
||||
status = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行。当前模型: {LLM_MODEL} \n {proxy_info}", elem_id="state-panel")
|
||||
|
||||
with gr.Accordion("基础功能区", open=True, elem_id="basic-panel") as area_basic_fn:
|
||||
with gr.Row():
|
||||
for k in range(NUM_CUSTOM_BASIC_BTN):
|
||||
@@ -117,7 +118,7 @@ def main():
|
||||
with gr.Row():
|
||||
gr.Markdown("插件可读取“输入区”文本/路径作为参数(上传文件自动修正路径)")
|
||||
with gr.Row(elem_id="input-plugin-group"):
|
||||
plugin_group_sel = gr.Dropdown(choices=all_plugin_groups, label='', show_label=False, value=DEFAULT_FN_GROUPS,
|
||||
plugin_group_sel = gr.Dropdown(choices=all_plugin_groups, label='', show_label=False, value=DEFAULT_FN_GROUPS,
|
||||
multiselect=True, interactive=True, elem_classes='normal_mut_select').style(container=False)
|
||||
with gr.Row():
|
||||
for k, plugin in plugins.items():
|
||||
@@ -125,7 +126,7 @@ def main():
|
||||
visible = True if match_group(plugin['Group'], DEFAULT_FN_GROUPS) else False
|
||||
variant = plugins[k]["Color"] if "Color" in plugin else "secondary"
|
||||
info = plugins[k].get("Info", k)
|
||||
plugin['Button'] = plugins[k]['Button'] = gr.Button(k, variant=variant,
|
||||
plugin['Button'] = plugins[k]['Button'] = gr.Button(k, variant=variant,
|
||||
visible=visible, info_str=f'函数插件区: {info}').style(size="sm")
|
||||
with gr.Row():
|
||||
with gr.Accordion("更多函数插件", open=True):
|
||||
@@ -137,7 +138,7 @@ def main():
|
||||
with gr.Row():
|
||||
dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="", show_label=False).style(container=False)
|
||||
with gr.Row():
|
||||
plugin_advanced_arg = gr.Textbox(show_label=True, label="高级参数输入区", visible=False,
|
||||
plugin_advanced_arg = gr.Textbox(show_label=True, label="高级参数输入区", visible=False,
|
||||
placeholder="这里是特殊函数插件的高级参数输入区").style(container=False)
|
||||
with gr.Row():
|
||||
switchy_bt = gr.Button(r"请先从插件列表中选择", variant="secondary").style(size="sm")
|
||||
@@ -145,13 +146,12 @@ def main():
|
||||
with gr.Accordion("点击展开“文件下载区”。", open=False) as area_file_up:
|
||||
file_upload = gr.Files(label="任何文件, 推荐上传压缩文件(zip, tar)", file_count="multiple", elem_id="elem_upload")
|
||||
|
||||
|
||||
with gr.Floating(init_x="0%", init_y="0%", visible=True, width=None, drag="forbidden", elem_id="tooltip"):
|
||||
with gr.Row():
|
||||
with gr.Tab("上传文件", elem_id="interact-panel"):
|
||||
gr.Markdown("请上传本地文件/压缩包供“函数插件区”功能调用。请注意: 上传文件后会自动把输入区修改为相应路径。")
|
||||
file_upload_2 = gr.Files(label="任何文件, 推荐上传压缩文件(zip, tar)", file_count="multiple", elem_id="elem_upload_float")
|
||||
|
||||
|
||||
with gr.Tab("更换模型", elem_id="interact-panel"):
|
||||
md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="更换LLM模型/请求源").style(container=False)
|
||||
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
|
||||
@@ -161,10 +161,11 @@ def main():
|
||||
|
||||
with gr.Tab("界面外观", elem_id="interact-panel"):
|
||||
theme_dropdown = gr.Dropdown(AVAIL_THEMES, value=THEME, label="更换UI主题").style(container=False)
|
||||
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "浮动输入区", "输入清除键", "插件参数区"],
|
||||
value=["基础功能区", "函数插件区"], label="显示/隐藏功能区", elem_id='cbs').style(container=False)
|
||||
checkboxes_2 = gr.CheckboxGroup(["自定义菜单"],
|
||||
value=[], label="显示/隐藏自定义菜单", elem_id='cbsc').style(container=False)
|
||||
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "浮动输入区", "输入清除键", "插件参数区"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区", elem_id='cbs').style(container=False)
|
||||
opt = ["自定义菜单"]
|
||||
value=[]
|
||||
if ADD_WAIFU: opt += ["添加Live2D形象"]; value += ["添加Live2D形象"]
|
||||
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.click(None, None, None, _js=js_code_for_toggle_darkmode)
|
||||
with gr.Tab("帮助", elem_id="interact-panel"):
|
||||
@@ -181,7 +182,7 @@ def main():
|
||||
submitBtn2 = gr.Button("提交", variant="primary"); submitBtn2.style(size="sm")
|
||||
resetBtn2 = gr.Button("重置", variant="secondary"); resetBtn2.style(size="sm")
|
||||
stopBtn2 = gr.Button("停止", variant="secondary"); stopBtn2.style(size="sm")
|
||||
clearBtn2 = gr.Button("清除", variant="secondary", visible=False); clearBtn2.style(size="sm")
|
||||
clearBtn2 = gr.Button("清除", elem_id="elem_clear2", variant="secondary", visible=False); clearBtn2.style(size="sm")
|
||||
|
||||
|
||||
with gr.Floating(init_x="20%", init_y="50%", visible=False, width="40%", drag="top") as area_customize:
|
||||
@@ -195,10 +196,12 @@ def main():
|
||||
basic_fn_suffix = gr.Textbox(show_label=False, placeholder="输入新提示后缀", lines=4).style(container=False)
|
||||
with gr.Column(scale=1, min_width=70):
|
||||
basic_fn_confirm = gr.Button("确认并保存", variant="primary"); basic_fn_confirm.style(size="sm")
|
||||
basic_fn_load = gr.Button("加载已保存", variant="primary"); basic_fn_load.style(size="sm")
|
||||
def assign_btn(persistent_cookie_, cookies_, basic_btn_dropdown_, basic_fn_title, basic_fn_prefix, basic_fn_suffix):
|
||||
basic_fn_clean = gr.Button("恢复默认", variant="primary"); basic_fn_clean.style(size="sm")
|
||||
def assign_btn(persistent_cookie_, cookies_, basic_btn_dropdown_, basic_fn_title, basic_fn_prefix, basic_fn_suffix, clean_up=False):
|
||||
ret = {}
|
||||
# 读取之前的自定义按钮
|
||||
customize_fn_overwrite_ = cookies_['customize_fn_overwrite']
|
||||
# 更新新的自定义按钮
|
||||
customize_fn_overwrite_.update({
|
||||
basic_btn_dropdown_:
|
||||
{
|
||||
@@ -208,27 +211,41 @@ def main():
|
||||
}
|
||||
}
|
||||
)
|
||||
cookies_.update(customize_fn_overwrite_)
|
||||
if clean_up:
|
||||
customize_fn_overwrite_ = {}
|
||||
cookies_.update(customize_fn_overwrite_) # 更新cookie
|
||||
visible = (not clean_up) and (basic_fn_title != "")
|
||||
if basic_btn_dropdown_ in customize_btns:
|
||||
ret.update({customize_btns[basic_btn_dropdown_]: gr.update(visible=True, value=basic_fn_title)})
|
||||
# 是自定义按钮,不是预定义按钮
|
||||
ret.update({customize_btns[basic_btn_dropdown_]: gr.update(visible=visible, value=basic_fn_title)})
|
||||
else:
|
||||
ret.update({predefined_btns[basic_btn_dropdown_]: gr.update(visible=True, value=basic_fn_title)})
|
||||
# 是预定义按钮
|
||||
ret.update({predefined_btns[basic_btn_dropdown_]: gr.update(visible=visible, value=basic_fn_title)})
|
||||
ret.update({cookies: cookies_})
|
||||
try: persistent_cookie_ = from_cookie_str(persistent_cookie_) # persistent cookie to dict
|
||||
except: persistent_cookie_ = {}
|
||||
persistent_cookie_["custom_bnt"] = customize_fn_overwrite_ # dict update new value
|
||||
persistent_cookie_ = to_cookie_str(persistent_cookie_) # persistent cookie to dict
|
||||
ret.update({persistent_cookie: persistent_cookie_}) # write persistent cookie
|
||||
ret.update({py_pickle_cookie: persistent_cookie_}) # write persistent cookie
|
||||
return ret
|
||||
|
||||
def reflesh_btn(persistent_cookie_, cookies_):
|
||||
|
||||
# update btn
|
||||
h = basic_fn_confirm.click(assign_btn, [py_pickle_cookie, cookies, basic_btn_dropdown, basic_fn_title, basic_fn_prefix, basic_fn_suffix],
|
||||
[py_pickle_cookie, cookies, *customize_btns.values(), *predefined_btns.values()])
|
||||
h.then(None, [py_pickle_cookie], None, _js="""(py_pickle_cookie)=>{setCookie("py_pickle_cookie", py_pickle_cookie, 365);}""")
|
||||
# clean up btn
|
||||
h2 = basic_fn_clean.click(assign_btn, [py_pickle_cookie, cookies, basic_btn_dropdown, basic_fn_title, basic_fn_prefix, basic_fn_suffix, gr.State(True)],
|
||||
[py_pickle_cookie, cookies, *customize_btns.values(), *predefined_btns.values()])
|
||||
h2.then(None, [py_pickle_cookie], None, _js="""(py_pickle_cookie)=>{setCookie("py_pickle_cookie", py_pickle_cookie, 365);}""")
|
||||
|
||||
def persistent_cookie_reload(persistent_cookie_, cookies_):
|
||||
ret = {}
|
||||
for k in customize_btns:
|
||||
ret.update({customize_btns[k]: gr.update(visible=False, value="")})
|
||||
|
||||
try: persistent_cookie_ = from_cookie_str(persistent_cookie_) # persistent cookie to dict
|
||||
except: return ret
|
||||
|
||||
|
||||
customize_fn_overwrite_ = persistent_cookie_.get("custom_bnt", {})
|
||||
cookies_['customize_fn_overwrite'] = customize_fn_overwrite_
|
||||
ret.update({cookies: cookies_})
|
||||
@@ -238,26 +255,17 @@ def main():
|
||||
if k in customize_btns: ret.update({customize_btns[k]: gr.update(visible=True, value=v['Title'])})
|
||||
else: ret.update({predefined_btns[k]: gr.update(visible=True, value=v['Title'])})
|
||||
return ret
|
||||
|
||||
basic_fn_load.click(reflesh_btn, [persistent_cookie, cookies], [cookies, *customize_btns.values(), *predefined_btns.values()])
|
||||
h = basic_fn_confirm.click(assign_btn, [persistent_cookie, cookies, basic_btn_dropdown, basic_fn_title, basic_fn_prefix, basic_fn_suffix],
|
||||
[persistent_cookie, cookies, *customize_btns.values(), *predefined_btns.values()])
|
||||
# save persistent cookie
|
||||
h.then(None, [persistent_cookie], None, _js="""(persistent_cookie)=>{setCookie("persistent_cookie", persistent_cookie, 5);}""")
|
||||
|
||||
# 功能区显示开关与功能区的互动
|
||||
def fn_area_visibility(a):
|
||||
ret = {}
|
||||
ret.update({area_basic_fn: gr.update(visible=("基础功能区" in a))})
|
||||
ret.update({area_crazy_fn: gr.update(visible=("函数插件区" in a))})
|
||||
ret.update({area_input_primary: gr.update(visible=("浮动输入区" not in a))})
|
||||
ret.update({area_input_secondary: gr.update(visible=("浮动输入区" in a))})
|
||||
ret.update({clearBtn: gr.update(visible=("输入清除键" in a))})
|
||||
ret.update({clearBtn2: gr.update(visible=("输入清除键" in a))})
|
||||
ret.update({plugin_advanced_arg: gr.update(visible=("插件参数区" in a))})
|
||||
if "浮动输入区" in a: ret.update({txt: gr.update(value="")})
|
||||
return ret
|
||||
checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn, area_input_primary, area_input_secondary, txt, txt2, clearBtn, clearBtn2, plugin_advanced_arg] )
|
||||
checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn, area_input_primary, area_input_secondary, txt, txt2, plugin_advanced_arg] )
|
||||
checkboxes.select(None, [checkboxes], None, _js=js_code_show_or_hide)
|
||||
|
||||
# 功能区显示开关与功能区的互动
|
||||
def fn_area_visibility_2(a):
|
||||
@@ -265,6 +273,7 @@ def main():
|
||||
ret.update({area_customize: gr.update(visible=("自定义菜单" in a))})
|
||||
return ret
|
||||
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)
|
||||
|
||||
# 整理反复出现的控件句柄组合
|
||||
input_combo = [cookies, max_length_sl, md_dropdown, txt, txt2, top_p, temperature, chatbot, history, system_prompt, plugin_advanced_arg]
|
||||
@@ -275,15 +284,17 @@ def main():
|
||||
cancel_handles.append(txt2.submit(**predict_args))
|
||||
cancel_handles.append(submitBtn.click(**predict_args))
|
||||
cancel_handles.append(submitBtn2.click(**predict_args))
|
||||
resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, status])
|
||||
resetBtn2.click(lambda: ([], [], "已重置"), None, [chatbot, history, status])
|
||||
clearBtn.click(lambda: ("",""), None, [txt, txt2])
|
||||
clearBtn2.click(lambda: ("",""), None, [txt, txt2])
|
||||
resetBtn.click(None, None, [chatbot, history, status], _js=js_code_reset) # 先在前端快速清除chatbot&status
|
||||
resetBtn2.click(None, None, [chatbot, history, status], _js=js_code_reset) # 先在前端快速清除chatbot&status
|
||||
resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, status]) # 再在后端清除history
|
||||
resetBtn2.click(lambda: ([], [], "已重置"), None, [chatbot, history, status]) # 再在后端清除history
|
||||
clearBtn.click(None, None, [txt, txt2], _js=js_code_clear)
|
||||
clearBtn2.click(None, None, [txt, txt2], _js=js_code_clear)
|
||||
if AUTO_CLEAR_TXT:
|
||||
submitBtn.click(lambda: ("",""), None, [txt, txt2])
|
||||
submitBtn2.click(lambda: ("",""), None, [txt, txt2])
|
||||
txt.submit(lambda: ("",""), None, [txt, txt2])
|
||||
txt2.submit(lambda: ("",""), None, [txt, txt2])
|
||||
submitBtn.click(None, None, [txt, txt2], _js=js_code_clear)
|
||||
submitBtn2.click(None, None, [txt, txt2], _js=js_code_clear)
|
||||
txt.submit(None, None, [txt, txt2], _js=js_code_clear)
|
||||
txt2.submit(None, None, [txt, txt2], _js=js_code_clear)
|
||||
# 基础功能区的回调函数注册
|
||||
for k in functional:
|
||||
if ("Visible" in functional[k]) and (not functional[k]["Visible"]): continue
|
||||
@@ -324,7 +335,7 @@ def main():
|
||||
else:
|
||||
css_part2 = adjust_theme()._get_theme_css()
|
||||
return css_part2 + css_part1
|
||||
|
||||
|
||||
theme_handle = theme_dropdown.select(on_theme_dropdown_changed, [theme_dropdown, secret_css], [secret_css])
|
||||
theme_handle.then(
|
||||
None,
|
||||
@@ -349,13 +360,13 @@ def main():
|
||||
if not group_list: # 处理特殊情况:没有选择任何插件组
|
||||
return [*[plugin['Button'].update(visible=False) for _, plugin in plugins_as_btn.items()], gr.Dropdown.update(choices=[])]
|
||||
for k, plugin in plugins.items():
|
||||
if plugin.get("AsButton", True):
|
||||
if plugin.get("AsButton", True):
|
||||
btn_list.append(plugin['Button'].update(visible=match_group(plugin['Group'], group_list))) # 刷新按钮
|
||||
if plugin.get('AdvancedArgs', False): dropdown_fn_list.append(k) # 对于需要高级参数的插件,亦在下拉菜单中显示
|
||||
elif match_group(plugin['Group'], group_list): fns_list.append(k) # 刷新下拉列表
|
||||
return [*btn_list, gr.Dropdown.update(choices=fns_list)]
|
||||
plugin_group_sel.select(fn=on_group_change, inputs=[plugin_group_sel], outputs=[*[plugin['Button'] for name, plugin in plugins_as_btn.items()], dropdown])
|
||||
if ENABLE_AUDIO:
|
||||
if ENABLE_AUDIO:
|
||||
from crazy_functions.live_audio.audio_io import RealtimeAudioDistribution
|
||||
rad = RealtimeAudioDistribution()
|
||||
def deal_audio(audio, cookies):
|
||||
@@ -363,12 +374,12 @@ def main():
|
||||
audio_mic.stream(deal_audio, inputs=[audio_mic, cookies])
|
||||
|
||||
|
||||
demo.load(init_cookie, inputs=[cookies, chatbot], outputs=[cookies])
|
||||
darkmode_js = js_code_for_darkmode_init
|
||||
demo.load(None, inputs=None, outputs=[persistent_cookie], _js=js_code_for_persistent_cookie_init)
|
||||
demo.load(None, inputs=[dark_mode], outputs=None, _js=darkmode_js) # 配置暗色主题或亮色主题
|
||||
demo.load(init_cookie, inputs=[cookies], outputs=[cookies])
|
||||
demo.load(persistent_cookie_reload, inputs = [py_pickle_cookie, cookies],
|
||||
outputs = [py_pickle_cookie, cookies, *customize_btns.values(), *predefined_btns.values()], _js=js_code_for_persistent_cookie_init)
|
||||
demo.load(None, inputs=[dark_mode], outputs=None, _js="""(dark_mode)=>{apply_cookie_for_checkbox(dark_mode);}""") # 配置暗色主题或亮色主题
|
||||
demo.load(None, inputs=[gr.Textbox(LAYOUT, visible=False)], outputs=None, _js='(LAYOUT)=>{GptAcademicJavaScriptInit(LAYOUT);}')
|
||||
|
||||
|
||||
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
|
||||
def run_delayed_tasks():
|
||||
import threading, webbrowser, time
|
||||
@@ -379,7 +390,7 @@ def main():
|
||||
def auto_updates(): time.sleep(0); auto_update()
|
||||
def open_browser(): time.sleep(2); webbrowser.open_new_tab(f"http://localhost:{PORT}")
|
||||
def warm_up_mods(): time.sleep(6); warm_up_modules()
|
||||
|
||||
|
||||
threading.Thread(target=auto_updates, name="self-upgrade", daemon=True).start() # 查看自动更新
|
||||
threading.Thread(target=open_browser, name="open-browser", daemon=True).start() # 打开浏览器页面
|
||||
threading.Thread(target=warm_up_mods, name="warm-up", daemon=True).start() # 预热tiktoken模块
|
||||
@@ -390,10 +401,10 @@ def main():
|
||||
|
||||
# 如果需要在二级路径下运行
|
||||
# CUSTOM_PATH = get_conf('CUSTOM_PATH')
|
||||
# if CUSTOM_PATH != "/":
|
||||
# if CUSTOM_PATH != "/":
|
||||
# from toolbox import run_gradio_in_subpath
|
||||
# run_gradio_in_subpath(demo, auth=AUTHENTICATION, port=PORT, custom_path=CUSTOM_PATH)
|
||||
# else:
|
||||
# else:
|
||||
# demo.launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png",
|
||||
# blocked_paths=["config.py","config_private.py","docker-compose.yml","Dockerfile",f"{PATH_LOGGING}/admin"])
|
||||
|
||||
|
||||
45
config.py
45
config.py
@@ -2,8 +2,8 @@
|
||||
以下所有配置也都支持利用环境变量覆写,环境变量配置格式见docker-compose.yml。
|
||||
读取优先级:环境变量 > config_private.py > config.py
|
||||
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
All the following configurations also support using environment variables to override,
|
||||
and the environment variable configuration format can be seen in docker-compose.yml.
|
||||
All the following configurations also support using environment variables to override,
|
||||
and the environment variable configuration format can be seen in docker-compose.yml.
|
||||
Configuration reading priority: environment variable > config_private.py > config.py
|
||||
"""
|
||||
|
||||
@@ -37,7 +37,7 @@ else:
|
||||
# ------------------------------------ 以下配置可以优化体验, 但大部分场合下并不需要修改 ------------------------------------
|
||||
|
||||
# 重新URL重新定向,实现更换API_URL的作用(高危设置! 常规情况下不要修改! 通过修改此设置,您将把您的API-KEY和对话隐私完全暴露给您设定的中间人!)
|
||||
# 格式: API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "在这里填写重定向的api.openai.com的URL"}
|
||||
# 格式: API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "在这里填写重定向的api.openai.com的URL"}
|
||||
# 举例: API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "https://reverse-proxy-url/v1/chat/completions"}
|
||||
API_URL_REDIRECT = {}
|
||||
|
||||
@@ -93,14 +93,14 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
|
||||
|
||||
|
||||
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
|
||||
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
|
||||
AVAIL_LLM_MODELS = ["gpt-3.5-turbo-1106","gpt-4-1106-preview","gpt-4-vision-preview",
|
||||
"gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
|
||||
"gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4",
|
||||
"gemini-pro", "chatglm3", "claude-2", "zhipuai"]
|
||||
LLM_MODEL = "gpt-3.5-turbo-16k" # 可选 ↓↓↓
|
||||
AVAIL_LLM_MODELS = ["gpt-4-1106-preview", "gpt-4-turbo-preview", "gpt-4-vision-preview",
|
||||
"gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
|
||||
"gpt-4", "gpt-4-32k", "azure-gpt-4", "glm-4", "glm-3-turbo",
|
||||
"gemini-pro", "chatglm3", "claude-2"]
|
||||
# P.S. 其他可用的模型还包括 [
|
||||
# "moss", "qwen-turbo", "qwen-plus", "qwen-max"
|
||||
# "zhipuai", "qianfan", "deepseekcoder", "llama2", "qwen-local", "gpt-3.5-turbo-0613",
|
||||
# "zhipuai", "qianfan", "deepseekcoder", "llama2", "qwen-local", "gpt-3.5-turbo-0613",
|
||||
# "gpt-3.5-turbo-16k-0613", "gpt-3.5-random", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k',
|
||||
# "spark", "sparkv2", "sparkv3", "chatglm_onnx", "claude-1-100k", "claude-2", "internlm", "jittorllms_pangualpha", "jittorllms_llama"
|
||||
# ]
|
||||
@@ -165,7 +165,7 @@ API_ORG = ""
|
||||
|
||||
|
||||
# 如果需要使用Slack Claude,使用教程详情见 request_llms/README.md
|
||||
SLACK_CLAUDE_BOT_ID = ''
|
||||
SLACK_CLAUDE_BOT_ID = ''
|
||||
SLACK_CLAUDE_USER_TOKEN = ''
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ XFYUN_API_KEY = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
|
||||
# 接入智谱大模型
|
||||
ZHIPUAI_API_KEY = ""
|
||||
ZHIPUAI_MODEL = "glm-4" # 可选 "glm-3-turbo" "glm-4"
|
||||
ZHIPUAI_MODEL = "" # 此选项已废弃,不再需要填写
|
||||
|
||||
|
||||
# # 火山引擎YUNQUE大模型
|
||||
@@ -215,6 +215,11 @@ ZHIPUAI_MODEL = "glm-4" # 可选 "glm-3-turbo" "glm-4"
|
||||
ANTHROPIC_API_KEY = ""
|
||||
|
||||
|
||||
# Mathpix 拥有执行PDF的OCR功能,但是需要注册账号
|
||||
MATHPIX_APPID = ""
|
||||
MATHPIX_APPKEY = ""
|
||||
|
||||
|
||||
# 自定义API KEY格式
|
||||
CUSTOM_API_KEY_PATTERN = ""
|
||||
|
||||
@@ -231,8 +236,8 @@ HUGGINGFACE_ACCESS_TOKEN = "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"
|
||||
# 获取方法:复制以下空间https://huggingface.co/spaces/qingxu98/grobid,设为public,然后GROBID_URL = "https://(你的hf用户名如qingxu98)-(你的填写的空间名如grobid).hf.space"
|
||||
GROBID_URLS = [
|
||||
"https://qingxu98-grobid.hf.space","https://qingxu98-grobid2.hf.space","https://qingxu98-grobid3.hf.space",
|
||||
"https://qingxu98-grobid4.hf.space","https://qingxu98-grobid5.hf.space", "https://qingxu98-grobid6.hf.space",
|
||||
"https://qingxu98-grobid7.hf.space", "https://qingxu98-grobid8.hf.space",
|
||||
"https://qingxu98-grobid4.hf.space","https://qingxu98-grobid5.hf.space", "https://qingxu98-grobid6.hf.space",
|
||||
"https://qingxu98-grobid7.hf.space", "https://qingxu98-grobid8.hf.space",
|
||||
]
|
||||
|
||||
|
||||
@@ -253,7 +258,7 @@ PATH_LOGGING = "gpt_log"
|
||||
|
||||
|
||||
# 除了连接OpenAI之外,还有哪些场合允许使用代理,请勿修改
|
||||
WHEN_TO_USE_PROXY = ["Download_LLM", "Download_Gradio_Theme", "Connect_Grobid",
|
||||
WHEN_TO_USE_PROXY = ["Download_LLM", "Download_Gradio_Theme", "Connect_Grobid",
|
||||
"Warmup_Modules", "Nougat_Download", "AutoGen"]
|
||||
|
||||
|
||||
@@ -304,9 +309,8 @@ NUM_CUSTOM_BASIC_BTN = 4
|
||||
│ ├── BAIDU_CLOUD_API_KEY
|
||||
│ └── BAIDU_CLOUD_SECRET_KEY
|
||||
│
|
||||
├── "zhipuai" 智谱AI大模型chatglm_turbo
|
||||
│ ├── ZHIPUAI_API_KEY
|
||||
│ └── ZHIPUAI_MODEL
|
||||
├── "glm-4", "glm-3-turbo", "zhipuai" 智谱AI大模型
|
||||
│ └── ZHIPUAI_API_KEY
|
||||
│
|
||||
├── "qwen-turbo" 等通义千问大模型
|
||||
│ └── DASHSCOPE_API_KEY
|
||||
@@ -318,7 +322,7 @@ NUM_CUSTOM_BASIC_BTN = 4
|
||||
├── NEWBING_STYLE
|
||||
└── NEWBING_COOKIES
|
||||
|
||||
|
||||
|
||||
本地大模型示意图
|
||||
│
|
||||
├── "chatglm3"
|
||||
@@ -358,6 +362,9 @@ NUM_CUSTOM_BASIC_BTN = 4
|
||||
│ └── ALIYUN_SECRET
|
||||
│
|
||||
└── PDF文档精准解析
|
||||
└── GROBID_URLS
|
||||
├── GROBID_URLS
|
||||
├── MATHPIX_APPID
|
||||
└── MATHPIX_APPKEY
|
||||
|
||||
|
||||
"""
|
||||
|
||||
@@ -3,18 +3,27 @@
|
||||
# 'stop' 颜色对应 theme.py 中的 color_er
|
||||
import importlib
|
||||
from toolbox import clear_line_break
|
||||
from toolbox import apply_gpt_academic_string_mask_langbased
|
||||
from toolbox import build_gpt_academic_masked_string_langbased
|
||||
from textwrap import dedent
|
||||
|
||||
def get_core_functions():
|
||||
return {
|
||||
|
||||
"英语学术润色": {
|
||||
# [1*] 前缀,会被加在你的输入之前。例如,用来描述你的要求,例如翻译、解释代码、润色等等
|
||||
"Prefix": r"Below is a paragraph from an academic paper. Polish the writing to meet the academic style, "
|
||||
r"improve the spelling, grammar, clarity, concision and overall readability. When necessary, rewrite the whole sentence. "
|
||||
r"Firstly, you should provide the polished paragraph. "
|
||||
r"Secondly, you should list all your modification and explain the reasons to do so in markdown table." + "\n\n",
|
||||
# [2*] 后缀,会被加在你的输入之后。例如,配合前缀可以把你的输入内容用引号圈起来
|
||||
"学术语料润色": {
|
||||
# [1*] 前缀字符串,会被加在你的输入之前。例如,用来描述你的要求,例如翻译、解释代码、润色等等。
|
||||
# 这里填一个提示词字符串就行了,这里为了区分中英文情景搞复杂了一点
|
||||
"Prefix": build_gpt_academic_masked_string_langbased(
|
||||
text_show_english=
|
||||
r"Below is a paragraph from an academic paper. Polish the writing to meet the academic style, "
|
||||
r"improve the spelling, grammar, clarity, concision and overall readability. When necessary, rewrite the whole sentence. "
|
||||
r"Firstly, you should provide the polished paragraph. "
|
||||
r"Secondly, you should list all your modification and explain the reasons to do so in markdown table.",
|
||||
text_show_chinese=
|
||||
r"作为一名中文学术论文写作改进助理,你的任务是改进所提供文本的拼写、语法、清晰、简洁和整体可读性,"
|
||||
r"同时分解长句,减少重复,并提供改进建议。请先提供文本的更正版本,然后在markdown表格中列出修改的内容,并给出修改的理由:"
|
||||
) + "\n\n",
|
||||
# [2*] 后缀字符串,会被加在你的输入之后。例如,配合前缀可以把你的输入内容用引号圈起来
|
||||
"Suffix": r"",
|
||||
# [3] 按钮颜色 (可选参数,默认 secondary)
|
||||
"Color": r"secondary",
|
||||
@@ -32,8 +41,10 @@ def get_core_functions():
|
||||
"Prefix": r"",
|
||||
# 后缀,会被加在你的输入之后。例如,配合前缀可以把你的输入内容用引号圈起来
|
||||
"Suffix":
|
||||
# dedent() 函数用于去除多行字符串的缩进
|
||||
dedent("\n"+r'''
|
||||
==============================
|
||||
|
||||
使用mermaid flowchart对以上文本进行总结,概括上述段落的内容以及内在逻辑关系,例如:
|
||||
|
||||
以下是对以上文本的总结,以mermaid flowchart的形式展示:
|
||||
@@ -83,14 +94,22 @@ def get_core_functions():
|
||||
|
||||
|
||||
"学术英中互译": {
|
||||
"Prefix": r"I want you to act as a scientific English-Chinese translator, " +
|
||||
r"I will provide you with some paragraphs in one language " +
|
||||
r"and your task is to accurately and academically translate the paragraphs only into the other language. " +
|
||||
r"Do not repeat the original provided paragraphs after translation. " +
|
||||
r"You should use artificial intelligence tools, " +
|
||||
r"such as natural language processing, and rhetorical knowledge " +
|
||||
r"and experience about effective writing techniques to reply. " +
|
||||
r"I'll give you my paragraphs as follows, tell me what language it is written in, and then translate:" + "\n\n",
|
||||
"Prefix": build_gpt_academic_masked_string_langbased(
|
||||
text_show_chinese=
|
||||
r"I want you to act as a scientific English-Chinese translator, "
|
||||
r"I will provide you with some paragraphs in one language "
|
||||
r"and your task is to accurately and academically translate the paragraphs only into the other language. "
|
||||
r"Do not repeat the original provided paragraphs after translation. "
|
||||
r"You should use artificial intelligence tools, "
|
||||
r"such as natural language processing, and rhetorical knowledge "
|
||||
r"and experience about effective writing techniques to reply. "
|
||||
r"I'll give you my paragraphs as follows, tell me what language it is written in, and then translate:",
|
||||
text_show_english=
|
||||
r"你是经验丰富的翻译,请把以下学术文章段落翻译成中文,"
|
||||
r"并同时充分考虑中文的语法、清晰、简洁和整体可读性,"
|
||||
r"必要时,你可以修改整个句子的顺序以确保翻译后的段落符合中文的语言习惯。"
|
||||
r"你需要翻译的文本如下:"
|
||||
) + "\n\n",
|
||||
"Suffix": r"",
|
||||
},
|
||||
|
||||
@@ -140,7 +159,11 @@ def handle_core_functionality(additional_fn, inputs, history, chatbot):
|
||||
if "PreProcess" in core_functional[additional_fn]:
|
||||
if core_functional[additional_fn]["PreProcess"] is not None:
|
||||
inputs = core_functional[additional_fn]["PreProcess"](inputs) # 获取预处理函数(如果有的话)
|
||||
inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"]
|
||||
# 为字符串加上上面定义的前缀和后缀。
|
||||
inputs = apply_gpt_academic_string_mask_langbased(
|
||||
string = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"],
|
||||
lang_reference = inputs,
|
||||
)
|
||||
if core_functional[additional_fn].get("AutoClearHistory", False):
|
||||
history = []
|
||||
return inputs, history
|
||||
|
||||
@@ -32,10 +32,9 @@ def get_crazy_functions():
|
||||
from crazy_functions.理解PDF文档内容 import 理解PDF文档内容标准文件输入
|
||||
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.虚空终端 import 虚空终端
|
||||
from crazy_functions.生成多种Mermaid图表 import 生成多种Mermaid图表
|
||||
|
||||
function_plugins = {
|
||||
"虚空终端": {
|
||||
@@ -71,6 +70,15 @@ def get_crazy_functions():
|
||||
"Info": "清除所有缓存文件,谨慎操作 | 不需要输入参数",
|
||||
"Function": HotReload(清除缓存),
|
||||
},
|
||||
"生成多种Mermaid图表(从当前对话或路径(.pdf/.md/.docx)中生产图表)": {
|
||||
"Group": "对话",
|
||||
"Color": "stop",
|
||||
"AsButton": False,
|
||||
"Info" : "基于当前对话或文件生成多种Mermaid图表,图表类型由模型判断",
|
||||
"Function": HotReload(生成多种Mermaid图表),
|
||||
"AdvancedArgs": True,
|
||||
"ArgsReminder": "请输入图类型对应的数字,不输入则为模型自行判断:1-流程图,2-序列图,3-类图,4-饼图,5-甘特图,6-状态图,7-实体关系图,8-象限提示图,9-思维导图",
|
||||
},
|
||||
"批量总结Word文档": {
|
||||
"Group": "学术",
|
||||
"Color": "stop",
|
||||
@@ -237,13 +245,7 @@ def get_crazy_functions():
|
||||
"Info": "对英文Latex项目全文进行润色处理 | 输入参数为路径或上传压缩包",
|
||||
"Function": HotReload(Latex英文润色),
|
||||
},
|
||||
"英文Latex项目全文纠错(输入路径或上传压缩包)": {
|
||||
"Group": "学术",
|
||||
"Color": "stop",
|
||||
"AsButton": False, # 加入下拉菜单中
|
||||
"Info": "对英文Latex项目全文进行纠错处理 | 输入参数为路径或上传压缩包",
|
||||
"Function": HotReload(Latex英文纠错),
|
||||
},
|
||||
|
||||
"中文Latex项目全文润色(输入路径或上传压缩包)": {
|
||||
"Group": "学术",
|
||||
"Color": "stop",
|
||||
@@ -252,6 +254,14 @@ def get_crazy_functions():
|
||||
"Function": HotReload(Latex中文润色),
|
||||
},
|
||||
# 已经被新插件取代
|
||||
# "英文Latex项目全文纠错(输入路径或上传压缩包)": {
|
||||
# "Group": "学术",
|
||||
# "Color": "stop",
|
||||
# "AsButton": False, # 加入下拉菜单中
|
||||
# "Info": "对英文Latex项目全文进行纠错处理 | 输入参数为路径或上传压缩包",
|
||||
# "Function": HotReload(Latex英文纠错),
|
||||
# },
|
||||
# 已经被新插件取代
|
||||
# "Latex项目全文中译英(输入路径或上传压缩包)": {
|
||||
# "Group": "学术",
|
||||
# "Color": "stop",
|
||||
@@ -522,7 +532,9 @@ def get_crazy_functions():
|
||||
print("Load function plugin failed")
|
||||
|
||||
try:
|
||||
from crazy_functions.Latex输出PDF结果 import Latex英文纠错加PDF对比
|
||||
from crazy_functions.Latex输出PDF import Latex英文纠错加PDF对比
|
||||
from crazy_functions.Latex输出PDF import Latex翻译中文并重新编译PDF
|
||||
from crazy_functions.Latex输出PDF import PDF翻译中文并重新编译PDF
|
||||
|
||||
function_plugins.update(
|
||||
{
|
||||
@@ -533,38 +545,39 @@ def get_crazy_functions():
|
||||
"AdvancedArgs": True,
|
||||
"ArgsReminder": "如果有必要, 请在此处追加更细致的矫错指令(使用英文)。",
|
||||
"Function": HotReload(Latex英文纠错加PDF对比),
|
||||
}
|
||||
}
|
||||
)
|
||||
from crazy_functions.Latex输出PDF结果 import Latex翻译中文并重新编译PDF
|
||||
|
||||
function_plugins.update(
|
||||
{
|
||||
},
|
||||
"Arxiv论文精细翻译(输入arxivID)[需Latex]": {
|
||||
"Group": "学术",
|
||||
"Color": "stop",
|
||||
"AsButton": False,
|
||||
"AdvancedArgs": True,
|
||||
"ArgsReminder": "如果有必要, 请在此处给出自定义翻译命令, 解决部分词汇翻译不准确的问题。 "
|
||||
+ "例如当单词'agent'翻译不准确时, 请尝试把以下指令复制到高级参数区: "
|
||||
+ 'If the term "agent" is used in this section, it should be translated to "智能体". ',
|
||||
"ArgsReminder": r"如果有必要, 请在此处给出自定义翻译命令, 解决部分词汇翻译不准确的问题。 "
|
||||
r"例如当单词'agent'翻译不准确时, 请尝试把以下指令复制到高级参数区: "
|
||||
r'If the term "agent" is used in this section, it should be translated to "智能体". ',
|
||||
"Info": "Arixv论文精细翻译 | 输入参数arxiv论文的ID,比如1812.10695",
|
||||
"Function": HotReload(Latex翻译中文并重新编译PDF),
|
||||
}
|
||||
}
|
||||
)
|
||||
function_plugins.update(
|
||||
{
|
||||
},
|
||||
"本地Latex论文精细翻译(上传Latex项目)[需Latex]": {
|
||||
"Group": "学术",
|
||||
"Color": "stop",
|
||||
"AsButton": False,
|
||||
"AdvancedArgs": True,
|
||||
"ArgsReminder": "如果有必要, 请在此处给出自定义翻译命令, 解决部分词汇翻译不准确的问题。 "
|
||||
+ "例如当单词'agent'翻译不准确时, 请尝试把以下指令复制到高级参数区: "
|
||||
+ 'If the term "agent" is used in this section, it should be translated to "智能体". ',
|
||||
"ArgsReminder": r"如果有必要, 请在此处给出自定义翻译命令, 解决部分词汇翻译不准确的问题。 "
|
||||
r"例如当单词'agent'翻译不准确时, 请尝试把以下指令复制到高级参数区: "
|
||||
r'If the term "agent" is used in this section, it should be translated to "智能体". ',
|
||||
"Info": "本地Latex论文精细翻译 | 输入参数是路径",
|
||||
"Function": HotReload(Latex翻译中文并重新编译PDF),
|
||||
},
|
||||
"PDF翻译中文并重新编译PDF(上传PDF)[需Latex]": {
|
||||
"Group": "学术",
|
||||
"Color": "stop",
|
||||
"AsButton": False,
|
||||
"AdvancedArgs": True,
|
||||
"ArgsReminder": r"如果有必要, 请在此处给出自定义翻译命令, 解决部分词汇翻译不准确的问题。 "
|
||||
r"例如当单词'agent'翻译不准确时, 请尝试把以下指令复制到高级参数区: "
|
||||
r'If the term "agent" is used in this section, it should be translated to "智能体". ',
|
||||
"Info": "PDF翻译中文,并重新编译PDF | 输入参数为路径",
|
||||
"Function": HotReload(PDF翻译中文并重新编译PDF)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -135,11 +135,11 @@ def 多文件润色(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
|
||||
|
||||
|
||||
@CatchException
|
||||
def Latex英文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Latex英文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
"对整个Latex项目进行润色。函数插件贡献者: Binary-Husky。(注意,此插件不调用Latex,如果有Latex环境,请使用“Latex英文纠错+高亮”插件)"])
|
||||
"对整个Latex项目进行润色。函数插件贡献者: Binary-Husky。(注意,此插件不调用Latex,如果有Latex环境,请使用「Latex英文纠错+高亮修正位置(需Latex)插件」"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
||||
@@ -173,7 +173,7 @@ def Latex英文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
||||
|
||||
|
||||
@CatchException
|
||||
def Latex中文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Latex中文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
@@ -209,7 +209,7 @@ def Latex中文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
||||
|
||||
|
||||
@CatchException
|
||||
def Latex英文纠错(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Latex英文纠错(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
|
||||
@@ -106,7 +106,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
|
||||
|
||||
|
||||
@CatchException
|
||||
def Latex英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Latex英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
@@ -143,7 +143,7 @@ def Latex英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prom
|
||||
|
||||
|
||||
@CatchException
|
||||
def Latex中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Latex中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
|
||||
484
crazy_functions/Latex输出PDF.py
普通文件
484
crazy_functions/Latex输出PDF.py
普通文件
@@ -0,0 +1,484 @@
|
||||
from toolbox import update_ui, trimmed_format_exc, get_conf, get_log_folder, promote_file_to_downloadzone
|
||||
from toolbox import CatchException, report_exception, update_ui_lastest_msg, zip_result, gen_time_str
|
||||
from functools import partial
|
||||
import glob, os, requests, time, json, tarfile
|
||||
|
||||
pj = os.path.join
|
||||
ARXIV_CACHE_DIR = os.path.expanduser(f"~/arxiv_cache/")
|
||||
|
||||
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 工具函数 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
# 专业词汇声明 = 'If the term "agent" is used in this section, it should be translated to "智能体". '
|
||||
def switch_prompt(pfg, mode, more_requirement):
|
||||
"""
|
||||
Generate prompts and system prompts based on the mode for proofreading or translating.
|
||||
Args:
|
||||
- pfg: Proofreader or Translator instance.
|
||||
- mode: A string specifying the mode, either 'proofread' or 'translate_zh'.
|
||||
|
||||
Returns:
|
||||
- inputs_array: A list of strings containing prompts for users to respond to.
|
||||
- sys_prompt_array: A list of strings containing prompts for system prompts.
|
||||
"""
|
||||
n_split = len(pfg.sp_file_contents)
|
||||
if mode == 'proofread_en':
|
||||
inputs_array = [r"Below is a section from an academic paper, proofread this section." +
|
||||
r"Do not modify any latex command such as \section, \cite, \begin, \item and equations. " + more_requirement +
|
||||
r"Answer me only with the revised text:" +
|
||||
f"\n\n{frag}" for frag in pfg.sp_file_contents]
|
||||
sys_prompt_array = ["You are a professional academic paper writer." for _ in range(n_split)]
|
||||
elif mode == 'translate_zh':
|
||||
inputs_array = [
|
||||
r"Below is a section from an English academic paper, translate it into Chinese. " + more_requirement +
|
||||
r"Do not modify any latex command such as \section, \cite, \begin, \item and equations. " +
|
||||
r"Answer me only with the translated text:" +
|
||||
f"\n\n{frag}" for frag in pfg.sp_file_contents]
|
||||
sys_prompt_array = ["You are a professional translator." for _ in range(n_split)]
|
||||
else:
|
||||
assert False, "未知指令"
|
||||
return inputs_array, sys_prompt_array
|
||||
|
||||
|
||||
def desend_to_extracted_folder_if_exist(project_folder):
|
||||
"""
|
||||
Descend into the extracted folder if it exists, otherwise return the original folder.
|
||||
|
||||
Args:
|
||||
- project_folder: A string specifying the folder path.
|
||||
|
||||
Returns:
|
||||
- A string specifying the path to the extracted folder, or the original folder if there is no extracted folder.
|
||||
"""
|
||||
maybe_dir = [f for f in glob.glob(f'{project_folder}/*') if os.path.isdir(f)]
|
||||
if len(maybe_dir) == 0: return project_folder
|
||||
if maybe_dir[0].endswith('.extract'): return maybe_dir[0]
|
||||
return project_folder
|
||||
|
||||
|
||||
def move_project(project_folder, arxiv_id=None):
|
||||
"""
|
||||
Create a new work folder and copy the project folder to it.
|
||||
|
||||
Args:
|
||||
- project_folder: A string specifying the folder path of the project.
|
||||
|
||||
Returns:
|
||||
- A string specifying the path to the new work folder.
|
||||
"""
|
||||
import shutil, time
|
||||
time.sleep(2) # avoid time string conflict
|
||||
if arxiv_id is not None:
|
||||
new_workfolder = pj(ARXIV_CACHE_DIR, arxiv_id, 'workfolder')
|
||||
else:
|
||||
new_workfolder = f'{get_log_folder()}/{gen_time_str()}'
|
||||
try:
|
||||
shutil.rmtree(new_workfolder)
|
||||
except:
|
||||
pass
|
||||
|
||||
# align subfolder if there is a folder wrapper
|
||||
items = glob.glob(pj(project_folder, '*'))
|
||||
items = [item for item in items if os.path.basename(item) != '__MACOSX']
|
||||
if len(glob.glob(pj(project_folder, '*.tex'))) == 0 and len(items) == 1:
|
||||
if os.path.isdir(items[0]): project_folder = items[0]
|
||||
|
||||
shutil.copytree(src=project_folder, dst=new_workfolder)
|
||||
return new_workfolder
|
||||
|
||||
|
||||
def arxiv_download(chatbot, history, txt, allow_cache=True):
|
||||
def check_cached_translation_pdf(arxiv_id):
|
||||
translation_dir = pj(ARXIV_CACHE_DIR, arxiv_id, 'translation')
|
||||
if not os.path.exists(translation_dir):
|
||||
os.makedirs(translation_dir)
|
||||
target_file = pj(translation_dir, 'translate_zh.pdf')
|
||||
if os.path.exists(target_file):
|
||||
promote_file_to_downloadzone(target_file, rename_file=None, chatbot=chatbot)
|
||||
target_file_compare = pj(translation_dir, 'comparison.pdf')
|
||||
if os.path.exists(target_file_compare):
|
||||
promote_file_to_downloadzone(target_file_compare, rename_file=None, chatbot=chatbot)
|
||||
return target_file
|
||||
return False
|
||||
|
||||
def is_float(s):
|
||||
try:
|
||||
float(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
if ('.' in txt) and ('/' not in txt) and is_float(txt): # is arxiv ID
|
||||
txt = 'https://arxiv.org/abs/' + txt.strip()
|
||||
if ('.' in txt) and ('/' not in txt) and is_float(txt[:10]): # is arxiv ID
|
||||
txt = 'https://arxiv.org/abs/' + txt[:10]
|
||||
|
||||
if not txt.startswith('https://arxiv.org'):
|
||||
return txt, None # 是本地文件,跳过下载
|
||||
|
||||
# <-------------- inspect format ------------->
|
||||
chatbot.append([f"检测到arxiv文档连接", '尝试下载 ...'])
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
time.sleep(1) # 刷新界面
|
||||
|
||||
url_ = txt # https://arxiv.org/abs/1707.06690
|
||||
if not txt.startswith('https://arxiv.org/abs/'):
|
||||
msg = f"解析arxiv网址失败, 期望格式例如: https://arxiv.org/abs/1707.06690。实际得到格式: {url_}。"
|
||||
yield from update_ui_lastest_msg(msg, chatbot=chatbot, history=history) # 刷新界面
|
||||
return msg, None
|
||||
# <-------------- set format ------------->
|
||||
arxiv_id = url_.split('/abs/')[-1]
|
||||
if 'v' in arxiv_id: arxiv_id = arxiv_id[:10]
|
||||
cached_translation_pdf = check_cached_translation_pdf(arxiv_id)
|
||||
if cached_translation_pdf and allow_cache: return cached_translation_pdf, arxiv_id
|
||||
|
||||
url_tar = url_.replace('/abs/', '/e-print/')
|
||||
translation_dir = pj(ARXIV_CACHE_DIR, arxiv_id, 'e-print')
|
||||
extract_dst = pj(ARXIV_CACHE_DIR, arxiv_id, 'extract')
|
||||
os.makedirs(translation_dir, exist_ok=True)
|
||||
|
||||
# <-------------- download arxiv source file ------------->
|
||||
dst = pj(translation_dir, arxiv_id + '.tar')
|
||||
if os.path.exists(dst):
|
||||
yield from update_ui_lastest_msg("调用缓存", chatbot=chatbot, history=history) # 刷新界面
|
||||
else:
|
||||
yield from update_ui_lastest_msg("开始下载", chatbot=chatbot, history=history) # 刷新界面
|
||||
proxies = get_conf('proxies')
|
||||
r = requests.get(url_tar, proxies=proxies)
|
||||
with open(dst, 'wb+') as f:
|
||||
f.write(r.content)
|
||||
# <-------------- extract file ------------->
|
||||
yield from update_ui_lastest_msg("下载完成", chatbot=chatbot, history=history) # 刷新界面
|
||||
from toolbox import extract_archive
|
||||
extract_archive(file_path=dst, dest_dir=extract_dst)
|
||||
return extract_dst, arxiv_id
|
||||
|
||||
|
||||
def pdf2tex_project(pdf_file_path):
|
||||
# Mathpix API credentials
|
||||
app_id, app_key = get_conf('MATHPIX_APPID', 'MATHPIX_APPKEY')
|
||||
headers = {"app_id": app_id, "app_key": app_key}
|
||||
|
||||
# Step 1: Send PDF file for processing
|
||||
options = {
|
||||
"conversion_formats": {"tex.zip": True},
|
||||
"math_inline_delimiters": ["$", "$"],
|
||||
"rm_spaces": True
|
||||
}
|
||||
|
||||
response = requests.post(url="https://api.mathpix.com/v3/pdf",
|
||||
headers=headers,
|
||||
data={"options_json": json.dumps(options)},
|
||||
files={"file": open(pdf_file_path, "rb")})
|
||||
|
||||
if response.ok:
|
||||
pdf_id = response.json()["pdf_id"]
|
||||
print(f"PDF processing initiated. PDF ID: {pdf_id}")
|
||||
|
||||
# Step 2: Check processing status
|
||||
while True:
|
||||
conversion_response = requests.get(f"https://api.mathpix.com/v3/pdf/{pdf_id}", headers=headers)
|
||||
conversion_data = conversion_response.json()
|
||||
|
||||
if conversion_data["status"] == "completed":
|
||||
print("PDF processing completed.")
|
||||
break
|
||||
elif conversion_data["status"] == "error":
|
||||
print("Error occurred during processing.")
|
||||
else:
|
||||
print(f"Processing status: {conversion_data['status']}")
|
||||
time.sleep(5) # wait for a few seconds before checking again
|
||||
|
||||
# Step 3: Save results to local files
|
||||
output_dir = os.path.join(os.path.dirname(pdf_file_path), 'mathpix_output')
|
||||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
url = f"https://api.mathpix.com/v3/pdf/{pdf_id}.tex"
|
||||
response = requests.get(url, headers=headers)
|
||||
file_name_wo_dot = '_'.join(os.path.basename(pdf_file_path).split('.')[:-1])
|
||||
output_name = f"{file_name_wo_dot}.tex.zip"
|
||||
output_path = os.path.join(output_dir, output_name)
|
||||
with open(output_path, "wb") as output_file:
|
||||
output_file.write(response.content)
|
||||
print(f"tex.zip file saved at: {output_path}")
|
||||
|
||||
import zipfile
|
||||
unzip_dir = os.path.join(output_dir, file_name_wo_dot)
|
||||
with zipfile.ZipFile(output_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(unzip_dir)
|
||||
|
||||
return unzip_dir
|
||||
|
||||
else:
|
||||
print(f"Error sending PDF for processing. Status code: {response.status_code}")
|
||||
return None
|
||||
|
||||
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 插件主程序1 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
|
||||
@CatchException
|
||||
def Latex英文纠错加PDF对比(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# <-------------- information about this plugin ------------->
|
||||
chatbot.append(["函数插件功能?",
|
||||
"对整个Latex项目进行纠错, 用latex编译为PDF对修正处做高亮。函数插件贡献者: Binary-Husky。注意事项: 目前仅支持GPT3.5/GPT4,其他模型转化效果未知。目前对机器学习类文献转化效果最好,其他类型文献转化效果未知。仅在Windows系统进行了测试,其他操作系统表现未知。"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
# <-------------- more requirements ------------->
|
||||
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
|
||||
more_req = plugin_kwargs.get("advanced_arg", "")
|
||||
_switch_prompt_ = partial(switch_prompt, more_requirement=more_req)
|
||||
|
||||
# <-------------- check deps ------------->
|
||||
try:
|
||||
import glob, os, time, subprocess
|
||||
subprocess.Popen(['pdflatex', '-version'])
|
||||
from .latex_fns.latex_actions import Latex精细分解与转化, 编译Latex
|
||||
except Exception as e:
|
||||
chatbot.append([f"解析项目: {txt}",
|
||||
f"尝试执行Latex指令失败。Latex没有安装, 或者不在环境变量PATH中。安装方法https://tug.org/texlive/。报错信息\n\n```\n\n{trimmed_format_exc()}\n\n```\n\n"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- clear history and read input ------------->
|
||||
history = []
|
||||
if os.path.exists(txt):
|
||||
project_folder = txt
|
||||
else:
|
||||
if txt == "": txt = '空空如也的输入栏'
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)]
|
||||
if len(file_manifest) == 0:
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何.tex文件: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- if is a zip/tar file ------------->
|
||||
project_folder = desend_to_extracted_folder_if_exist(project_folder)
|
||||
|
||||
# <-------------- move latex project away from temp folder ------------->
|
||||
project_folder = move_project(project_folder, arxiv_id=None)
|
||||
|
||||
# <-------------- if merge_translate_zh is already generated, skip gpt req ------------->
|
||||
if not os.path.exists(project_folder + '/merge_proofread_en.tex'):
|
||||
yield from Latex精细分解与转化(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
||||
chatbot, history, system_prompt, mode='proofread_en',
|
||||
switch_prompt=_switch_prompt_)
|
||||
|
||||
# <-------------- compile PDF ------------->
|
||||
success = yield from 编译Latex(chatbot, history, main_file_original='merge',
|
||||
main_file_modified='merge_proofread_en',
|
||||
work_folder_original=project_folder, work_folder_modified=project_folder,
|
||||
work_folder=project_folder)
|
||||
|
||||
# <-------------- zip PDF ------------->
|
||||
zip_res = zip_result(project_folder)
|
||||
if success:
|
||||
chatbot.append((f"成功啦", '请查收结果(压缩包)...'))
|
||||
yield from update_ui(chatbot=chatbot, history=history);
|
||||
time.sleep(1) # 刷新界面
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
else:
|
||||
chatbot.append((f"失败了",
|
||||
'虽然PDF生成失败了, 但请查收结果(压缩包), 内含已经翻译的Tex文档, 也是可读的, 您可以到Github Issue区, 用该压缩包+对话历史存档进行反馈 ...'))
|
||||
yield from update_ui(chatbot=chatbot, history=history);
|
||||
time.sleep(1) # 刷新界面
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
|
||||
# <-------------- we are done ------------->
|
||||
return success
|
||||
|
||||
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 插件主程序2 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
@CatchException
|
||||
def Latex翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# <-------------- information about this plugin ------------->
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
"对整个Latex项目进行翻译, 生成中文PDF。函数插件贡献者: Binary-Husky。注意事项: 此插件Windows支持最佳,Linux下必须使用Docker安装,详见项目主README.md。目前仅支持GPT3.5/GPT4,其他模型转化效果未知。目前对机器学习类文献转化效果最好,其他类型文献转化效果未知。"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
# <-------------- more requirements ------------->
|
||||
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
|
||||
more_req = plugin_kwargs.get("advanced_arg", "")
|
||||
no_cache = more_req.startswith("--no-cache")
|
||||
if no_cache: more_req.lstrip("--no-cache")
|
||||
allow_cache = not no_cache
|
||||
_switch_prompt_ = partial(switch_prompt, more_requirement=more_req)
|
||||
|
||||
# <-------------- check deps ------------->
|
||||
try:
|
||||
import glob, os, time, subprocess
|
||||
subprocess.Popen(['pdflatex', '-version'])
|
||||
from .latex_fns.latex_actions import Latex精细分解与转化, 编译Latex
|
||||
except Exception as e:
|
||||
chatbot.append([f"解析项目: {txt}",
|
||||
f"尝试执行Latex指令失败。Latex没有安装, 或者不在环境变量PATH中。安装方法https://tug.org/texlive/。报错信息\n\n```\n\n{trimmed_format_exc()}\n\n```\n\n"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- clear history and read input ------------->
|
||||
history = []
|
||||
try:
|
||||
txt, arxiv_id = yield from arxiv_download(chatbot, history, txt, allow_cache)
|
||||
except tarfile.ReadError as e:
|
||||
yield from update_ui_lastest_msg(
|
||||
"无法自动下载该论文的Latex源码,请前往arxiv打开此论文下载页面,点other Formats,然后download source手动下载latex源码包。接下来调用本地Latex翻译插件即可。",
|
||||
chatbot=chatbot, history=history)
|
||||
return
|
||||
|
||||
if txt.endswith('.pdf'):
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"发现已经存在翻译好的PDF文档")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
if os.path.exists(txt):
|
||||
project_folder = txt
|
||||
else:
|
||||
if txt == "": txt = '空空如也的输入栏'
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无法处理: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)]
|
||||
if len(file_manifest) == 0:
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何.tex文件: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- if is a zip/tar file ------------->
|
||||
project_folder = desend_to_extracted_folder_if_exist(project_folder)
|
||||
|
||||
# <-------------- move latex project away from temp folder ------------->
|
||||
project_folder = move_project(project_folder, arxiv_id)
|
||||
|
||||
# <-------------- if merge_translate_zh is already generated, skip gpt req ------------->
|
||||
if not os.path.exists(project_folder + '/merge_translate_zh.tex'):
|
||||
yield from Latex精细分解与转化(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
||||
chatbot, history, system_prompt, mode='translate_zh',
|
||||
switch_prompt=_switch_prompt_)
|
||||
|
||||
# <-------------- compile PDF ------------->
|
||||
success = yield from 编译Latex(chatbot, history, main_file_original='merge',
|
||||
main_file_modified='merge_translate_zh', mode='translate_zh',
|
||||
work_folder_original=project_folder, work_folder_modified=project_folder,
|
||||
work_folder=project_folder)
|
||||
|
||||
# <-------------- zip PDF ------------->
|
||||
zip_res = zip_result(project_folder)
|
||||
if success:
|
||||
chatbot.append((f"成功啦", '请查收结果(压缩包)...'))
|
||||
yield from update_ui(chatbot=chatbot, history=history);
|
||||
time.sleep(1) # 刷新界面
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
else:
|
||||
chatbot.append((f"失败了",
|
||||
'虽然PDF生成失败了, 但请查收结果(压缩包), 内含已经翻译的Tex文档, 您可以到Github Issue区, 用该压缩包进行反馈。如系统是Linux,请检查系统字体(见Github wiki) ...'))
|
||||
yield from update_ui(chatbot=chatbot, history=history);
|
||||
time.sleep(1) # 刷新界面
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
|
||||
# <-------------- we are done ------------->
|
||||
return success
|
||||
|
||||
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 插件主程序3 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
@CatchException
|
||||
def PDF翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
# <-------------- information about this plugin ------------->
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
"将PDF转换为Latex项目,翻译为中文后重新编译为PDF。函数插件贡献者: Marroh。注意事项: 此插件Windows支持最佳,Linux下必须使用Docker安装,详见项目主README.md。目前仅支持GPT3.5/GPT4,其他模型转化效果未知。目前对机器学习类文献转化效果最好,其他类型文献转化效果未知。"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
# <-------------- more requirements ------------->
|
||||
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
|
||||
more_req = plugin_kwargs.get("advanced_arg", "")
|
||||
no_cache = more_req.startswith("--no-cache")
|
||||
if no_cache: more_req.lstrip("--no-cache")
|
||||
allow_cache = not no_cache
|
||||
_switch_prompt_ = partial(switch_prompt, more_requirement=more_req)
|
||||
|
||||
# <-------------- check deps ------------->
|
||||
try:
|
||||
import glob, os, time, subprocess
|
||||
subprocess.Popen(['pdflatex', '-version'])
|
||||
from .latex_fns.latex_actions import Latex精细分解与转化, 编译Latex
|
||||
except Exception as e:
|
||||
chatbot.append([f"解析项目: {txt}",
|
||||
f"尝试执行Latex指令失败。Latex没有安装, 或者不在环境变量PATH中。安装方法https://tug.org/texlive/。报错信息\n\n```\n\n{trimmed_format_exc()}\n\n```\n\n"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- clear history and read input ------------->
|
||||
if os.path.exists(txt):
|
||||
project_folder = txt
|
||||
else:
|
||||
if txt == "": txt = '空空如也的输入栏'
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无法处理: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.pdf', recursive=True)]
|
||||
if len(file_manifest) == 0:
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何.pdf文件: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
if len(file_manifest) != 1:
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"不支持同时处理多个pdf文件: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
app_id, app_key = get_conf('MATHPIX_APPID', 'MATHPIX_APPKEY')
|
||||
if len(app_id) == 0 or len(app_key) == 0:
|
||||
report_exception(chatbot, history, a="缺失 MATHPIX_APPID 和 MATHPIX_APPKEY。", b=f"请配置 MATHPIX_APPID 和 MATHPIX_APPKEY")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- convert pdf into tex ------------->
|
||||
project_folder = pdf2tex_project(file_manifest[0])
|
||||
|
||||
# Translate English Latex to Chinese Latex, and compile it
|
||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)]
|
||||
if len(file_manifest) == 0:
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何.tex文件: {txt}")
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
return
|
||||
|
||||
# <-------------- if is a zip/tar file ------------->
|
||||
project_folder = desend_to_extracted_folder_if_exist(project_folder)
|
||||
|
||||
# <-------------- move latex project away from temp folder ------------->
|
||||
project_folder = move_project(project_folder)
|
||||
|
||||
# <-------------- if merge_translate_zh is already generated, skip gpt req ------------->
|
||||
if not os.path.exists(project_folder + '/merge_translate_zh.tex'):
|
||||
yield from Latex精细分解与转化(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
||||
chatbot, history, system_prompt, mode='translate_zh',
|
||||
switch_prompt=_switch_prompt_)
|
||||
|
||||
# <-------------- compile PDF ------------->
|
||||
success = yield from 编译Latex(chatbot, history, main_file_original='merge',
|
||||
main_file_modified='merge_translate_zh', mode='translate_zh',
|
||||
work_folder_original=project_folder, work_folder_modified=project_folder,
|
||||
work_folder=project_folder)
|
||||
|
||||
# <-------------- zip PDF ------------->
|
||||
zip_res = zip_result(project_folder)
|
||||
if success:
|
||||
chatbot.append((f"成功啦", '请查收结果(压缩包)...'))
|
||||
yield from update_ui(chatbot=chatbot, history=history);
|
||||
time.sleep(1) # 刷新界面
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
else:
|
||||
chatbot.append((f"失败了",
|
||||
'虽然PDF生成失败了, 但请查收结果(压缩包), 内含已经翻译的Tex文档, 您可以到Github Issue区, 用该压缩包进行反馈。如系统是Linux,请检查系统字体(见Github wiki) ...'))
|
||||
yield from update_ui(chatbot=chatbot, history=history);
|
||||
time.sleep(1) # 刷新界面
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
|
||||
# <-------------- we are done ------------->
|
||||
return success
|
||||
@@ -9,7 +9,7 @@ class PipeCom:
|
||||
|
||||
|
||||
class PluginMultiprocessManager:
|
||||
def __init__(self, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def __init__(self, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# ⭐ run in main process
|
||||
self.autogen_work_dir = os.path.join(get_log_folder("autogen"), gen_time_str())
|
||||
self.previous_work_dir_files = {}
|
||||
@@ -18,7 +18,7 @@ class PluginMultiprocessManager:
|
||||
self.chatbot = chatbot
|
||||
self.history = history
|
||||
self.system_prompt = system_prompt
|
||||
# self.web_port = web_port
|
||||
# self.user_request = user_request
|
||||
self.alive = True
|
||||
self.use_docker = get_conf("AUTOGEN_USE_DOCKER")
|
||||
self.last_user_input = ""
|
||||
|
||||
@@ -32,7 +32,7 @@ def string_to_options(arguments):
|
||||
return args
|
||||
|
||||
@CatchException
|
||||
def 微调数据集生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 微调数据集生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -40,7 +40,7 @@ def 微调数据集生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
chatbot.append(("这是什么功能?", "[Local Message] 微调数据集生成"))
|
||||
@@ -80,7 +80,7 @@ def 微调数据集生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
||||
|
||||
|
||||
@CatchException
|
||||
def 启动微调(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 启动微调(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -88,7 +88,7 @@ def 启动微调(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
import subprocess
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
|
||||
@@ -12,7 +12,7 @@ def input_clipping(inputs, history, max_token_limit):
|
||||
mode = 'input-and-history'
|
||||
# 当 输入部分的token占比 小于 全文的一半时,只裁剪历史
|
||||
input_token_num = get_token_num(inputs)
|
||||
if input_token_num < max_token_limit//2:
|
||||
if input_token_num < max_token_limit//2:
|
||||
mode = 'only-history'
|
||||
max_token_limit = max_token_limit - input_token_num
|
||||
|
||||
@@ -21,7 +21,7 @@ def input_clipping(inputs, history, max_token_limit):
|
||||
n_token = get_token_num('\n'.join(everything))
|
||||
everything_token = [get_token_num(e) for e in everything]
|
||||
delta = max(everything_token) // 16 # 截断时的颗粒度
|
||||
|
||||
|
||||
while n_token > max_token_limit:
|
||||
where = np.argmax(everything_token)
|
||||
encoded = enc.encode(everything[where], disallowed_special=())
|
||||
@@ -38,9 +38,9 @@ def input_clipping(inputs, history, max_token_limit):
|
||||
return inputs, history
|
||||
|
||||
def request_gpt_model_in_new_thread_with_ui_alive(
|
||||
inputs, inputs_show_user, llm_kwargs,
|
||||
inputs, inputs_show_user, llm_kwargs,
|
||||
chatbot, history, sys_prompt, refresh_interval=0.2,
|
||||
handle_token_exceed=True,
|
||||
handle_token_exceed=True,
|
||||
retry_times_at_unknown_error=2,
|
||||
):
|
||||
"""
|
||||
@@ -77,7 +77,7 @@ def request_gpt_model_in_new_thread_with_ui_alive(
|
||||
exceeded_cnt = 0
|
||||
while True:
|
||||
# watchdog error
|
||||
if len(mutable) >= 2 and (time.time()-mutable[1]) > watch_dog_patience:
|
||||
if len(mutable) >= 2 and (time.time()-mutable[1]) > watch_dog_patience:
|
||||
raise RuntimeError("检测到程序终止。")
|
||||
try:
|
||||
# 【第一种情况】:顺利完成
|
||||
@@ -140,12 +140,12 @@ def can_multi_process(llm):
|
||||
if llm.startswith('api2d-'): return True
|
||||
if llm.startswith('azure-'): return True
|
||||
if llm.startswith('spark'): return True
|
||||
if llm.startswith('zhipuai'): return True
|
||||
if llm.startswith('zhipuai') or llm.startswith('glm-'): return True
|
||||
return False
|
||||
|
||||
def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
||||
inputs_array, inputs_show_user_array, llm_kwargs,
|
||||
chatbot, history_array, sys_prompt_array,
|
||||
inputs_array, inputs_show_user_array, llm_kwargs,
|
||||
chatbot, history_array, sys_prompt_array,
|
||||
refresh_interval=0.2, max_workers=-1, scroller_max_len=30,
|
||||
handle_token_exceed=True, show_user_at_complete=False,
|
||||
retry_times_at_unknown_error=2,
|
||||
@@ -189,7 +189,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
||||
# 屏蔽掉 chatglm的多线程,可能会导致严重卡顿
|
||||
if not can_multi_process(llm_kwargs['llm_model']):
|
||||
max_workers = 1
|
||||
|
||||
|
||||
executor = ThreadPoolExecutor(max_workers=max_workers)
|
||||
n_frag = len(inputs_array)
|
||||
# 用户反馈
|
||||
@@ -214,7 +214,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
||||
try:
|
||||
# 【第一种情况】:顺利完成
|
||||
gpt_say = predict_no_ui_long_connection(
|
||||
inputs=inputs, llm_kwargs=llm_kwargs, history=history,
|
||||
inputs=inputs, llm_kwargs=llm_kwargs, history=history,
|
||||
sys_prompt=sys_prompt, observe_window=mutable[index], console_slience=True
|
||||
)
|
||||
mutable[index][2] = "已成功"
|
||||
@@ -246,7 +246,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
||||
print(tb_str)
|
||||
gpt_say += f"[Local Message] 警告,线程{index}在执行过程中遭遇问题, Traceback:\n\n{tb_str}\n\n"
|
||||
if len(mutable[index][0]) > 0: gpt_say += "此线程失败前收到的回答:\n\n" + mutable[index][0]
|
||||
if retry_op > 0:
|
||||
if retry_op > 0:
|
||||
retry_op -= 1
|
||||
wait = random.randint(5, 20)
|
||||
if ("Rate limit reached" in tb_str) or ("Too Many Requests" in tb_str):
|
||||
@@ -284,12 +284,11 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
||||
# 在前端打印些好玩的东西
|
||||
for thread_index, _ in enumerate(worker_done):
|
||||
print_something_really_funny = "[ ...`"+mutable[thread_index][0][-scroller_max_len:].\
|
||||
replace('\n', '').replace('`', '.').replace(
|
||||
' ', '.').replace('<br/>', '.....').replace('$', '.')+"`... ]"
|
||||
replace('\n', '').replace('`', '.').replace(' ', '.').replace('<br/>', '.....').replace('$', '.')+"`... ]"
|
||||
observe_win.append(print_something_really_funny)
|
||||
# 在前端打印些好玩的东西
|
||||
stat_str = ''.join([f'`{mutable[thread_index][2]}`: {obs}\n\n'
|
||||
if not done else f'`{mutable[thread_index][2]}`\n\n'
|
||||
stat_str = ''.join([f'`{mutable[thread_index][2]}`: {obs}\n\n'
|
||||
if not done else f'`{mutable[thread_index][2]}`\n\n'
|
||||
for thread_index, done, obs in zip(range(len(worker_done)), worker_done, observe_win)])
|
||||
# 在前端打印些好玩的东西
|
||||
chatbot[-1] = [chatbot[-1][0], f'多线程操作已经开始,完成情况: \n\n{stat_str}' + ''.join(['.']*(cnt % 10+1))]
|
||||
@@ -303,7 +302,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
||||
for inputs_show_user, f in zip(inputs_show_user_array, futures):
|
||||
gpt_res = f.result()
|
||||
gpt_response_collection.extend([inputs_show_user, gpt_res])
|
||||
|
||||
|
||||
# 是否在结束时,在界面上显示结果
|
||||
if show_user_at_complete:
|
||||
for inputs_show_user, f in zip(inputs_show_user_array, futures):
|
||||
@@ -353,7 +352,7 @@ def read_and_clean_pdf_text(fp):
|
||||
if wtf['size'] not in fsize_statiscs: fsize_statiscs[wtf['size']] = 0
|
||||
fsize_statiscs[wtf['size']] += len(wtf['text'])
|
||||
return max(fsize_statiscs, key=fsize_statiscs.get)
|
||||
|
||||
|
||||
def ffsize_same(a,b):
|
||||
"""
|
||||
提取字体大小是否近似相等
|
||||
@@ -389,7 +388,7 @@ def read_and_clean_pdf_text(fp):
|
||||
if index == 0:
|
||||
page_one_meta = [" ".join(["".join([wtf['text'] for wtf in l['spans']]) for l in t['lines']]).replace(
|
||||
'- ', '') for t in text_areas['blocks'] if 'lines' in t]
|
||||
|
||||
|
||||
############################## <第 2 步,获取正文主字体> ##################################
|
||||
try:
|
||||
fsize_statiscs = {}
|
||||
@@ -405,7 +404,7 @@ def read_and_clean_pdf_text(fp):
|
||||
mega_sec = []
|
||||
sec = []
|
||||
for index, line in enumerate(meta_line):
|
||||
if index == 0:
|
||||
if index == 0:
|
||||
sec.append(line[fc])
|
||||
continue
|
||||
if REMOVE_FOOT_NOTE:
|
||||
@@ -502,12 +501,12 @@ def get_files_from_everything(txt, type): # type='.md'
|
||||
"""
|
||||
这个函数是用来获取指定目录下所有指定类型(如.md)的文件,并且对于网络上的文件,也可以获取它。
|
||||
下面是对每个参数和返回值的说明:
|
||||
参数
|
||||
- txt: 路径或网址,表示要搜索的文件或者文件夹路径或网络上的文件。
|
||||
参数
|
||||
- txt: 路径或网址,表示要搜索的文件或者文件夹路径或网络上的文件。
|
||||
- type: 字符串,表示要搜索的文件类型。默认是.md。
|
||||
返回值
|
||||
- success: 布尔值,表示函数是否成功执行。
|
||||
- file_manifest: 文件路径列表,里面包含以指定类型为后缀名的所有文件的绝对路径。
|
||||
返回值
|
||||
- success: 布尔值,表示函数是否成功执行。
|
||||
- file_manifest: 文件路径列表,里面包含以指定类型为后缀名的所有文件的绝对路径。
|
||||
- project_folder: 字符串,表示文件所在的文件夹路径。如果是网络上的文件,就是临时文件夹的路径。
|
||||
该函数详细注释已添加,请确认是否满足您的需要。
|
||||
"""
|
||||
@@ -571,7 +570,7 @@ class nougat_interface():
|
||||
def NOUGAT_parse_pdf(self, fp, chatbot, history):
|
||||
from toolbox import update_ui_lastest_msg
|
||||
|
||||
yield from update_ui_lastest_msg("正在解析论文, 请稍候。进度:正在排队, 等待线程锁...",
|
||||
yield from update_ui_lastest_msg("正在解析论文, 请稍候。进度:正在排队, 等待线程锁...",
|
||||
chatbot=chatbot, history=history, delay=0)
|
||||
self.threadLock.acquire()
|
||||
import glob, threading, os
|
||||
@@ -579,7 +578,7 @@ class nougat_interface():
|
||||
dst = os.path.join(get_log_folder(plugin_name='nougat'), gen_time_str())
|
||||
os.makedirs(dst)
|
||||
|
||||
yield from update_ui_lastest_msg("正在解析论文, 请稍候。进度:正在加载NOUGAT... (提示:首次运行需要花费较长时间下载NOUGAT参数)",
|
||||
yield from update_ui_lastest_msg("正在解析论文, 请稍候。进度:正在加载NOUGAT... (提示:首次运行需要花费较长时间下载NOUGAT参数)",
|
||||
chatbot=chatbot, history=history, delay=0)
|
||||
self.nougat_with_timeout(f'nougat --out "{os.path.abspath(dst)}" "{os.path.abspath(fp)}"', os.getcwd(), timeout=3600)
|
||||
res = glob.glob(os.path.join(dst,'*.mmd'))
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
import os
|
||||
from textwrap import indent
|
||||
|
||||
class FileNode:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.children = []
|
||||
self.is_leaf = False
|
||||
self.level = 0
|
||||
self.parenting_ship = []
|
||||
self.comment = ""
|
||||
self.comment_maxlen_show = 50
|
||||
|
||||
@staticmethod
|
||||
def add_linebreaks_at_spaces(string, interval=10):
|
||||
return '\n'.join(string[i:i+interval] for i in range(0, len(string), interval))
|
||||
|
||||
def sanitize_comment(self, comment):
|
||||
if len(comment) > self.comment_maxlen_show: suf = '...'
|
||||
else: suf = ''
|
||||
comment = comment[:self.comment_maxlen_show]
|
||||
comment = comment.replace('\"', '').replace('`', '').replace('\n', '').replace('`', '').replace('$', '')
|
||||
comment = self.add_linebreaks_at_spaces(comment, 10)
|
||||
return '`' + comment + suf + '`'
|
||||
|
||||
def add_file(self, file_path, file_comment):
|
||||
directory_names, file_name = os.path.split(file_path)
|
||||
current_node = self
|
||||
level = 1
|
||||
if directory_names == "":
|
||||
new_node = FileNode(file_name)
|
||||
current_node.children.append(new_node)
|
||||
new_node.is_leaf = True
|
||||
new_node.comment = self.sanitize_comment(file_comment)
|
||||
new_node.level = level
|
||||
current_node = new_node
|
||||
else:
|
||||
dnamesplit = directory_names.split(os.sep)
|
||||
for i, directory_name in enumerate(dnamesplit):
|
||||
found_child = False
|
||||
level += 1
|
||||
for child in current_node.children:
|
||||
if child.name == directory_name:
|
||||
current_node = child
|
||||
found_child = True
|
||||
break
|
||||
if not found_child:
|
||||
new_node = FileNode(directory_name)
|
||||
current_node.children.append(new_node)
|
||||
new_node.level = level - 1
|
||||
current_node = new_node
|
||||
term = FileNode(file_name)
|
||||
term.level = level
|
||||
term.comment = self.sanitize_comment(file_comment)
|
||||
term.is_leaf = True
|
||||
current_node.children.append(term)
|
||||
|
||||
def print_files_recursively(self, level=0, code="R0"):
|
||||
print(' '*level + self.name + ' ' + str(self.is_leaf) + ' ' + str(self.level))
|
||||
for j, child in enumerate(self.children):
|
||||
child.print_files_recursively(level=level+1, code=code+str(j))
|
||||
self.parenting_ship.extend(child.parenting_ship)
|
||||
p1 = f"""{code}[\"🗎{self.name}\"]""" if self.is_leaf else f"""{code}[[\"📁{self.name}\"]]"""
|
||||
p2 = """ --> """
|
||||
p3 = f"""{code+str(j)}[\"🗎{child.name}\"]""" if child.is_leaf else f"""{code+str(j)}[[\"📁{child.name}\"]]"""
|
||||
edge_code = p1 + p2 + p3
|
||||
if edge_code in self.parenting_ship:
|
||||
continue
|
||||
self.parenting_ship.append(edge_code)
|
||||
if self.comment != "":
|
||||
pc1 = f"""{code}[\"🗎{self.name}\"]""" if self.is_leaf else f"""{code}[[\"📁{self.name}\"]]"""
|
||||
pc2 = f""" -.-x """
|
||||
pc3 = f"""C{code}[\"{self.comment}\"]:::Comment"""
|
||||
edge_code = pc1 + pc2 + pc3
|
||||
self.parenting_ship.append(edge_code)
|
||||
|
||||
|
||||
MERMAID_TEMPLATE = r"""
|
||||
```mermaid
|
||||
flowchart LR
|
||||
%% <gpt_academic_hide_mermaid_code> 一个特殊标记,用于在生成mermaid图表时隐藏代码块
|
||||
classDef Comment stroke-dasharray: 5 5
|
||||
subgraph {graph_name}
|
||||
{relationship}
|
||||
end
|
||||
```
|
||||
"""
|
||||
|
||||
def build_file_tree_mermaid_diagram(file_manifest, file_comments, graph_name):
|
||||
# Create the root node
|
||||
file_tree_struct = FileNode("root")
|
||||
# Build the tree structure
|
||||
for file_path, file_comment in zip(file_manifest, file_comments):
|
||||
file_tree_struct.add_file(file_path, file_comment)
|
||||
file_tree_struct.print_files_recursively()
|
||||
cc = "\n".join(file_tree_struct.parenting_ship)
|
||||
ccc = indent(cc, prefix=" "*8)
|
||||
return MERMAID_TEMPLATE.format(graph_name=graph_name, relationship=ccc)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# File manifest
|
||||
file_manifest = [
|
||||
"cradle_void_terminal.ipynb",
|
||||
"tests/test_utils.py",
|
||||
"tests/test_plugins.py",
|
||||
"tests/test_llms.py",
|
||||
"config.py",
|
||||
"build/ChatGLM-6b-onnx-u8s8/chatglm-6b-int8-onnx-merged/model_weights_0.bin",
|
||||
"crazy_functions/latex_fns/latex_actions.py",
|
||||
"crazy_functions/latex_fns/latex_toolbox.py"
|
||||
]
|
||||
file_comments = [
|
||||
"根据位置和名称,可能是一个模块的初始化文件根据位置和名称,可能是一个模块的初始化文件根据位置和名称,可能是一个模块的初始化文件",
|
||||
"包含一些用于文本处理和模型微调的函数和装饰器包含一些用于文本处理和模型微调的函数和装饰器包含一些用于文本处理和模型微调的函数和装饰器",
|
||||
"用于构建HTML报告的类和方法用于构建HTML报告的类和方法用于构建HTML报告的类和方法",
|
||||
"包含了用于文本切分的函数,以及处理PDF文件的示例代码包含了用于文本切分的函数,以及处理PDF文件的示例代码包含了用于文本切分的函数,以及处理PDF文件的示例代码",
|
||||
"用于解析和翻译PDF文件的功能和相关辅助函数用于解析和翻译PDF文件的功能和相关辅助函数用于解析和翻译PDF文件的功能和相关辅助函数",
|
||||
"是一个包的初始化文件,用于初始化包的属性和导入模块是一个包的初始化文件,用于初始化包的属性和导入模块是一个包的初始化文件,用于初始化包的属性和导入模块",
|
||||
"用于加载和分割文件中的文本的通用文件加载器用于加载和分割文件中的文本的通用文件加载器用于加载和分割文件中的文本的通用文件加载器",
|
||||
"包含了用于构建和管理向量数据库的函数和类包含了用于构建和管理向量数据库的函数和类包含了用于构建和管理向量数据库的函数和类",
|
||||
]
|
||||
print(build_file_tree_mermaid_diagram(file_manifest, file_comments, "项目文件树"))
|
||||
@@ -0,0 +1,85 @@
|
||||
from crazy_functions.crazy_utils import read_and_clean_pdf_text, get_files_from_everything
|
||||
import os
|
||||
import re
|
||||
def extract_text_from_files(txt, chatbot, history):
|
||||
"""
|
||||
查找pdf/md/word并获取文本内容并返回状态以及文本
|
||||
|
||||
输入参数 Args:
|
||||
chatbot: chatbot inputs and outputs (用户界面对话窗口句柄,用于数据流可视化)
|
||||
history (list): List of chat history (历史,对话历史列表)
|
||||
|
||||
输出 Returns:
|
||||
文件是否存在(bool)
|
||||
final_result(list):文本内容
|
||||
page_one(list):第一页内容/摘要
|
||||
file_manifest(list):文件路径
|
||||
excption(string):需要用户手动处理的信息,如没出错则保持为空
|
||||
"""
|
||||
|
||||
final_result = []
|
||||
page_one = []
|
||||
file_manifest = []
|
||||
excption = ""
|
||||
|
||||
if txt == "":
|
||||
final_result.append(txt)
|
||||
return False, final_result, page_one, file_manifest, excption #如输入区内容不是文件则直接返回输入区内容
|
||||
|
||||
#查找输入区内容中的文件
|
||||
file_pdf,pdf_manifest,folder_pdf = get_files_from_everything(txt, '.pdf')
|
||||
file_md,md_manifest,folder_md = get_files_from_everything(txt, '.md')
|
||||
file_word,word_manifest,folder_word = get_files_from_everything(txt, '.docx')
|
||||
file_doc,doc_manifest,folder_doc = get_files_from_everything(txt, '.doc')
|
||||
|
||||
if file_doc:
|
||||
excption = "word"
|
||||
return False, final_result, page_one, file_manifest, excption
|
||||
|
||||
file_num = len(pdf_manifest) + len(md_manifest) + len(word_manifest)
|
||||
if file_num == 0:
|
||||
final_result.append(txt)
|
||||
return False, final_result, page_one, file_manifest, excption #如输入区内容不是文件则直接返回输入区内容
|
||||
|
||||
if file_pdf:
|
||||
try: # 尝试导入依赖,如果缺少依赖,则给出安装建议
|
||||
import fitz
|
||||
except:
|
||||
excption = "pdf"
|
||||
return False, final_result, page_one, file_manifest, excption
|
||||
for index, fp in enumerate(pdf_manifest):
|
||||
file_content, pdf_one = read_and_clean_pdf_text(fp) # (尝试)按照章节切割PDF
|
||||
file_content = file_content.encode('utf-8', 'ignore').decode() # avoid reading non-utf8 chars
|
||||
pdf_one = str(pdf_one).encode('utf-8', 'ignore').decode() # avoid reading non-utf8 chars
|
||||
final_result.append(file_content)
|
||||
page_one.append(pdf_one)
|
||||
file_manifest.append(os.path.relpath(fp, folder_pdf))
|
||||
|
||||
if file_md:
|
||||
for index, fp in enumerate(md_manifest):
|
||||
with open(fp, 'r', encoding='utf-8', errors='replace') as f:
|
||||
file_content = f.read()
|
||||
file_content = file_content.encode('utf-8', 'ignore').decode()
|
||||
headers = re.findall(r'^#\s(.*)$', file_content, re.MULTILINE) #接下来提取md中的一级/二级标题作为摘要
|
||||
if len(headers) > 0:
|
||||
page_one.append("\n".join(headers)) #合并所有的标题,以换行符分割
|
||||
else:
|
||||
page_one.append("")
|
||||
final_result.append(file_content)
|
||||
file_manifest.append(os.path.relpath(fp, folder_md))
|
||||
|
||||
if file_word:
|
||||
try: # 尝试导入依赖,如果缺少依赖,则给出安装建议
|
||||
from docx import Document
|
||||
except:
|
||||
excption = "word_pip"
|
||||
return False, final_result, page_one, file_manifest, excption
|
||||
for index, fp in enumerate(word_manifest):
|
||||
doc = Document(fp)
|
||||
file_content = '\n'.join([p.text for p in doc.paragraphs])
|
||||
file_content = file_content.encode('utf-8', 'ignore').decode()
|
||||
page_one.append(file_content[:200])
|
||||
final_result.append(file_content)
|
||||
file_manifest.append(os.path.relpath(fp, folder_word))
|
||||
|
||||
return True, final_result, page_one, file_manifest, excption
|
||||
@@ -130,7 +130,7 @@ def get_name(_url_):
|
||||
|
||||
|
||||
@CatchException
|
||||
def 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
|
||||
CRAZY_FUNCTION_INFO = "下载arxiv论文并翻译摘要,函数插件作者[binary-husky]。正在提取摘要并下载PDF文档……"
|
||||
import glob
|
||||
|
||||
@@ -5,7 +5,7 @@ from request_llms.bridge_all import predict_no_ui_long_connection
|
||||
from crazy_functions.game_fns.game_utils import get_code_block, is_same_thing
|
||||
|
||||
@CatchException
|
||||
def 随机小游戏(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 随机小游戏(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
from crazy_functions.game_fns.game_interactive_story import MiniGame_ResumeStory
|
||||
# 清空历史
|
||||
history = []
|
||||
@@ -23,7 +23,7 @@ def 随机小游戏(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
|
||||
|
||||
@CatchException
|
||||
def 随机小游戏1(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 随机小游戏1(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
from crazy_functions.game_fns.game_ascii_art import MiniGame_ASCII_Art
|
||||
# 清空历史
|
||||
history = []
|
||||
|
||||
@@ -3,7 +3,7 @@ from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
||||
|
||||
|
||||
@CatchException
|
||||
def 交互功能模板函数(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 交互功能模板函数(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数, 如温度和top_p等, 一般原样传递下去就行
|
||||
@@ -11,7 +11,7 @@ def 交互功能模板函数(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
chatbot.append(("这是什么功能?", "交互功能函数模板。在执行完成之后, 可以将自身的状态存储到cookie中, 等待用户的再次调用。"))
|
||||
|
||||
@@ -139,7 +139,7 @@ def get_recent_file_prompt_support(chatbot):
|
||||
return path
|
||||
|
||||
@CatchException
|
||||
def 函数动态生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 函数动态生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -147,7 +147,7 @@ def 函数动态生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
|
||||
# 清空历史
|
||||
|
||||
@@ -4,7 +4,7 @@ from .crazy_utils import input_clipping
|
||||
import copy, json
|
||||
|
||||
@CatchException
|
||||
def 命令行助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 命令行助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本, 例如需要翻译的一段话, 再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数, 如温度和top_p等, 一般原样传递下去就行
|
||||
@@ -12,7 +12,7 @@ def 命令行助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
|
||||
chatbot 聊天显示框的句柄, 用于显示给用户
|
||||
history 聊天历史, 前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
# 清空历史, 以免输入溢出
|
||||
history = []
|
||||
|
||||
@@ -93,7 +93,7 @@ def edit_image(llm_kwargs, prompt, image_path, resolution="1024x1024", model="da
|
||||
|
||||
|
||||
@CatchException
|
||||
def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -101,7 +101,7 @@ def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
if prompt.strip() == "":
|
||||
@@ -123,7 +123,7 @@ def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
|
||||
|
||||
|
||||
@CatchException
|
||||
def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
if prompt.strip() == "":
|
||||
chatbot.append((prompt, "[Local Message] 图像生成提示为空白,请在“输入区”输入图像生成提示。"))
|
||||
@@ -209,7 +209,7 @@ class ImageEditState(GptAcademicState):
|
||||
return all([x['value'] is not None for x in self.req])
|
||||
|
||||
@CatchException
|
||||
def 图片修改_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 图片修改_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 尚未完成
|
||||
history = [] # 清空历史
|
||||
state = ImageEditState.get_state(chatbot, ImageEditState)
|
||||
|
||||
@@ -21,7 +21,7 @@ def remove_model_prefix(llm):
|
||||
|
||||
|
||||
@CatchException
|
||||
def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -29,7 +29,7 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
# 检查当前的模型是否符合要求
|
||||
supported_llms = [
|
||||
@@ -89,7 +89,7 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
history = []
|
||||
chatbot.append(["正在启动: 多智能体终端", "插件动态生成, 执行开始, 作者 Microsoft & Binary-Husky."])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
executor = AutoGenMath(llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port)
|
||||
executor = AutoGenMath(llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request)
|
||||
persistent_class_multi_user_manager.set(persistent_key, executor)
|
||||
exit_reason = yield from executor.main_process_ui_control(txt, create_or_resume="create")
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ def read_file_to_chat(chatbot, history, file_name):
|
||||
return chatbot, history
|
||||
|
||||
@CatchException
|
||||
def 对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -77,7 +77,7 @@ def 对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
|
||||
chatbot.append(("保存当前对话",
|
||||
@@ -91,7 +91,7 @@ def hide_cwd(str):
|
||||
return str.replace(current_path, replace_path)
|
||||
|
||||
@CatchException
|
||||
def 载入对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 载入对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -99,7 +99,7 @@ def 载入对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
from .crazy_utils import get_files_from_everything
|
||||
success, file_manifest, _ = get_files_from_everything(txt, type='.html')
|
||||
@@ -126,7 +126,7 @@ def 载入对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
return
|
||||
|
||||
@CatchException
|
||||
def 删除所有本地对话历史记录(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 删除所有本地对话历史记录(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -134,7 +134,7 @@ def 删除所有本地对话历史记录(txt, llm_kwargs, plugin_kwargs, chatbot
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
|
||||
import glob, os
|
||||
|
||||
@@ -79,7 +79,7 @@ def 解析docx(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot
|
||||
|
||||
|
||||
@CatchException
|
||||
def 总结word文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 总结word文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
import glob, os
|
||||
|
||||
# 基本信息:功能、贡献者
|
||||
|
||||
@@ -153,7 +153,7 @@ def get_files_from_everything(txt, preference=''):
|
||||
|
||||
|
||||
@CatchException
|
||||
def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
@@ -193,7 +193,7 @@ def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
||||
|
||||
|
||||
@CatchException
|
||||
def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
@@ -226,7 +226,7 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
||||
|
||||
|
||||
@CatchException
|
||||
def Markdown翻译指定语言(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def Markdown翻译指定语言(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
|
||||
@@ -101,7 +101,7 @@ do not have too much repetitive information, numerical values using the original
|
||||
|
||||
|
||||
@CatchException
|
||||
def 批量总结PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 批量总结PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
import glob, os
|
||||
|
||||
# 基本信息:功能、贡献者
|
||||
|
||||
@@ -124,7 +124,7 @@ def 解析Paper(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo
|
||||
|
||||
|
||||
@CatchException
|
||||
def 批量总结PDF文档pdfminer(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 批量总结PDF文档pdfminer(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ def markdown_to_dict(article_content):
|
||||
|
||||
|
||||
@CatchException
|
||||
def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
|
||||
disable_auto_promotion(chatbot)
|
||||
# 基本信息:功能、贡献者
|
||||
|
||||
@@ -10,7 +10,7 @@ import os
|
||||
|
||||
|
||||
@CatchException
|
||||
def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
|
||||
disable_auto_promotion(chatbot)
|
||||
# 基本信息:功能、贡献者
|
||||
|
||||
@@ -50,7 +50,7 @@ def get_code_block(reply):
|
||||
return matches[0].strip('python') # code block
|
||||
|
||||
@CatchException
|
||||
def 动画生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 动画生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -58,7 +58,7 @@ def 动画生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
# 清空历史,以免输入溢出
|
||||
history = []
|
||||
|
||||
@@ -63,7 +63,7 @@ def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
|
||||
|
||||
|
||||
@CatchException
|
||||
def 理解PDF文档内容标准文件输入(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 理解PDF文档内容标准文件输入(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
import glob, os
|
||||
|
||||
# 基本信息:功能、贡献者
|
||||
|
||||
@@ -36,7 +36,7 @@ def 生成函数注释(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
||||
|
||||
|
||||
@CatchException
|
||||
def 批量生成函数注释(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 批量生成函数注释(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
|
||||
296
crazy_functions/生成多种Mermaid图表.py
普通文件
296
crazy_functions/生成多种Mermaid图表.py
普通文件
@@ -0,0 +1,296 @@
|
||||
from toolbox import CatchException, update_ui, report_exception
|
||||
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
||||
import datetime
|
||||
|
||||
#以下是每类图表的PROMPT
|
||||
SELECT_PROMPT = """
|
||||
“{subject}”
|
||||
=============
|
||||
以上是从文章中提取的摘要,将会使用这些摘要绘制图表。请你选择一个合适的图表类型:
|
||||
1 流程图
|
||||
2 序列图
|
||||
3 类图
|
||||
4 饼图
|
||||
5 甘特图
|
||||
6 状态图
|
||||
7 实体关系图
|
||||
8 象限提示图
|
||||
不需要解释原因,仅需要输出单个不带任何标点符号的数字。
|
||||
"""
|
||||
#没有思维导图!!!测试发现模型始终会优先选择思维导图
|
||||
#流程图
|
||||
PROMPT_1 = """
|
||||
请你给出围绕“{subject}”的逻辑关系图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
graph TD
|
||||
P(编程) --> L1(Python)
|
||||
P(编程) --> L2(C)
|
||||
P(编程) --> L3(C++)
|
||||
P(编程) --> L4(Javascipt)
|
||||
P(编程) --> L5(PHP)
|
||||
```
|
||||
"""
|
||||
#序列图
|
||||
PROMPT_2 = """
|
||||
请你给出围绕“{subject}”的序列图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant A as 用户
|
||||
participant B as 系统
|
||||
A->>B: 登录请求
|
||||
B->>A: 登录成功
|
||||
A->>B: 获取数据
|
||||
B->>A: 返回数据
|
||||
```
|
||||
"""
|
||||
#类图
|
||||
PROMPT_3 = """
|
||||
请你给出围绕“{subject}”的类图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
classDiagram
|
||||
Class01 <|-- AveryLongClass : Cool
|
||||
Class03 *-- Class04
|
||||
Class05 o-- Class06
|
||||
Class07 .. Class08
|
||||
Class09 --> C2 : Where am i?
|
||||
Class09 --* C3
|
||||
Class09 --|> Class07
|
||||
Class07 : equals()
|
||||
Class07 : Object[] elementData
|
||||
Class01 : size()
|
||||
Class01 : int chimp
|
||||
Class01 : int gorilla
|
||||
Class08 <--> C2: Cool label
|
||||
```
|
||||
"""
|
||||
#饼图
|
||||
PROMPT_4 = """
|
||||
请你给出围绕“{subject}”的饼图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
pie title Pets adopted by volunteers
|
||||
"狗" : 386
|
||||
"猫" : 85
|
||||
"兔子" : 15
|
||||
```
|
||||
"""
|
||||
#甘特图
|
||||
PROMPT_5 = """
|
||||
请你给出围绕“{subject}”的甘特图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
gantt
|
||||
title 项目开发流程
|
||||
dateFormat YYYY-MM-DD
|
||||
section 设计
|
||||
需求分析 :done, des1, 2024-01-06,2024-01-08
|
||||
原型设计 :active, des2, 2024-01-09, 3d
|
||||
UI设计 : des3, after des2, 5d
|
||||
section 开发
|
||||
前端开发 :2024-01-20, 10d
|
||||
后端开发 :2024-01-20, 10d
|
||||
```
|
||||
"""
|
||||
#状态图
|
||||
PROMPT_6 = """
|
||||
请你给出围绕“{subject}”的状态图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> Still
|
||||
Still --> [*]
|
||||
Still --> Moving
|
||||
Moving --> Still
|
||||
Moving --> Crash
|
||||
Crash --> [*]
|
||||
```
|
||||
"""
|
||||
#实体关系图
|
||||
PROMPT_7 = """
|
||||
请你给出围绕“{subject}”的实体关系图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
erDiagram
|
||||
CUSTOMER ||--o{ ORDER : places
|
||||
ORDER ||--|{ LINE-ITEM : contains
|
||||
CUSTOMER {
|
||||
string name
|
||||
string id
|
||||
}
|
||||
ORDER {
|
||||
string orderNumber
|
||||
date orderDate
|
||||
string customerID
|
||||
}
|
||||
LINE-ITEM {
|
||||
number quantity
|
||||
string productID
|
||||
}
|
||||
```
|
||||
"""
|
||||
#象限提示图
|
||||
PROMPT_8 = """
|
||||
请你给出围绕“{subject}”的象限图,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
graph LR
|
||||
A[Hard skill] --> B(Programming)
|
||||
A[Hard skill] --> C(Design)
|
||||
D[Soft skill] --> E(Coordination)
|
||||
D[Soft skill] --> F(Communication)
|
||||
```
|
||||
"""
|
||||
#思维导图
|
||||
PROMPT_9 = """
|
||||
{subject}
|
||||
==========
|
||||
请给出上方内容的思维导图,充分考虑其之间的逻辑,使用mermaid语法,mermaid语法举例:
|
||||
```mermaid
|
||||
mindmap
|
||||
root((mindmap))
|
||||
Origins
|
||||
Long history
|
||||
::icon(fa fa-book)
|
||||
Popularisation
|
||||
British popular psychology author Tony Buzan
|
||||
Research
|
||||
On effectiveness<br/>and features
|
||||
On Automatic creation
|
||||
Uses
|
||||
Creative techniques
|
||||
Strategic planning
|
||||
Argument mapping
|
||||
Tools
|
||||
Pen and paper
|
||||
Mermaid
|
||||
```
|
||||
"""
|
||||
|
||||
def 解析历史输入(history,llm_kwargs,file_manifest,chatbot,plugin_kwargs):
|
||||
############################## <第 0 步,切割输入> ##################################
|
||||
# 借用PDF切割中的函数对文本进行切割
|
||||
TOKEN_LIMIT_PER_FRAGMENT = 2500
|
||||
txt = str(history).encode('utf-8', 'ignore').decode() # avoid reading non-utf8 chars
|
||||
from crazy_functions.pdf_fns.breakdown_txt import breakdown_text_to_satisfy_token_limit
|
||||
txt = breakdown_text_to_satisfy_token_limit(txt=txt, limit=TOKEN_LIMIT_PER_FRAGMENT, llm_model=llm_kwargs['llm_model'])
|
||||
############################## <第 1 步,迭代地历遍整个文章,提取精炼信息> ##################################
|
||||
results = []
|
||||
MAX_WORD_TOTAL = 4096
|
||||
n_txt = len(txt)
|
||||
last_iteration_result = "从以下文本中提取摘要。"
|
||||
if n_txt >= 20: print('文章极长,不能达到预期效果')
|
||||
for i in range(n_txt):
|
||||
NUM_OF_WORD = MAX_WORD_TOTAL // n_txt
|
||||
i_say = f"Read this section, recapitulate the content of this section with less than {NUM_OF_WORD} words in Chinese: {txt[i]}"
|
||||
i_say_show_user = f"[{i+1}/{n_txt}] Read this section, recapitulate the content of this section with less than {NUM_OF_WORD} words: {txt[i][:200]} ...."
|
||||
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(i_say, i_say_show_user, # i_say=真正给chatgpt的提问, i_say_show_user=给用户看的提问
|
||||
llm_kwargs, chatbot,
|
||||
history=["The main content of the previous section is?", last_iteration_result], # 迭代上一次的结果
|
||||
sys_prompt="Extracts the main content from the text section where it is located for graphing purposes, answer me with Chinese." # 提示
|
||||
)
|
||||
results.append(gpt_say)
|
||||
last_iteration_result = gpt_say
|
||||
############################## <第 2 步,根据整理的摘要选择图表类型> ##################################
|
||||
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
|
||||
gpt_say = plugin_kwargs.get("advanced_arg", "") #将图表类型参数赋值为插件参数
|
||||
results_txt = '\n'.join(results) #合并摘要
|
||||
if gpt_say not in ['1','2','3','4','5','6','7','8','9']: #如插件参数不正确则使用对话模型判断
|
||||
i_say_show_user = f'接下来将判断适合的图表类型,如连续3次判断失败将会使用流程图进行绘制'; gpt_say = "[Local Message] 收到。" # 用户提示
|
||||
chatbot.append([i_say_show_user, gpt_say]); yield from update_ui(chatbot=chatbot, history=[]) # 更新UI
|
||||
i_say = SELECT_PROMPT.format(subject=results_txt)
|
||||
i_say_show_user = f'请判断适合使用的流程图类型,其中数字对应关系为:1-流程图,2-序列图,3-类图,4-饼图,5-甘特图,6-状态图,7-实体关系图,8-象限提示图。由于不管提供文本是什么,模型大概率认为"思维导图"最合适,因此思维导图仅能通过参数调用。'
|
||||
for i in range(3):
|
||||
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
||||
inputs=i_say,
|
||||
inputs_show_user=i_say_show_user,
|
||||
llm_kwargs=llm_kwargs, chatbot=chatbot, history=[],
|
||||
sys_prompt=""
|
||||
)
|
||||
if gpt_say in ['1','2','3','4','5','6','7','8','9']: #判断返回是否正确
|
||||
break
|
||||
if gpt_say not in ['1','2','3','4','5','6','7','8','9']:
|
||||
gpt_say = '1'
|
||||
############################## <第 3 步,根据选择的图表类型绘制图表> ##################################
|
||||
if gpt_say == '1':
|
||||
i_say = PROMPT_1.format(subject=results_txt)
|
||||
elif gpt_say == '2':
|
||||
i_say = PROMPT_2.format(subject=results_txt)
|
||||
elif gpt_say == '3':
|
||||
i_say = PROMPT_3.format(subject=results_txt)
|
||||
elif gpt_say == '4':
|
||||
i_say = PROMPT_4.format(subject=results_txt)
|
||||
elif gpt_say == '5':
|
||||
i_say = PROMPT_5.format(subject=results_txt)
|
||||
elif gpt_say == '6':
|
||||
i_say = PROMPT_6.format(subject=results_txt)
|
||||
elif gpt_say == '7':
|
||||
i_say = PROMPT_7.replace("{subject}", results_txt) #由于实体关系图用到了{}符号
|
||||
elif gpt_say == '8':
|
||||
i_say = PROMPT_8.format(subject=results_txt)
|
||||
elif gpt_say == '9':
|
||||
i_say = PROMPT_9.format(subject=results_txt)
|
||||
i_say_show_user = f'请根据判断结果绘制相应的图表。如需绘制思维导图请使用参数调用,同时过大的图表可能需要复制到在线编辑器中进行渲染。'
|
||||
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
||||
inputs=i_say,
|
||||
inputs_show_user=i_say_show_user,
|
||||
llm_kwargs=llm_kwargs, chatbot=chatbot, history=[],
|
||||
sys_prompt=""
|
||||
)
|
||||
history.append(gpt_say)
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
|
||||
|
||||
@CatchException
|
||||
def 生成多种Mermaid图表(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
plugin_kwargs 插件模型的参数,用于灵活调整复杂功能的各种参数
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
"""
|
||||
import os
|
||||
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
"根据当前聊天历史或指定的路径文件(文件内容优先)绘制多种mermaid图表,将会由对话模型首先判断适合的图表类型,随后绘制图表。\
|
||||
\n您也可以使用插件参数指定绘制的图表类型,函数插件贡献者: Menghuan1918"])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
if os.path.exists(txt): #如输入区无内容则直接解析历史记录
|
||||
from crazy_functions.pdf_fns.parse_word import extract_text_from_files
|
||||
file_exist, final_result, page_one, file_manifest, excption = extract_text_from_files(txt, chatbot, history)
|
||||
else:
|
||||
file_exist = False
|
||||
excption = ""
|
||||
file_manifest = []
|
||||
|
||||
if excption != "":
|
||||
if excption == "word":
|
||||
report_exception(chatbot, history,
|
||||
a = f"解析项目: {txt}",
|
||||
b = f"找到了.doc文件,但是该文件格式不被支持,请先转化为.docx格式。")
|
||||
|
||||
elif excption == "pdf":
|
||||
report_exception(chatbot, history,
|
||||
a = f"解析项目: {txt}",
|
||||
b = f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade pymupdf```。")
|
||||
|
||||
elif excption == "word_pip":
|
||||
report_exception(chatbot, history,
|
||||
a=f"解析项目: {txt}",
|
||||
b=f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade python-docx pywin32```。")
|
||||
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
else:
|
||||
if not file_exist:
|
||||
history.append(txt) #如输入区不是文件则将输入区内容加入历史记录
|
||||
i_say_show_user = f'首先你从历史记录中提取摘要。'; gpt_say = "[Local Message] 收到。" # 用户提示
|
||||
chatbot.append([i_say_show_user, gpt_say]); yield from update_ui(chatbot=chatbot, history=history) # 更新UI
|
||||
yield from 解析历史输入(history,llm_kwargs,file_manifest,chatbot,plugin_kwargs)
|
||||
else:
|
||||
file_num = len(file_manifest)
|
||||
for i in range(file_num): #依次处理文件
|
||||
i_say_show_user = f"[{i+1}/{file_num}]处理文件{file_manifest[i]}"; gpt_say = "[Local Message] 收到。" # 用户提示
|
||||
chatbot.append([i_say_show_user, gpt_say]); yield from update_ui(chatbot=chatbot, history=history) # 更新UI
|
||||
history = [] #如输入区内容为文件则清空历史记录
|
||||
history.append(final_result[i])
|
||||
yield from 解析历史输入(history,llm_kwargs,file_manifest,chatbot,plugin_kwargs)
|
||||
@@ -13,7 +13,7 @@ install_msg ="""
|
||||
"""
|
||||
|
||||
@CatchException
|
||||
def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数, 如温度和top_p等, 一般原样传递下去就行
|
||||
@@ -21,7 +21,7 @@ def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
|
||||
@@ -84,7 +84,7 @@ def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
|
||||
|
||||
@CatchException
|
||||
def 读取知识库作答(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port=-1):
|
||||
def 读取知识库作答(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request=-1):
|
||||
# resolve deps
|
||||
try:
|
||||
# from zh_langchain import construct_vector_store
|
||||
|
||||
@@ -55,7 +55,7 @@ def scrape_text(url, proxies) -> str:
|
||||
return text
|
||||
|
||||
@CatchException
|
||||
def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -63,7 +63,7 @@ def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
chatbot.append((f"请结合互联网信息回答以下问题:{txt}",
|
||||
|
||||
@@ -55,7 +55,7 @@ def scrape_text(url, proxies) -> str:
|
||||
return text
|
||||
|
||||
@CatchException
|
||||
def 连接bing搜索回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 连接bing搜索回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -63,7 +63,7 @@ def 连接bing搜索回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, histor
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
chatbot.append((f"请结合互联网信息回答以下问题:{txt}",
|
||||
|
||||
@@ -104,7 +104,7 @@ def analyze_intention_with_simple_rules(txt):
|
||||
|
||||
|
||||
@CatchException
|
||||
def 虚空终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 虚空终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
disable_auto_promotion(chatbot=chatbot)
|
||||
# 获取当前虚空终端状态
|
||||
state = VoidTerminalState.get_state(chatbot)
|
||||
@@ -121,7 +121,7 @@ def 虚空终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
state.set_state(chatbot=chatbot, key='has_provided_explaination', value=True)
|
||||
state.unlock_plugin(chatbot=chatbot)
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
yield from 虚空终端主路由(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port)
|
||||
yield from 虚空终端主路由(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request)
|
||||
return
|
||||
else:
|
||||
# 如果意图模糊,提示
|
||||
@@ -133,7 +133,7 @@ def 虚空终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
|
||||
|
||||
|
||||
def 虚空终端主路由(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 虚空终端主路由(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = []
|
||||
chatbot.append(("虚空终端状态: ", f"正在执行任务: {txt}"))
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
@@ -12,6 +12,12 @@ class PaperFileGroup():
|
||||
self.sp_file_index = []
|
||||
self.sp_file_tag = []
|
||||
|
||||
# count_token
|
||||
from request_llms.bridge_all import model_info
|
||||
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
||||
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
||||
self.get_token_num = get_token_num
|
||||
|
||||
def run_file_split(self, max_token_limit=1900):
|
||||
"""
|
||||
将长文本分离开来
|
||||
@@ -54,7 +60,7 @@ def parseNotebook(filename, enable_markdown=1):
|
||||
Code += f"This is {idx+1}th code block: \n"
|
||||
Code += code+"\n"
|
||||
|
||||
return Code
|
||||
return Code
|
||||
|
||||
|
||||
def ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
|
||||
@@ -109,7 +115,7 @@ def ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
@CatchException
|
||||
def 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
chatbot.append([
|
||||
"函数插件功能?",
|
||||
"对IPynb文件进行解析。Contributor: codycjy."])
|
||||
|
||||
@@ -83,7 +83,8 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
||||
history=this_iteration_history_feed, # 迭代之前的分析
|
||||
sys_prompt="你是一个程序架构分析师,正在分析一个项目的源代码。" + sys_prompt_additional)
|
||||
|
||||
summary = "请用一句话概括这些文件的整体功能"
|
||||
diagram_code = make_diagram(this_iteration_files, result, this_iteration_history_feed)
|
||||
summary = "请用一句话概括这些文件的整体功能。\n\n" + diagram_code
|
||||
summary_result = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
||||
inputs=summary,
|
||||
inputs_show_user=summary,
|
||||
@@ -104,9 +105,12 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
||||
chatbot.append(("完成了吗?", res))
|
||||
yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面
|
||||
|
||||
def make_diagram(this_iteration_files, result, this_iteration_history_feed):
|
||||
from crazy_functions.diagram_fns.file_tree import build_file_tree_mermaid_diagram
|
||||
return build_file_tree_mermaid_diagram(this_iteration_history_feed[0::2], this_iteration_history_feed[1::2], "项目示意图")
|
||||
|
||||
@CatchException
|
||||
def 解析项目本身(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析项目本身(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob
|
||||
file_manifest = [f for f in glob.glob('./*.py')] + \
|
||||
@@ -119,7 +123,7 @@ def 解析项目本身(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
|
||||
|
||||
@CatchException
|
||||
def 解析一个Python项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个Python项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -137,7 +141,7 @@ def 解析一个Python项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
|
||||
|
||||
@CatchException
|
||||
def 解析一个Matlab项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个Matlab项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -155,7 +159,7 @@ def 解析一个Matlab项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
|
||||
|
||||
@CatchException
|
||||
def 解析一个C项目的头文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个C项目的头文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -175,7 +179,7 @@ def 解析一个C项目的头文件(txt, llm_kwargs, plugin_kwargs, chatbot, his
|
||||
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
|
||||
|
||||
@CatchException
|
||||
def 解析一个C项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个C项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -197,7 +201,7 @@ def 解析一个C项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system
|
||||
|
||||
|
||||
@CatchException
|
||||
def 解析一个Java项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个Java项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -219,7 +223,7 @@ def 解析一个Java项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys
|
||||
|
||||
|
||||
@CatchException
|
||||
def 解析一个前端项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个前端项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -248,7 +252,7 @@ def 解析一个前端项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
|
||||
|
||||
@CatchException
|
||||
def 解析一个Golang项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个Golang项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -269,7 +273,7 @@ def 解析一个Golang项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
|
||||
|
||||
@CatchException
|
||||
def 解析一个Rust项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个Rust项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -289,7 +293,7 @@ def 解析一个Rust项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys
|
||||
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
|
||||
|
||||
@CatchException
|
||||
def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -311,7 +315,7 @@ def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
||||
|
||||
|
||||
@CatchException
|
||||
def 解析一个CSharp项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析一个CSharp项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
@@ -331,7 +335,7 @@ def 解析一个CSharp项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
|
||||
|
||||
|
||||
@CatchException
|
||||
def 解析任意code项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 解析任意code项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
txt_pattern = plugin_kwargs.get("advanced_arg")
|
||||
txt_pattern = txt_pattern.replace(",", ",")
|
||||
# 将要匹配的模式(例如: *.c, *.cpp, *.py, config.toml)
|
||||
|
||||
@@ -2,7 +2,7 @@ from toolbox import CatchException, update_ui, get_conf
|
||||
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
||||
import datetime
|
||||
@CatchException
|
||||
def 同时问询(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 同时问询(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -10,7 +10,7 @@ def 同时问询(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
MULTI_QUERY_LLM_MODELS = get_conf('MULTI_QUERY_LLM_MODELS')
|
||||
@@ -32,7 +32,7 @@ def 同时问询(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
|
||||
|
||||
@CatchException
|
||||
def 同时问询_指定模型(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 同时问询_指定模型(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -40,7 +40,7 @@ def 同时问询_指定模型(txt, llm_kwargs, plugin_kwargs, chatbot, history,
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class InterviewAssistant(AliyunASR):
|
||||
|
||||
|
||||
@CatchException
|
||||
def 语音助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 语音助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
# pip install -U openai-whisper
|
||||
chatbot.append(["对话助手函数插件:使用时,双手离开鼠标键盘吧", "音频助手, 正在听您讲话(点击“停止”键可终止程序)..."])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
@@ -44,7 +44,7 @@ def 解析Paper(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo
|
||||
|
||||
|
||||
@CatchException
|
||||
def 读文章写摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 读文章写摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
import glob, os
|
||||
if os.path.exists(txt):
|
||||
|
||||
@@ -132,7 +132,7 @@ def get_meta_information(url, chatbot, history):
|
||||
return profile
|
||||
|
||||
@CatchException
|
||||
def 谷歌检索小助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 谷歌检索小助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
disable_auto_promotion(chatbot=chatbot)
|
||||
# 基本信息:功能、贡献者
|
||||
chatbot.append([
|
||||
|
||||
@@ -11,7 +11,7 @@ import os
|
||||
|
||||
|
||||
@CatchException
|
||||
def 猜你想问(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 猜你想问(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
if txt:
|
||||
show_say = txt
|
||||
prompt = txt+'\n回答完问题后,再列出用户可能提出的三个问题。'
|
||||
@@ -32,7 +32,7 @@ def 猜你想问(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
||||
|
||||
|
||||
@CatchException
|
||||
def 清除缓存(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 清除缓存(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
chatbot.append(['清除本地缓存数据', '执行中. 删除数据'])
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||
|
||||
|
||||
@@ -1,19 +1,47 @@
|
||||
from toolbox import CatchException, update_ui
|
||||
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
||||
from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
||||
import datetime
|
||||
|
||||
高阶功能模板函数示意图 = f"""
|
||||
```mermaid
|
||||
flowchart TD
|
||||
%% <gpt_academic_hide_mermaid_code> 一个特殊标记,用于在生成mermaid图表时隐藏代码块
|
||||
subgraph 函数调用["函数调用过程"]
|
||||
AA["输入栏用户输入的文本(txt)"] --> BB["gpt模型参数(llm_kwargs)"]
|
||||
BB --> CC["插件模型参数(plugin_kwargs)"]
|
||||
CC --> DD["对话显示框的句柄(chatbot)"]
|
||||
DD --> EE["对话历史(history)"]
|
||||
EE --> FF["系统提示词(system_prompt)"]
|
||||
FF --> GG["当前用户信息(web_port)"]
|
||||
|
||||
A["开始(查询5天历史事件)"]
|
||||
A --> B["获取当前月份和日期"]
|
||||
B --> C["生成历史事件查询提示词"]
|
||||
C --> D["调用大模型"]
|
||||
D --> E["更新界面"]
|
||||
E --> F["记录历史"]
|
||||
F --> |"下一天"| B
|
||||
end
|
||||
```
|
||||
"""
|
||||
|
||||
@CatchException
|
||||
def 高阶功能模板函数(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 高阶功能模板函数(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
# 高阶功能模板函数示意图:https://mermaid.live/edit#pako:eNptk1tvEkEYhv8KmattQpvlvOyFCcdeeaVXuoYssBwie8gyhCIlqVoLhrbbtAWNUpEGUkyMEDW2Fmn_DDOL_8LZHdOwxrnamX3f7_3mmZk6yKhZCfAgV1KrmYKoQ9fDuKC4yChX0nld1Aou1JzjznQ5fWmejh8LYHW6vG2a47YAnlCLNSIRolnenKBXI_zRIBrcuqRT890u7jZx7zMDt-AaMbnW1--5olGiz2sQjwfoQxsZL0hxplSSU0-rop4vrzmKR6O2JxYjHmwcL2Y_HDatVMkXlf86YzHbGY9bO5j8XE7O8Nsbc3iNB3ukL2SMcH-XIQBgWoVOZzxuOxOJOyc63EPGV6ZQLENVrznViYStTiaJ2vw2M2d9bByRnOXkgCnXylCSU5quyto_IcmkbdvctELmJ-j1ASW3uB3g5xOmKqVTmqr_Na3AtuS_dtBFm8H90XJyHkDDT7S9xXWb4HGmRChx64AOL5HRpUm411rM5uh4H78Z4V7fCZzytjZz2seto9XaNPFue07clLaVZF8UNLygJ-VES8lah_n-O-5Ozc7-77NzJ0-K0yr0ZYrmHdqAk50t2RbA4qq9uNohBASw7YpSgaRkLWCCAtxAlnRZLGbJba9bPwUAC5IsCYAnn1kpJ1ZKUACC0iBSsQLVBzUlA3ioVyQ3qGhZEUrxokiehAz4nFgqk1VNVABfB1uAD_g2_AGPl-W8nMcbCvsDblADfNCz4feyobDPy3rYEMtxwYYbPFNVUoHdCPmDHBv2cP4AMfrCbiBli-Q-3afv0X6WdsIjW2-10fgDy1SAig
|
||||
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
plugin_kwargs 插件模型的参数,用于灵活调整复杂功能的各种参数
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
chatbot.append(("这是什么功能?", "[Local Message] 请注意,您正在调用一个[函数插件]的模板,该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板(该函数只有20多行代码)。此外我们也提供可同步处理大量文件的多线程Demo供您参考。您若希望分享新的功能模组,请不吝PR!"))
|
||||
chatbot.append((
|
||||
"您正在调用插件:历史上的今天",
|
||||
"[Local Message] 请注意,您正在调用一个[函数插件]的模板,该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板(该函数只有20多行代码)。此外我们也提供可同步处理大量文件的多线程Demo供您参考。您若希望分享新的功能模组,请不吝PR!" + 高阶功能模板函数示意图))
|
||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
|
||||
for i in range(5):
|
||||
currentMonth = (datetime.date.today() + datetime.timedelta(days=i)).month
|
||||
@@ -43,7 +71,7 @@ graph TD
|
||||
```
|
||||
"""
|
||||
@CatchException
|
||||
def 测试图表渲染(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
def 测试图表渲染(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):
|
||||
"""
|
||||
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
|
||||
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
|
||||
@@ -51,7 +79,7 @@ def 测试图表渲染(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
||||
chatbot 聊天显示框的句柄,用于显示给用户
|
||||
history 聊天历史,前情提要
|
||||
system_prompt 给gpt的静默提醒
|
||||
web_port 当前软件运行的端口号
|
||||
user_request 当前用户的请求信息(IP地址等)
|
||||
"""
|
||||
history = [] # 清空历史,以免输入溢出
|
||||
chatbot.append(("这是什么功能?", "一个测试mermaid绘制图表的功能,您可以在输入框中输入一些关键词,然后使用mermaid+llm绘制图表。"))
|
||||
|
||||
@@ -13,7 +13,7 @@ COPY . .
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
# 安装语音插件的额外依赖
|
||||
RUN pip3 install pyOpenSSL scipy git+https://github.com/aliyun/alibabacloud-nls-python-sdk.git
|
||||
RUN pip3 install aliyun-python-sdk-core==2.13.3 pyOpenSSL webrtcvad scipy git+https://github.com/aliyun/alibabacloud-nls-python-sdk.git
|
||||
|
||||
# 可选步骤,用于预热模块
|
||||
RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()'
|
||||
|
||||
@@ -165,7 +165,7 @@ toolbox.py是一个工具类库,其中主要包含了一些函数装饰器和
|
||||
|
||||
3. read_file_to_chat(chatbot, history, file_name):从传入的文件中读取内容,解析出对话历史记录并更新聊天显示框。
|
||||
|
||||
4. 对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):一个主要函数,用于保存当前对话记录并提醒用户。如果用户希望加载历史记录,则调用read_file_to_chat()来更新聊天显示框。如果用户希望删除历史记录,调用删除所有本地对话历史记录()函数完成删除操作。
|
||||
4. 对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):一个主要函数,用于保存当前对话记录并提醒用户。如果用户希望加载历史记录,则调用read_file_to_chat()来更新聊天显示框。如果用户希望删除历史记录,调用删除所有本地对话历史记录()函数完成删除操作。
|
||||
|
||||
## [19/48] 请对下面的程序文件做一个概述: crazy_functions\总结word文档.py
|
||||
|
||||
|
||||
@@ -1668,7 +1668,7 @@
|
||||
"Markdown翻译指定语言": "TranslateMarkdownToSpecifiedLanguage",
|
||||
"Langchain知识库": "LangchainKnowledgeBase",
|
||||
"Latex英文纠错加PDF对比": "CorrectEnglishInLatexWithPDFComparison",
|
||||
"Latex输出PDF结果": "OutputPDFFromLatex",
|
||||
"Latex输出PDF": "OutputPDFFromLatex",
|
||||
"Latex翻译中文并重新编译PDF": "TranslateChineseToEnglishInLatexAndRecompilePDF",
|
||||
"sprint亮靛": "SprintIndigo",
|
||||
"寻找Latex主文件": "FindLatexMainFile",
|
||||
@@ -3004,5 +3004,7 @@
|
||||
"1. 上传图片": "TranslatedText",
|
||||
"保存状态": "TranslatedText",
|
||||
"GPT-Academic对话存档": "TranslatedText",
|
||||
"Arxiv论文精细翻译": "TranslatedText"
|
||||
"Arxiv论文精细翻译": "TranslatedText",
|
||||
"from crazy_functions.AdvancedFunctionTemplate import 测试图表渲染": "from crazy_functions.AdvancedFunctionTemplate import test_chart_rendering",
|
||||
"测试图表渲染": "test_chart_rendering"
|
||||
}
|
||||
|
||||
@@ -1492,7 +1492,7 @@
|
||||
"交互功能模板函数": "InteractiveFunctionTemplateFunction",
|
||||
"交互功能函数模板": "InteractiveFunctionFunctionTemplate",
|
||||
"Latex英文纠错加PDF对比": "LatexEnglishErrorCorrectionWithPDFComparison",
|
||||
"Latex输出PDF结果": "LatexOutputPDFResult",
|
||||
"Latex输出PDF": "LatexOutputPDFResult",
|
||||
"Latex翻译中文并重新编译PDF": "TranslateChineseAndRecompilePDF",
|
||||
"语音助手": "VoiceAssistant",
|
||||
"微调数据集生成": "FineTuneDatasetGeneration",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"批量Markdown翻译": "BatchTranslateMarkdown",
|
||||
"连接bing搜索回答问题": "ConnectBingSearchAnswerQuestion",
|
||||
"Langchain知识库": "LangchainKnowledgeBase",
|
||||
"Latex输出PDF结果": "OutputPDFFromLatex",
|
||||
"Latex输出PDF": "OutputPDFFromLatex",
|
||||
"把字符太少的块清除为回车": "ClearBlocksWithTooFewCharactersToNewline",
|
||||
"Latex精细分解与转化": "DecomposeAndConvertLatex",
|
||||
"解析一个C项目的头文件": "ParseCProjectHeaderFiles",
|
||||
@@ -97,5 +97,12 @@
|
||||
"多智能体": "MultiAgent",
|
||||
"图片生成_DALLE2": "ImageGeneration_DALLE2",
|
||||
"图片生成_DALLE3": "ImageGeneration_DALLE3",
|
||||
"图片修改_DALLE2": "ImageModification_DALLE2"
|
||||
}
|
||||
"图片修改_DALLE2": "ImageModification_DALLE2",
|
||||
"生成多种Mermaid图表": "GenerateMultipleMermaidCharts",
|
||||
"知识库文件注入": "InjectKnowledgeBaseFiles",
|
||||
"PDF翻译中文并重新编译PDF": "TranslatePDFToChineseAndRecompilePDF",
|
||||
"随机小游戏": "RandomMiniGame",
|
||||
"互动小游戏": "InteractiveMiniGame",
|
||||
"解析历史输入": "ParseHistoricalInput",
|
||||
"高阶功能模板函数示意图": "HighOrderFunctionTemplateDiagram"
|
||||
}
|
||||
@@ -1468,7 +1468,7 @@
|
||||
"交互功能模板函数": "InteractiveFunctionTemplateFunctions",
|
||||
"交互功能函数模板": "InteractiveFunctionFunctionTemplates",
|
||||
"Latex英文纠错加PDF对比": "LatexEnglishCorrectionWithPDFComparison",
|
||||
"Latex输出PDF结果": "OutputPDFFromLatex",
|
||||
"Latex输出PDF": "OutputPDFFromLatex",
|
||||
"Latex翻译中文并重新编译PDF": "TranslateLatexToChineseAndRecompilePDF",
|
||||
"语音助手": "VoiceAssistant",
|
||||
"微调数据集生成": "FineTuneDatasetGeneration",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
## 1. 安装额外依赖
|
||||
```
|
||||
pip install --upgrade pyOpenSSL scipy git+https://github.com/aliyun/alibabacloud-nls-python-sdk.git
|
||||
pip install --upgrade pyOpenSSL webrtcvad scipy git+https://github.com/aliyun/alibabacloud-nls-python-sdk.git
|
||||
```
|
||||
|
||||
如果因为特色网络问题导致上述命令无法执行:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import tiktoken, copy
|
||||
from functools import lru_cache
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from toolbox import get_conf, trimmed_format_exc
|
||||
from toolbox import get_conf, trimmed_format_exc, apply_gpt_academic_string_mask
|
||||
|
||||
from .bridge_chatgpt import predict_no_ui_long_connection as chatgpt_noui
|
||||
from .bridge_chatgpt import predict as chatgpt_ui
|
||||
@@ -31,6 +31,9 @@ from .bridge_qianfan import predict as qianfan_ui
|
||||
from .bridge_google_gemini import predict as genai_ui
|
||||
from .bridge_google_gemini import predict_no_ui_long_connection as genai_noui
|
||||
|
||||
from .bridge_zhipu import predict_no_ui_long_connection as zhipu_noui
|
||||
from .bridge_zhipu import predict as zhipu_ui
|
||||
|
||||
colors = ['#FF00FF', '#00FFFF', '#FF0000', '#990099', '#009999', '#990044']
|
||||
|
||||
class LazyloadTiktoken(object):
|
||||
@@ -44,13 +47,13 @@ class LazyloadTiktoken(object):
|
||||
tmp = tiktoken.encoding_for_model(model)
|
||||
print('加载tokenizer完毕')
|
||||
return tmp
|
||||
|
||||
|
||||
def encode(self, *args, **kwargs):
|
||||
encoder = self.get_encoder(self.model)
|
||||
encoder = self.get_encoder(self.model)
|
||||
return encoder.encode(*args, **kwargs)
|
||||
|
||||
|
||||
def decode(self, *args, **kwargs):
|
||||
encoder = self.get_encoder(self.model)
|
||||
encoder = self.get_encoder(self.model)
|
||||
return encoder.decode(*args, **kwargs)
|
||||
|
||||
# Endpoint 重定向
|
||||
@@ -63,7 +66,7 @@ azure_endpoint = AZURE_ENDPOINT + f'openai/deployments/{AZURE_ENGINE}/chat/compl
|
||||
# 兼容旧版的配置
|
||||
try:
|
||||
API_URL = get_conf("API_URL")
|
||||
if API_URL != "https://api.openai.com/v1/chat/completions":
|
||||
if API_URL != "https://api.openai.com/v1/chat/completions":
|
||||
openai_endpoint = API_URL
|
||||
print("警告!API_URL配置选项将被弃用,请更换为API_URL_REDIRECT配置")
|
||||
except:
|
||||
@@ -95,7 +98,7 @@ model_info = {
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
},
|
||||
|
||||
|
||||
"gpt-3.5-turbo-16k": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
@@ -150,6 +153,15 @@ model_info = {
|
||||
"token_cnt": get_token_num_gpt4,
|
||||
},
|
||||
|
||||
"gpt-4-turbo-preview": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
"endpoint": openai_endpoint,
|
||||
"max_token": 128000,
|
||||
"tokenizer": tokenizer_gpt4,
|
||||
"token_cnt": get_token_num_gpt4,
|
||||
},
|
||||
|
||||
"gpt-4-1106-preview": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
@@ -159,6 +171,15 @@ model_info = {
|
||||
"token_cnt": get_token_num_gpt4,
|
||||
},
|
||||
|
||||
"gpt-4-0125-preview": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
"endpoint": openai_endpoint,
|
||||
"max_token": 128000,
|
||||
"tokenizer": tokenizer_gpt4,
|
||||
"token_cnt": get_token_num_gpt4,
|
||||
},
|
||||
|
||||
"gpt-3.5-random": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
@@ -167,7 +188,7 @@ model_info = {
|
||||
"tokenizer": tokenizer_gpt4,
|
||||
"token_cnt": get_token_num_gpt4,
|
||||
},
|
||||
|
||||
|
||||
"gpt-4-vision-preview": {
|
||||
"fn_with_ui": chatgpt_vision_ui,
|
||||
"fn_without_ui": chatgpt_vision_noui,
|
||||
@@ -197,16 +218,25 @@ model_info = {
|
||||
"token_cnt": get_token_num_gpt4,
|
||||
},
|
||||
|
||||
# api_2d (此后不需要在此处添加api2d的接口了,因为下面的代码会自动添加)
|
||||
"api2d-gpt-3.5-turbo": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
"endpoint": api2d_endpoint,
|
||||
"max_token": 4096,
|
||||
# 智谱AI
|
||||
"glm-4": {
|
||||
"fn_with_ui": zhipu_ui,
|
||||
"fn_without_ui": zhipu_noui,
|
||||
"endpoint": None,
|
||||
"max_token": 10124 * 8,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
},
|
||||
"glm-3-turbo": {
|
||||
"fn_with_ui": zhipu_ui,
|
||||
"fn_without_ui": zhipu_noui,
|
||||
"endpoint": None,
|
||||
"max_token": 10124 * 4,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
},
|
||||
|
||||
# api_2d (此后不需要在此处添加api2d的接口了,因为下面的代码会自动添加)
|
||||
"api2d-gpt-4": {
|
||||
"fn_with_ui": chatgpt_ui,
|
||||
"fn_without_ui": chatgpt_noui,
|
||||
@@ -530,7 +560,7 @@ if "sparkv2" in AVAIL_LLM_MODELS: # 讯飞星火认知大模型
|
||||
})
|
||||
except:
|
||||
print(trimmed_format_exc())
|
||||
if "sparkv3" in AVAIL_LLM_MODELS: # 讯飞星火认知大模型
|
||||
if "sparkv3" in AVAIL_LLM_MODELS or "sparkv3.5" in AVAIL_LLM_MODELS: # 讯飞星火认知大模型
|
||||
try:
|
||||
from .bridge_spark import predict_no_ui_long_connection as spark_noui
|
||||
from .bridge_spark import predict as spark_ui
|
||||
@@ -542,6 +572,14 @@ if "sparkv3" in AVAIL_LLM_MODELS: # 讯飞星火认知大模型
|
||||
"max_token": 4096,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
},
|
||||
"sparkv3.5": {
|
||||
"fn_with_ui": spark_ui,
|
||||
"fn_without_ui": spark_noui,
|
||||
"endpoint": None,
|
||||
"max_token": 4096,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
}
|
||||
})
|
||||
except:
|
||||
@@ -562,19 +600,17 @@ if "llama2" in AVAIL_LLM_MODELS: # llama2
|
||||
})
|
||||
except:
|
||||
print(trimmed_format_exc())
|
||||
if "zhipuai" in AVAIL_LLM_MODELS: # zhipuai
|
||||
if "zhipuai" in AVAIL_LLM_MODELS: # zhipuai 是glm-4的别名,向后兼容配置
|
||||
try:
|
||||
from .bridge_zhipu import predict_no_ui_long_connection as zhipu_noui
|
||||
from .bridge_zhipu import predict as zhipu_ui
|
||||
model_info.update({
|
||||
"zhipuai": {
|
||||
"fn_with_ui": zhipu_ui,
|
||||
"fn_without_ui": zhipu_noui,
|
||||
"endpoint": None,
|
||||
"max_token": 4096,
|
||||
"max_token": 10124 * 8,
|
||||
"tokenizer": tokenizer_gpt35,
|
||||
"token_cnt": get_token_num_gpt35,
|
||||
}
|
||||
},
|
||||
})
|
||||
except:
|
||||
print(trimmed_format_exc())
|
||||
@@ -617,7 +653,7 @@ AZURE_CFG_ARRAY = get_conf("AZURE_CFG_ARRAY")
|
||||
if len(AZURE_CFG_ARRAY) > 0:
|
||||
for azure_model_name, azure_cfg_dict in AZURE_CFG_ARRAY.items():
|
||||
# 可能会覆盖之前的配置,但这是意料之中的
|
||||
if not azure_model_name.startswith('azure'):
|
||||
if not azure_model_name.startswith('azure'):
|
||||
raise ValueError("AZURE_CFG_ARRAY中配置的模型必须以azure开头")
|
||||
endpoint_ = azure_cfg_dict["AZURE_ENDPOINT"] + \
|
||||
f'openai/deployments/{azure_cfg_dict["AZURE_ENGINE"]}/chat/completions?api-version=2023-05-15'
|
||||
@@ -668,6 +704,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history, sys_prompt, obser
|
||||
"""
|
||||
import threading, time, copy
|
||||
|
||||
inputs = apply_gpt_academic_string_mask(inputs, mode="show_llm")
|
||||
model = llm_kwargs['llm_model']
|
||||
n_model = 1
|
||||
if '&' not in model:
|
||||
@@ -682,7 +719,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history, sys_prompt, obser
|
||||
executor = ThreadPoolExecutor(max_workers=4)
|
||||
models = model.split('&')
|
||||
n_model = len(models)
|
||||
|
||||
|
||||
window_len = len(observe_window)
|
||||
assert window_len==3
|
||||
window_mutex = [["", time.time(), ""] for _ in range(n_model)] + [True]
|
||||
@@ -701,7 +738,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history, sys_prompt, obser
|
||||
time.sleep(0.25)
|
||||
if not window_mutex[-1]: break
|
||||
# 看门狗(watchdog)
|
||||
for i in range(n_model):
|
||||
for i in range(n_model):
|
||||
window_mutex[i][1] = observe_window[1]
|
||||
# 观察窗(window)
|
||||
chat_string = []
|
||||
@@ -741,6 +778,7 @@ def predict(inputs, llm_kwargs, *args, **kwargs):
|
||||
additional_fn代表点击的哪个按钮,按钮见functional.py
|
||||
"""
|
||||
|
||||
inputs = apply_gpt_academic_string_mask(inputs, mode="show_llm")
|
||||
method = model_info[llm_kwargs['llm_model']]["fn_with_ui"] # 如果这里报错,检查config中的AVAIL_LLM_MODELS选项
|
||||
yield from method(inputs, llm_kwargs, *args, **kwargs)
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="",
|
||||
error_msg = get_full_error(chunk, stream_response).decode()
|
||||
if "reduce the length" in error_msg:
|
||||
raise ConnectionAbortedError("OpenAI拒绝了请求:" + error_msg)
|
||||
elif """type":"upstream_error","param":"307""" in error_msg:
|
||||
raise ConnectionAbortedError("正常结束,但显示Token不足,导致输出不完整,请削减单次输入的文本量。")
|
||||
else:
|
||||
raise RuntimeError("OpenAI拒绝了请求:" + error_msg)
|
||||
if ('data: [DONE]' in chunk_decoded): break # api2d 正常完成
|
||||
|
||||
@@ -57,6 +57,10 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
||||
|
||||
if "vision" in llm_kwargs["llm_model"]:
|
||||
have_recent_file, image_paths = have_any_recent_upload_image_files(chatbot)
|
||||
if not have_recent_file:
|
||||
chatbot.append((inputs, "没有检测到任何近期上传的图像文件,请上传jpg格式的图片,此外,请注意拓展名需要小写"))
|
||||
yield from update_ui(chatbot=chatbot, history=history, msg="等待图片") # 刷新界面
|
||||
return
|
||||
def make_media_input(inputs, image_paths):
|
||||
for image_path in image_paths:
|
||||
inputs = inputs + f'<br/><br/><div align="center"><img src="file={os.path.abspath(image_path)}"></div>'
|
||||
|
||||
@@ -146,21 +146,17 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
# 开始接收回复
|
||||
try:
|
||||
response = f"[Local Message] 等待{model_name}响应中 ..."
|
||||
for response in generate_from_baidu_qianfan(inputs, llm_kwargs, history, system_prompt):
|
||||
chatbot[-1] = (inputs, response)
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
history.extend([inputs, response])
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
except ConnectionAbortedError as e:
|
||||
from .bridge_all import model_info
|
||||
if len(history) >= 2: history[-1] = ""; history[-2] = "" # 清除当前溢出的输入:history[-2] 是本次输入, history[-1] 是本次输出
|
||||
history = clip_history(inputs=inputs, history=history, tokenizer=model_info[llm_kwargs['llm_model']]['tokenizer'],
|
||||
history = clip_history(inputs=inputs, history=history, tokenizer=model_info[llm_kwargs['llm_model']]['tokenizer'],
|
||||
max_token_limit=(model_info[llm_kwargs['llm_model']]['max_token'])) # history至少释放二分之一
|
||||
chatbot[-1] = (chatbot[-1][0], "[Local Message] Reduce the length. 本次输入过长, 或历史数据过长. 历史缓存数据已部分释放, 您可以请再次尝试. (若再次失败则更可能是因为输入过长.)")
|
||||
yield from update_ui(chatbot=chatbot, history=history, msg="异常") # 刷新界面
|
||||
return
|
||||
|
||||
# 总结输出
|
||||
response = f"[Local Message] {model_name}响应异常 ..."
|
||||
if response == f"[Local Message] 等待{model_name}响应中 ...":
|
||||
response = f"[Local Message] {model_name}响应异常 ..."
|
||||
history.extend([inputs, response])
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
@@ -51,6 +51,7 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
||||
# 开始接收回复
|
||||
from .com_qwenapi import QwenRequestInstance
|
||||
sri = QwenRequestInstance()
|
||||
response = f"[Local Message] 等待{model_name}响应中 ..."
|
||||
for response in sri.generate(inputs, llm_kwargs, history, system_prompt):
|
||||
chatbot[-1] = (inputs, response)
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
@@ -56,6 +56,7 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
||||
# 开始接收回复
|
||||
from .com_skylark2api import YUNQUERequestInstance
|
||||
sri = YUNQUERequestInstance()
|
||||
response = f"[Local Message] 等待{model_name}响应中 ..."
|
||||
for response in sri.generate(inputs, llm_kwargs, history, system_prompt):
|
||||
chatbot[-1] = (inputs, response)
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
@@ -9,7 +9,7 @@ model_name = '星火认知大模型'
|
||||
|
||||
def validate_key():
|
||||
XFYUN_APPID = get_conf('XFYUN_APPID')
|
||||
if XFYUN_APPID == '00000000' or XFYUN_APPID == '':
|
||||
if XFYUN_APPID == '00000000' or XFYUN_APPID == '':
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -49,9 +49,10 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
||||
from core_functional import handle_core_functionality
|
||||
inputs, history = handle_core_functionality(additional_fn, inputs, history, chatbot)
|
||||
|
||||
# 开始接收回复
|
||||
# 开始接收回复
|
||||
from .com_sparkapi import SparkRequestInstance
|
||||
sri = SparkRequestInstance()
|
||||
response = f"[Local Message] 等待{model_name}响应中 ..."
|
||||
for response in sri.generate(inputs, llm_kwargs, history, system_prompt, use_image_api=True):
|
||||
chatbot[-1] = (inputs, response)
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
|
||||
import time
|
||||
import os
|
||||
from toolbox import update_ui, get_conf, update_ui_lastest_msg
|
||||
from toolbox import check_packages, report_exception
|
||||
from toolbox import check_packages, report_exception, have_any_recent_upload_image_files
|
||||
|
||||
model_name = '智谱AI大模型'
|
||||
zhipuai_default_model = 'glm-4'
|
||||
|
||||
def validate_key():
|
||||
ZHIPUAI_API_KEY = get_conf("ZHIPUAI_API_KEY")
|
||||
if ZHIPUAI_API_KEY == '': return False
|
||||
return True
|
||||
|
||||
def make_media_input(inputs, image_paths):
|
||||
for image_path in image_paths:
|
||||
inputs = inputs + f'<br/><br/><div align="center"><img src="file={os.path.abspath(image_path)}"></div>'
|
||||
return inputs
|
||||
|
||||
def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="", observe_window=[], console_slience=False):
|
||||
"""
|
||||
⭐多线程方法
|
||||
@@ -18,34 +24,40 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="",
|
||||
watch_dog_patience = 5
|
||||
response = ""
|
||||
|
||||
if llm_kwargs["llm_model"] == "zhipuai":
|
||||
llm_kwargs["llm_model"] = zhipuai_default_model
|
||||
|
||||
if validate_key() is False:
|
||||
raise RuntimeError('请配置ZHIPUAI_API_KEY')
|
||||
|
||||
from .com_zhipuapi import ZhipuRequestInstance
|
||||
sri = ZhipuRequestInstance()
|
||||
for response in sri.generate(inputs, llm_kwargs, history, sys_prompt):
|
||||
# 开始接收回复
|
||||
from .com_zhipuglm import ZhipuChatInit
|
||||
zhipu_bro_init = ZhipuChatInit()
|
||||
for chunk, response in zhipu_bro_init.generate_chat(inputs, llm_kwargs, history, sys_prompt):
|
||||
if len(observe_window) >= 1:
|
||||
observe_window[0] = response
|
||||
if len(observe_window) >= 2:
|
||||
if (time.time()-observe_window[1]) > watch_dog_patience: raise RuntimeError("程序终止。")
|
||||
if (time.time() - observe_window[1]) > watch_dog_patience:
|
||||
raise RuntimeError("程序终止。")
|
||||
return response
|
||||
|
||||
def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):
|
||||
|
||||
def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream=True, additional_fn=None):
|
||||
"""
|
||||
⭐单线程方法
|
||||
函数的说明请见 request_llms/bridge_all.py
|
||||
"""
|
||||
chatbot.append((inputs, ""))
|
||||
chatbot.append([inputs, ""])
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
||||
try:
|
||||
check_packages(["zhipuai"])
|
||||
except:
|
||||
yield from update_ui_lastest_msg(f"导入软件依赖失败。使用该模型需要额外依赖,安装方法```pip install zhipuai==1.0.7```。",
|
||||
chatbot=chatbot, history=history, delay=0)
|
||||
yield from update_ui_lastest_msg(f"导入软件依赖失败。使用该模型需要额外依赖,安装方法```pip install --upgrade zhipuai```。",
|
||||
chatbot=chatbot, history=history, delay=0)
|
||||
return
|
||||
|
||||
|
||||
if validate_key() is False:
|
||||
yield from update_ui_lastest_msg(lastmsg="[Local Message] 请配置ZHIPUAI_API_KEY", chatbot=chatbot, history=history, delay=0)
|
||||
return
|
||||
@@ -53,16 +65,29 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
||||
if additional_fn is not None:
|
||||
from core_functional import handle_core_functionality
|
||||
inputs, history = handle_core_functionality(additional_fn, inputs, history, chatbot)
|
||||
|
||||
# 开始接收回复
|
||||
from .com_zhipuapi import ZhipuRequestInstance
|
||||
sri = ZhipuRequestInstance()
|
||||
for response in sri.generate(inputs, llm_kwargs, history, system_prompt):
|
||||
chatbot[-1] = (inputs, response)
|
||||
chatbot[-1] = [inputs, ""]
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
# 总结输出
|
||||
if response == f"[Local Message] 等待{model_name}响应中 ...":
|
||||
response = f"[Local Message] {model_name}响应异常 ..."
|
||||
if llm_kwargs["llm_model"] == "zhipuai":
|
||||
llm_kwargs["llm_model"] = zhipuai_default_model
|
||||
|
||||
if llm_kwargs["llm_model"] in ["glm-4v"]:
|
||||
have_recent_file, image_paths = have_any_recent_upload_image_files(chatbot)
|
||||
if not have_recent_file:
|
||||
chatbot.append((inputs, "没有检测到任何近期上传的图像文件,请上传jpg格式的图片,此外,请注意拓展名需要小写"))
|
||||
yield from update_ui(chatbot=chatbot, history=history, msg="等待图片") # 刷新界面
|
||||
return
|
||||
if have_recent_file:
|
||||
inputs = make_media_input(inputs, image_paths)
|
||||
chatbot[-1] = [inputs, ""]
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
|
||||
# 开始接收回复
|
||||
from .com_zhipuglm import ZhipuChatInit
|
||||
zhipu_bro_init = ZhipuChatInit()
|
||||
for chunk, response in zhipu_bro_init.generate_chat(inputs, llm_kwargs, history, system_prompt):
|
||||
chatbot[-1] = [inputs, response]
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
history.extend([inputs, response])
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
@@ -7,7 +7,7 @@ import os
|
||||
import re
|
||||
import requests
|
||||
from typing import List, Dict, Tuple
|
||||
from toolbox import get_conf, encode_image, get_pictures_list
|
||||
from toolbox import get_conf, encode_image, get_pictures_list, to_markdown_tabs
|
||||
|
||||
proxies, TIMEOUT_SECONDS = get_conf("proxies", "TIMEOUT_SECONDS")
|
||||
|
||||
@@ -112,34 +112,6 @@ def html_local_img(__file, layout="left", max_width=None, max_height=None, md=Tr
|
||||
return a
|
||||
|
||||
|
||||
def to_markdown_tabs(head: list, tabs: list, alignment=":---:", column=False):
|
||||
"""
|
||||
Args:
|
||||
head: 表头:[]
|
||||
tabs: 表值:[[列1], [列2], [列3], [列4]]
|
||||
alignment: :--- 左对齐, :---: 居中对齐, ---: 右对齐
|
||||
column: True to keep data in columns, False to keep data in rows (default).
|
||||
Returns:
|
||||
A string representation of the markdown table.
|
||||
"""
|
||||
if column:
|
||||
transposed_tabs = list(map(list, zip(*tabs)))
|
||||
else:
|
||||
transposed_tabs = tabs
|
||||
# Find the maximum length among the columns
|
||||
max_len = max(len(column) for column in transposed_tabs)
|
||||
|
||||
tab_format = "| %s "
|
||||
tabs_list = "".join([tab_format % i for i in head]) + "|\n"
|
||||
tabs_list += "".join([tab_format % alignment for i in head]) + "|\n"
|
||||
|
||||
for i in range(max_len):
|
||||
row_data = [tab[i] if i < len(tab) else "" for tab in transposed_tabs]
|
||||
row_data = file_manifest_filter_html(row_data, filter_=None)
|
||||
tabs_list += "".join([tab_format % i for i in row_data]) + "|\n"
|
||||
|
||||
return tabs_list
|
||||
|
||||
|
||||
class GoogleChatInit:
|
||||
def __init__(self):
|
||||
|
||||
@@ -65,6 +65,7 @@ class SparkRequestInstance():
|
||||
self.gpt_url = "ws://spark-api.xf-yun.com/v1.1/chat"
|
||||
self.gpt_url_v2 = "ws://spark-api.xf-yun.com/v2.1/chat"
|
||||
self.gpt_url_v3 = "ws://spark-api.xf-yun.com/v3.1/chat"
|
||||
self.gpt_url_v35 = "wss://spark-api.xf-yun.com/v3.5/chat"
|
||||
self.gpt_url_img = "wss://spark-api.cn-huabei-1.xf-yun.com/v2.1/image"
|
||||
|
||||
self.time_to_yield_event = threading.Event()
|
||||
@@ -91,6 +92,8 @@ class SparkRequestInstance():
|
||||
gpt_url = self.gpt_url_v2
|
||||
elif llm_kwargs['llm_model'] == 'sparkv3':
|
||||
gpt_url = self.gpt_url_v3
|
||||
elif llm_kwargs['llm_model'] == 'sparkv3.5':
|
||||
gpt_url = self.gpt_url_v35
|
||||
else:
|
||||
gpt_url = self.gpt_url
|
||||
file_manifest = []
|
||||
@@ -190,6 +193,7 @@ def gen_params(appid, inputs, llm_kwargs, history, system_prompt, file_manifest)
|
||||
"spark": "general",
|
||||
"sparkv2": "generalv2",
|
||||
"sparkv3": "generalv3",
|
||||
"sparkv3.5": "generalv3.5",
|
||||
}
|
||||
domains_select = domains[llm_kwargs['llm_model']]
|
||||
if file_manifest: domains_select = 'image'
|
||||
|
||||
84
request_llms/com_zhipuglm.py
普通文件
84
request_llms/com_zhipuglm.py
普通文件
@@ -0,0 +1,84 @@
|
||||
# encoding: utf-8
|
||||
# @Time : 2024/1/22
|
||||
# @Author : Kilig947 & binary husky
|
||||
# @Descr : 兼容最新的智谱Ai
|
||||
from toolbox import get_conf
|
||||
from zhipuai import ZhipuAI
|
||||
from toolbox import get_conf, encode_image, get_pictures_list
|
||||
import logging, os
|
||||
|
||||
|
||||
def input_encode_handler(inputs, llm_kwargs):
|
||||
if llm_kwargs["most_recent_uploaded"].get("path"):
|
||||
image_paths = get_pictures_list(llm_kwargs["most_recent_uploaded"]["path"])
|
||||
md_encode = []
|
||||
for md_path in image_paths:
|
||||
type_ = os.path.splitext(md_path)[1].replace(".", "")
|
||||
type_ = "jpeg" if type_ == "jpg" else type_
|
||||
md_encode.append({"data": encode_image(md_path), "type": type_})
|
||||
return inputs, md_encode
|
||||
|
||||
|
||||
class ZhipuChatInit:
|
||||
|
||||
def __init__(self):
|
||||
ZHIPUAI_API_KEY, ZHIPUAI_MODEL = get_conf("ZHIPUAI_API_KEY", "ZHIPUAI_MODEL")
|
||||
if len(ZHIPUAI_MODEL) > 0:
|
||||
logging.error('ZHIPUAI_MODEL 配置项选项已经弃用,请在LLM_MODEL中配置')
|
||||
self.zhipu_bro = ZhipuAI(api_key=ZHIPUAI_API_KEY)
|
||||
self.model = ''
|
||||
|
||||
def __conversation_user(self, user_input: str, llm_kwargs):
|
||||
if self.model not in ["glm-4v"]:
|
||||
return {"role": "user", "content": user_input}
|
||||
else:
|
||||
input_, encode_img = input_encode_handler(user_input, llm_kwargs=llm_kwargs)
|
||||
what_i_have_asked = {"role": "user", "content": []}
|
||||
what_i_have_asked['content'].append({"type": 'text', "text": user_input})
|
||||
if encode_img:
|
||||
img_d = {"type": "image_url",
|
||||
"image_url": {'url': encode_img}}
|
||||
what_i_have_asked['content'].append(img_d)
|
||||
return what_i_have_asked
|
||||
|
||||
def __conversation_history(self, history, llm_kwargs):
|
||||
messages = []
|
||||
conversation_cnt = len(history) // 2
|
||||
if conversation_cnt:
|
||||
for index in range(0, 2 * conversation_cnt, 2):
|
||||
what_i_have_asked = self.__conversation_user(history[index], llm_kwargs)
|
||||
what_gpt_answer = {
|
||||
"role": "assistant",
|
||||
"content": history[index + 1]
|
||||
}
|
||||
messages.append(what_i_have_asked)
|
||||
messages.append(what_gpt_answer)
|
||||
return messages
|
||||
|
||||
def __conversation_message_payload(self, inputs, llm_kwargs, history, system_prompt):
|
||||
messages = []
|
||||
if system_prompt:
|
||||
messages.append({"role": "system", "content": system_prompt})
|
||||
self.model = llm_kwargs['llm_model']
|
||||
messages.extend(self.__conversation_history(history, llm_kwargs)) # 处理 history
|
||||
messages.append(self.__conversation_user(inputs, llm_kwargs)) # 处理用户对话
|
||||
response = self.zhipu_bro.chat.completions.create(
|
||||
model=self.model, messages=messages, stream=True,
|
||||
temperature=llm_kwargs.get('temperature', 0.95) * 0.95, # 只能传默认的 temperature 和 top_p
|
||||
top_p=llm_kwargs.get('top_p', 0.7) * 0.7,
|
||||
max_tokens=llm_kwargs.get('max_tokens', 1024 * 4), # 最大输出模型的一半
|
||||
)
|
||||
return response
|
||||
|
||||
def generate_chat(self, inputs, llm_kwargs, history, system_prompt):
|
||||
self.model = llm_kwargs['llm_model']
|
||||
response = self.__conversation_message_payload(inputs, llm_kwargs, history, system_prompt)
|
||||
bro_results = ''
|
||||
for chunk in response:
|
||||
bro_results += chunk.choices[0].delta.content
|
||||
yield chunk.choices[0].delta.content, bro_results
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
zhipu = ZhipuChatInit()
|
||||
zhipu.generate_chat('你好', {'llm_model': 'glm-4'}, [], '你是WPSAi')
|
||||
1
request_llms/moss
子模块
1
request_llms/moss
子模块
子模块 request_llms/moss 已添加到 4d905bcead
@@ -1,8 +1,10 @@
|
||||
pydantic==1.10.11
|
||||
https://public.agent-matrix.com/publish/gradio-3.32.8-py3-none-any.whl
|
||||
gradio-client==0.8
|
||||
pypdf2==2.12.1
|
||||
zhipuai<2
|
||||
zhipuai>=2
|
||||
tiktoken>=0.3.3
|
||||
requests[socks]
|
||||
pydantic==2.5.2
|
||||
protobuf==3.18
|
||||
transformers>=4.27.1
|
||||
scipdf_parser>=0.52
|
||||
|
||||
@@ -4,62 +4,47 @@ import os
|
||||
import math
|
||||
from textwrap import dedent
|
||||
from functools import lru_cache
|
||||
from pymdownx.superfences import fence_div_format, fence_code_format
|
||||
from pymdownx.superfences import fence_code_format
|
||||
from latex2mathml.converter import convert as tex2mathml
|
||||
from shared_utils.config_loader import get_conf as get_conf
|
||||
|
||||
pj = os.path.join
|
||||
default_user_name = 'default_user'
|
||||
from shared_utils.text_mask import apply_gpt_academic_string_mask
|
||||
|
||||
markdown_extension_configs = {
|
||||
'mdx_math': {
|
||||
'enable_dollar_delimiter': True,
|
||||
'use_gitlab_delimiters': False,
|
||||
"mdx_math": {
|
||||
"enable_dollar_delimiter": True,
|
||||
"use_gitlab_delimiters": False,
|
||||
},
|
||||
}
|
||||
|
||||
code_highlight_configs = {
|
||||
"pymdownx.superfences": {
|
||||
'css_class': 'codehilite',
|
||||
"css_class": "codehilite",
|
||||
"custom_fences": [
|
||||
{
|
||||
'name': 'mermaid',
|
||||
'class': 'mermaid',
|
||||
'format': fence_code_format
|
||||
}
|
||||
]
|
||||
{"name": "mermaid", "class": "mermaid", "format": fence_code_format}
|
||||
],
|
||||
},
|
||||
"pymdownx.highlight": {
|
||||
'css_class': 'codehilite',
|
||||
'guess_lang': True,
|
||||
"css_class": "codehilite",
|
||||
"guess_lang": True,
|
||||
# 'auto_title': True,
|
||||
# 'linenums': True
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
def text_divide_paragraph(text):
|
||||
"""
|
||||
将文本按照段落分隔符分割开,生成带有段落标签的HTML代码。
|
||||
"""
|
||||
pre = '<div class="markdown-body">'
|
||||
suf = '</div>'
|
||||
if text.startswith(pre) and text.endswith(suf):
|
||||
return text
|
||||
|
||||
if '```' in text:
|
||||
# careful input
|
||||
return text
|
||||
elif '</div>' in text:
|
||||
# careful input
|
||||
return text
|
||||
else:
|
||||
# whatever input
|
||||
lines = text.split("\n")
|
||||
for i, line in enumerate(lines):
|
||||
lines[i] = lines[i].replace(" ", " ")
|
||||
text = "</br>".join(lines)
|
||||
return pre + text + suf
|
||||
|
||||
code_highlight_configs_block_mermaid = {
|
||||
"pymdownx.superfences": {
|
||||
"css_class": "codehilite",
|
||||
# "custom_fences": [
|
||||
# {"name": "mermaid", "class": "mermaid", "format": fence_code_format}
|
||||
# ],
|
||||
},
|
||||
"pymdownx.highlight": {
|
||||
"css_class": "codehilite",
|
||||
"guess_lang": True,
|
||||
# 'auto_title': True,
|
||||
# 'linenums': True
|
||||
},
|
||||
}
|
||||
|
||||
def tex2mathml_catch_exception(content, *args, **kwargs):
|
||||
try:
|
||||
@@ -71,20 +56,20 @@ def tex2mathml_catch_exception(content, *args, **kwargs):
|
||||
|
||||
def replace_math_no_render(match):
|
||||
content = match.group(1)
|
||||
if 'mode=display' in match.group(0):
|
||||
content = content.replace('\n', '</br>')
|
||||
return f"<font color=\"#00FF00\">$$</font><font color=\"#FF00FF\">{content}</font><font color=\"#00FF00\">$$</font>"
|
||||
if "mode=display" in match.group(0):
|
||||
content = content.replace("\n", "</br>")
|
||||
return f'<font color="#00FF00">$$</font><font color="#FF00FF">{content}</font><font color="#00FF00">$$</font>'
|
||||
else:
|
||||
return f"<font color=\"#00FF00\">$</font><font color=\"#FF00FF\">{content}</font><font color=\"#00FF00\">$</font>"
|
||||
return f'<font color="#00FF00">$</font><font color="#FF00FF">{content}</font><font color="#00FF00">$</font>'
|
||||
|
||||
|
||||
def replace_math_render(match):
|
||||
content = match.group(1)
|
||||
if 'mode=display' in match.group(0):
|
||||
if '\\begin{aligned}' in content:
|
||||
content = content.replace('\\begin{aligned}', '\\begin{array}')
|
||||
content = content.replace('\\end{aligned}', '\\end{array}')
|
||||
content = content.replace('&', ' ')
|
||||
if "mode=display" in match.group(0):
|
||||
if "\\begin{aligned}" in content:
|
||||
content = content.replace("\\begin{aligned}", "\\begin{array}")
|
||||
content = content.replace("\\end{aligned}", "\\end{array}")
|
||||
content = content.replace("&", " ")
|
||||
content = tex2mathml_catch_exception(content, display="block")
|
||||
return content
|
||||
else:
|
||||
@@ -95,9 +80,11 @@ def markdown_bug_hunt(content):
|
||||
"""
|
||||
解决一个mdx_math的bug(单$包裹begin命令时多余<script>)
|
||||
"""
|
||||
content = content.replace('<script type="math/tex">\n<script type="math/tex; mode=display">',
|
||||
'<script type="math/tex; mode=display">')
|
||||
content = content.replace('</script>\n</script>', '</script>')
|
||||
content = content.replace(
|
||||
'<script type="math/tex">\n<script type="math/tex; mode=display">',
|
||||
'<script type="math/tex; mode=display">',
|
||||
)
|
||||
content = content.replace("</script>\n</script>", "</script>")
|
||||
return content
|
||||
|
||||
|
||||
@@ -105,25 +92,29 @@ def is_equation(txt):
|
||||
"""
|
||||
判定是否为公式 | 测试1 写出洛伦兹定律,使用tex格式公式 测试2 给出柯西不等式,使用latex格式 测试3 写出麦克斯韦方程组
|
||||
"""
|
||||
if '```' in txt and '```reference' not in txt: return False
|
||||
if '$' not in txt and '\\[' not in txt: return False
|
||||
if "```" in txt and "```reference" not in txt:
|
||||
return False
|
||||
if "$" not in txt and "\\[" not in txt:
|
||||
return False
|
||||
mathpatterns = {
|
||||
r'(?<!\\|\$)(\$)([^\$]+)(\$)': {'allow_multi_lines': False}, # $...$
|
||||
r'(?<!\\)(\$\$)([^\$]+)(\$\$)': {'allow_multi_lines': True}, # $$...$$
|
||||
r'(?<!\\)(\\\[)(.+?)(\\\])': {'allow_multi_lines': False}, # \[...\]
|
||||
r"(?<!\\|\$)(\$)([^\$]+)(\$)": {"allow_multi_lines": False}, # $...$
|
||||
r"(?<!\\)(\$\$)([^\$]+)(\$\$)": {"allow_multi_lines": True}, # $$...$$
|
||||
r"(?<!\\)(\\\[)(.+?)(\\\])": {"allow_multi_lines": False}, # \[...\]
|
||||
# r'(?<!\\)(\\\()(.+?)(\\\))': {'allow_multi_lines': False}, # \(...\)
|
||||
# r'(?<!\\)(\\begin{([a-z]+?\*?)})(.+?)(\\end{\2})': {'allow_multi_lines': True}, # \begin...\end
|
||||
# r'(?<!\\)(\$`)([^`]+)(`\$)': {'allow_multi_lines': False}, # $`...`$
|
||||
}
|
||||
matches = []
|
||||
for pattern, property in mathpatterns.items():
|
||||
flags = re.ASCII | re.DOTALL if property['allow_multi_lines'] else re.ASCII
|
||||
flags = re.ASCII | re.DOTALL if property["allow_multi_lines"] else re.ASCII
|
||||
matches.extend(re.findall(pattern, txt, flags))
|
||||
if len(matches) == 0: return False
|
||||
if len(matches) == 0:
|
||||
return False
|
||||
contain_any_eq = False
|
||||
illegal_pattern = re.compile(r'[^\x00-\x7F]|echo')
|
||||
illegal_pattern = re.compile(r"[^\x00-\x7F]|echo")
|
||||
for match in matches:
|
||||
if len(match) != 3: return False
|
||||
if len(match) != 3:
|
||||
return False
|
||||
eq_canidate = match[1]
|
||||
if illegal_pattern.search(eq_canidate):
|
||||
return False
|
||||
@@ -134,27 +125,28 @@ def is_equation(txt):
|
||||
|
||||
def fix_markdown_indent(txt):
|
||||
# fix markdown indent
|
||||
if (' - ' not in txt) or ('. ' not in txt):
|
||||
if (" - " not in txt) or (". " not in txt):
|
||||
# do not need to fix, fast escape
|
||||
return txt
|
||||
# walk through the lines and fix non-standard indentation
|
||||
lines = txt.split("\n")
|
||||
pattern = re.compile(r'^\s+-')
|
||||
pattern = re.compile(r"^\s+-")
|
||||
activated = False
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith('- ') or line.startswith('1. '):
|
||||
if line.startswith("- ") or line.startswith("1. "):
|
||||
activated = True
|
||||
if activated and pattern.match(line):
|
||||
stripped_string = line.lstrip()
|
||||
num_spaces = len(line) - len(stripped_string)
|
||||
if (num_spaces % 4) == 3:
|
||||
num_spaces_should_be = math.ceil(num_spaces / 4) * 4
|
||||
lines[i] = ' ' * num_spaces_should_be + stripped_string
|
||||
return '\n'.join(lines)
|
||||
lines[i] = " " * num_spaces_should_be + stripped_string
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
FENCED_BLOCK_RE = re.compile(
|
||||
dedent(r'''
|
||||
dedent(
|
||||
r"""
|
||||
(?P<fence>^[ \t]*(?:~{3,}|`{3,}))[ ]* # opening fence
|
||||
((\{(?P<attrs>[^\}\n]*)\})| # (optional {attrs} or
|
||||
(\.?(?P<lang>[\w#.+-]*)[ ]*)? # optional (.)lang
|
||||
@@ -162,16 +154,17 @@ FENCED_BLOCK_RE = re.compile(
|
||||
\n # newline (end of opening fence)
|
||||
(?P<code>.*?)(?<=\n) # the code block
|
||||
(?P=fence)[ ]*$ # closing fence
|
||||
'''),
|
||||
re.MULTILINE | re.DOTALL | re.VERBOSE
|
||||
"""
|
||||
),
|
||||
re.MULTILINE | re.DOTALL | re.VERBOSE,
|
||||
)
|
||||
|
||||
|
||||
def get_line_range(re_match_obj, txt):
|
||||
start_pos, end_pos = re_match_obj.regs[0]
|
||||
num_newlines_before = txt[:start_pos+1].count('\n')
|
||||
num_newlines_before = txt[: start_pos + 1].count("\n")
|
||||
line_start = num_newlines_before
|
||||
line_end = num_newlines_before + txt[start_pos:end_pos].count('\n')+1
|
||||
line_end = num_newlines_before + txt[start_pos:end_pos].count("\n") + 1
|
||||
return line_start, line_end
|
||||
|
||||
|
||||
@@ -181,14 +174,16 @@ def fix_code_segment_indent(txt):
|
||||
txt_tmp = txt
|
||||
while True:
|
||||
re_match_obj = FENCED_BLOCK_RE.search(txt_tmp)
|
||||
if not re_match_obj: break
|
||||
if len(lines) == 0: lines = txt.split("\n")
|
||||
|
||||
if not re_match_obj:
|
||||
break
|
||||
if len(lines) == 0:
|
||||
lines = txt.split("\n")
|
||||
|
||||
# 清空 txt_tmp 对应的位置方便下次搜索
|
||||
start_pos, end_pos = re_match_obj.regs[0]
|
||||
txt_tmp = txt_tmp[:start_pos] + ' '*(end_pos-start_pos) + txt_tmp[end_pos:]
|
||||
txt_tmp = txt_tmp[:start_pos] + " " * (end_pos - start_pos) + txt_tmp[end_pos:]
|
||||
line_start, line_end = get_line_range(re_match_obj, txt)
|
||||
|
||||
|
||||
# 获取公共缩进
|
||||
shared_indent_cnt = 1e5
|
||||
for i in range(line_start, line_end):
|
||||
@@ -202,26 +197,26 @@ def fix_code_segment_indent(txt):
|
||||
num_spaces_should_be = math.ceil(shared_indent_cnt / 4) * 4
|
||||
for i in range(line_start, line_end):
|
||||
add_n = num_spaces_should_be - shared_indent_cnt
|
||||
lines[i] = ' ' * add_n + lines[i]
|
||||
if not change_any: # 遇到第一个
|
||||
lines[i] = " " * add_n + lines[i]
|
||||
if not change_any: # 遇到第一个
|
||||
change_any = True
|
||||
|
||||
if change_any:
|
||||
return '\n'.join(lines)
|
||||
return "\n".join(lines)
|
||||
else:
|
||||
return txt
|
||||
|
||||
|
||||
@lru_cache(maxsize=128) # 使用 lru缓存 加快转换速度
|
||||
|
||||
|
||||
@lru_cache(maxsize=128) # 使用 lru缓存 加快转换速度
|
||||
def markdown_convertion(txt):
|
||||
"""
|
||||
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
||||
"""
|
||||
pre = '<div class="markdown-body">'
|
||||
suf = '</div>'
|
||||
suf = "</div>"
|
||||
if txt.startswith(pre) and txt.endswith(suf):
|
||||
# print('警告,输入了已经经过转化的字符串,二次转化可能出问题')
|
||||
return txt # 已经被转化过,不需要再次转化
|
||||
return txt # 已经被转化过,不需要再次转化
|
||||
|
||||
find_equation_pattern = r'<script type="math/tex(?:.*?)>(.*?)</script>'
|
||||
|
||||
@@ -229,18 +224,47 @@ def markdown_convertion(txt):
|
||||
# txt = fix_code_segment_indent(txt)
|
||||
if is_equation(txt): # 有$标识的公式符号,且没有代码段```的标识
|
||||
# convert everything to html format
|
||||
split = markdown.markdown(text='---')
|
||||
convert_stage_1 = markdown.markdown(text=txt, extensions=['sane_lists', 'tables', 'mdx_math', 'pymdownx.superfences', 'pymdownx.highlight'],
|
||||
extension_configs={**markdown_extension_configs, **code_highlight_configs})
|
||||
split = markdown.markdown(text="---")
|
||||
convert_stage_1 = markdown.markdown(
|
||||
text=txt,
|
||||
extensions=[
|
||||
"sane_lists",
|
||||
"tables",
|
||||
"mdx_math",
|
||||
"pymdownx.superfences",
|
||||
"pymdownx.highlight",
|
||||
],
|
||||
extension_configs={**markdown_extension_configs, **code_highlight_configs},
|
||||
)
|
||||
convert_stage_1 = markdown_bug_hunt(convert_stage_1)
|
||||
# 1. convert to easy-to-copy tex (do not render math)
|
||||
convert_stage_2_1, n = re.subn(find_equation_pattern, replace_math_no_render, convert_stage_1, flags=re.DOTALL)
|
||||
convert_stage_2_1, n = re.subn(
|
||||
find_equation_pattern,
|
||||
replace_math_no_render,
|
||||
convert_stage_1,
|
||||
flags=re.DOTALL,
|
||||
)
|
||||
# 2. convert to rendered equation
|
||||
convert_stage_2_2, n = re.subn(find_equation_pattern, replace_math_render, convert_stage_1, flags=re.DOTALL)
|
||||
convert_stage_2_2, n = re.subn(
|
||||
find_equation_pattern, replace_math_render, convert_stage_1, flags=re.DOTALL
|
||||
)
|
||||
# cat them together
|
||||
return pre + convert_stage_2_1 + f'{split}' + convert_stage_2_2 + suf
|
||||
return pre + convert_stage_2_1 + f"{split}" + convert_stage_2_2 + suf
|
||||
else:
|
||||
return pre + markdown.markdown(txt, extensions=['sane_lists', 'tables', 'pymdownx.superfences', 'pymdownx.highlight'], extension_configs=code_highlight_configs) + suf
|
||||
return (
|
||||
pre
|
||||
+ markdown.markdown(
|
||||
txt,
|
||||
extensions=[
|
||||
"sane_lists",
|
||||
"tables",
|
||||
"pymdownx.superfences",
|
||||
"pymdownx.highlight",
|
||||
],
|
||||
extension_configs=code_highlight_configs,
|
||||
)
|
||||
+ suf
|
||||
)
|
||||
|
||||
|
||||
def close_up_code_segment_during_stream(gpt_reply):
|
||||
@@ -254,20 +278,67 @@ def close_up_code_segment_during_stream(gpt_reply):
|
||||
str: 返回一个新的字符串,将输出代码片段的“后面的```”补上。
|
||||
|
||||
"""
|
||||
if '```' not in gpt_reply:
|
||||
if "```" not in gpt_reply:
|
||||
return gpt_reply
|
||||
if gpt_reply.endswith('```'):
|
||||
if gpt_reply.endswith("```"):
|
||||
return gpt_reply
|
||||
|
||||
# 排除了以上两个情况,我们
|
||||
segments = gpt_reply.split('```')
|
||||
segments = gpt_reply.split("```")
|
||||
n_mark = len(segments) - 1
|
||||
if n_mark % 2 == 1:
|
||||
return gpt_reply + '\n```' # 输出代码片段中!
|
||||
return gpt_reply + "\n```" # 输出代码片段中!
|
||||
else:
|
||||
return gpt_reply
|
||||
|
||||
|
||||
def special_render_issues_for_mermaid(text):
|
||||
# 用不太优雅的方式处理一个core_functional.py中出现的mermaid渲染特例:
|
||||
# 我不希望"总结绘制脑图"prompt中的mermaid渲染出来
|
||||
@lru_cache(maxsize=1)
|
||||
def get_special_case():
|
||||
from core_functional import get_core_functions
|
||||
special_case = get_core_functions()["总结绘制脑图"]["Suffix"]
|
||||
return special_case
|
||||
if text.endswith(get_special_case()): text = text.replace("```mermaid", "```")
|
||||
return text
|
||||
|
||||
|
||||
def compat_non_markdown_input(text):
|
||||
"""
|
||||
改善非markdown输入的显示效果,例如将空格转换为 ,将换行符转换为</br>等。
|
||||
"""
|
||||
if "```" in text:
|
||||
# careful input:markdown输入
|
||||
text = special_render_issues_for_mermaid(text) # 处理特殊的渲染问题
|
||||
return text
|
||||
elif "</div>" in text:
|
||||
# careful input:html输入
|
||||
return text
|
||||
else:
|
||||
# whatever input:非markdown输入
|
||||
lines = text.split("\n")
|
||||
for i, line in enumerate(lines):
|
||||
lines[i] = lines[i].replace(" ", " ") # 空格转换为
|
||||
text = "</br>".join(lines) # 换行符转换为</br>
|
||||
return text
|
||||
|
||||
|
||||
@lru_cache(maxsize=128) # 使用lru缓存
|
||||
def simple_markdown_convertion(text):
|
||||
pre = '<div class="markdown-body">'
|
||||
suf = "</div>"
|
||||
if text.startswith(pre) and text.endswith(suf):
|
||||
return text # 已经被转化过,不需要再次转化
|
||||
text = compat_non_markdown_input(text) # 兼容非markdown输入
|
||||
text = markdown.markdown(
|
||||
text,
|
||||
extensions=["pymdownx.superfences", "tables", "pymdownx.highlight"],
|
||||
extension_configs=code_highlight_configs,
|
||||
)
|
||||
return pre + text + suf
|
||||
|
||||
|
||||
def format_io(self, y):
|
||||
"""
|
||||
将输入和输出解析为HTML格式。将y中最后一项的输入部分段落化,并将输出部分的Markdown和数学公式转换为HTML格式。
|
||||
@@ -275,13 +346,16 @@ def format_io(self, y):
|
||||
if y is None or y == []:
|
||||
return []
|
||||
i_ask, gpt_reply = y[-1]
|
||||
# 输入部分太自由,预处理一波
|
||||
if i_ask is not None: i_ask = text_divide_paragraph(i_ask)
|
||||
i_ask = apply_gpt_academic_string_mask(i_ask, mode="show_render")
|
||||
gpt_reply = apply_gpt_academic_string_mask(gpt_reply, mode="show_render")
|
||||
# 当代码输出半截的时候,试着补上后个```
|
||||
if gpt_reply is not None: gpt_reply = close_up_code_segment_during_stream(gpt_reply)
|
||||
# process
|
||||
if gpt_reply is not None:
|
||||
gpt_reply = close_up_code_segment_during_stream(gpt_reply)
|
||||
# 处理提问与输出
|
||||
y[-1] = (
|
||||
None if i_ask is None else markdown.markdown(i_ask, extensions=['pymdownx.superfences', 'tables', 'pymdownx.highlight'], extension_configs=code_highlight_configs),
|
||||
None if gpt_reply is None else markdown_convertion(gpt_reply)
|
||||
# 输入部分
|
||||
None if i_ask is None else simple_markdown_convertion(i_ask),
|
||||
# 输出部分
|
||||
None if gpt_reply is None else markdown_convertion(gpt_reply),
|
||||
)
|
||||
return y
|
||||
|
||||
@@ -52,7 +52,7 @@ def get_plugin_default_kwargs():
|
||||
}
|
||||
chatbot = ChatBotWithCookies(llm_kwargs)
|
||||
|
||||
# txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port
|
||||
# txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request
|
||||
DEFAULT_FN_GROUPS_kwargs = {
|
||||
"main_input": "./README.md",
|
||||
"llm_kwargs": llm_kwargs,
|
||||
@@ -60,7 +60,7 @@ def get_plugin_default_kwargs():
|
||||
"chatbot_with_cookie": chatbot,
|
||||
"history": [],
|
||||
"system_prompt": "You are a good AI.",
|
||||
"web_port": None,
|
||||
"user_request": None,
|
||||
}
|
||||
return DEFAULT_FN_GROUPS_kwargs
|
||||
|
||||
|
||||
137
shared_utils/handle_upload.py
普通文件
137
shared_utils/handle_upload.py
普通文件
@@ -0,0 +1,137 @@
|
||||
import importlib
|
||||
import time
|
||||
import inspect
|
||||
import re
|
||||
import os
|
||||
import base64
|
||||
import gradio
|
||||
import shutil
|
||||
import glob
|
||||
from shared_utils.config_loader import get_conf
|
||||
|
||||
def html_local_file(file):
|
||||
base_path = os.path.dirname(__file__) # 项目目录
|
||||
if os.path.exists(str(file)):
|
||||
file = f'file={file.replace(base_path, ".")}'
|
||||
return file
|
||||
|
||||
|
||||
def html_local_img(__file, layout="left", max_width=None, max_height=None, md=True):
|
||||
style = ""
|
||||
if max_width is not None:
|
||||
style += f"max-width: {max_width};"
|
||||
if max_height is not None:
|
||||
style += f"max-height: {max_height};"
|
||||
__file = html_local_file(__file)
|
||||
a = f'<div align="{layout}"><img src="{__file}" style="{style}"></div>'
|
||||
if md:
|
||||
a = f""
|
||||
return a
|
||||
|
||||
|
||||
def file_manifest_filter_type(file_list, filter_: list = None):
|
||||
new_list = []
|
||||
if not filter_:
|
||||
filter_ = ["png", "jpg", "jpeg"]
|
||||
for file in file_list:
|
||||
if str(os.path.basename(file)).split(".")[-1] in filter_:
|
||||
new_list.append(html_local_img(file, md=False))
|
||||
else:
|
||||
new_list.append(file)
|
||||
return new_list
|
||||
|
||||
|
||||
def zip_extract_member_new(self, member, targetpath, pwd):
|
||||
# 修复中文乱码的问题
|
||||
"""Extract the ZipInfo object 'member' to a physical
|
||||
file on the path targetpath.
|
||||
"""
|
||||
import zipfile
|
||||
if not isinstance(member, zipfile.ZipInfo):
|
||||
member = self.getinfo(member)
|
||||
|
||||
# build the destination pathname, replacing
|
||||
# forward slashes to platform specific separators.
|
||||
arcname = member.filename.replace('/', os.path.sep)
|
||||
arcname = arcname.encode('cp437', errors='replace').decode('gbk', errors='replace')
|
||||
|
||||
if os.path.altsep:
|
||||
arcname = arcname.replace(os.path.altsep, os.path.sep)
|
||||
# interpret absolute pathname as relative, remove drive letter or
|
||||
# UNC path, redundant separators, "." and ".." components.
|
||||
arcname = os.path.splitdrive(arcname)[1]
|
||||
invalid_path_parts = ('', os.path.curdir, os.path.pardir)
|
||||
arcname = os.path.sep.join(x for x in arcname.split(os.path.sep)
|
||||
if x not in invalid_path_parts)
|
||||
if os.path.sep == '\\':
|
||||
# filter illegal characters on Windows
|
||||
arcname = self._sanitize_windows_name(arcname, os.path.sep)
|
||||
|
||||
targetpath = os.path.join(targetpath, arcname)
|
||||
targetpath = os.path.normpath(targetpath)
|
||||
|
||||
# Create all upper directories if necessary.
|
||||
upperdirs = os.path.dirname(targetpath)
|
||||
if upperdirs and not os.path.exists(upperdirs):
|
||||
os.makedirs(upperdirs)
|
||||
|
||||
if member.is_dir():
|
||||
if not os.path.isdir(targetpath):
|
||||
os.mkdir(targetpath)
|
||||
return targetpath
|
||||
|
||||
with self.open(member, pwd=pwd) as source, \
|
||||
open(targetpath, "wb") as target:
|
||||
shutil.copyfileobj(source, target)
|
||||
|
||||
return targetpath
|
||||
|
||||
|
||||
def extract_archive(file_path, dest_dir):
|
||||
import zipfile
|
||||
import tarfile
|
||||
import os
|
||||
|
||||
# Get the file extension of the input file
|
||||
file_extension = os.path.splitext(file_path)[1]
|
||||
|
||||
# Extract the archive based on its extension
|
||||
if file_extension == ".zip":
|
||||
with zipfile.ZipFile(file_path, "r") as zipobj:
|
||||
zipobj._extract_member = lambda a,b,c: zip_extract_member_new(zipobj, a,b,c) # 修复中文乱码的问题
|
||||
zipobj.extractall(path=dest_dir)
|
||||
print("Successfully extracted zip archive to {}".format(dest_dir))
|
||||
|
||||
elif file_extension in [".tar", ".gz", ".bz2"]:
|
||||
with tarfile.open(file_path, "r:*") as tarobj:
|
||||
tarobj.extractall(path=dest_dir)
|
||||
print("Successfully extracted tar archive to {}".format(dest_dir))
|
||||
|
||||
# 第三方库,需要预先pip install rarfile
|
||||
# 此外,Windows上还需要安装winrar软件,配置其Path环境变量,如"C:\Program Files\WinRAR"才可以
|
||||
elif file_extension == ".rar":
|
||||
try:
|
||||
import rarfile
|
||||
|
||||
with rarfile.RarFile(file_path) as rf:
|
||||
rf.extractall(path=dest_dir)
|
||||
print("Successfully extracted rar archive to {}".format(dest_dir))
|
||||
except:
|
||||
print("Rar format requires additional dependencies to install")
|
||||
return "\n\n解压失败! 需要安装pip install rarfile来解压rar文件。建议:使用zip压缩格式。"
|
||||
|
||||
# 第三方库,需要预先pip install py7zr
|
||||
elif file_extension == ".7z":
|
||||
try:
|
||||
import py7zr
|
||||
|
||||
with py7zr.SevenZipFile(file_path, mode="r") as f:
|
||||
f.extractall(path=dest_dir)
|
||||
print("Successfully extracted 7z archive to {}".format(dest_dir))
|
||||
except:
|
||||
print("7z format requires additional dependencies to install")
|
||||
return "\n\n解压失败! 需要安装pip install py7zr来解压7z文件"
|
||||
else:
|
||||
return ""
|
||||
return ""
|
||||
|
||||
@@ -14,7 +14,7 @@ def is_openai_api_key(key):
|
||||
if len(CUSTOM_API_KEY_PATTERN) != 0:
|
||||
API_MATCH_ORIGINAL = re.match(CUSTOM_API_KEY_PATTERN, key)
|
||||
else:
|
||||
API_MATCH_ORIGINAL = re.match(r"sk-[a-zA-Z0-9]{48}$", key)
|
||||
API_MATCH_ORIGINAL = re.match(r"sk-[a-zA-Z0-9]{48}$|sess-[a-zA-Z0-9]{40}$", key)
|
||||
return bool(API_MATCH_ORIGINAL)
|
||||
|
||||
|
||||
|
||||
107
shared_utils/text_mask.py
普通文件
107
shared_utils/text_mask.py
普通文件
@@ -0,0 +1,107 @@
|
||||
import re
|
||||
from functools import lru_cache
|
||||
|
||||
# 这段代码是使用Python编程语言中的re模块,即正则表达式库,来定义了一个正则表达式模式。
|
||||
# 这个模式被编译成一个正则表达式对象,存储在名为const_extract_exp的变量中,以便于后续快速的匹配和查找操作。
|
||||
# 这里解释一下正则表达式中的几个特殊字符:
|
||||
# - . 表示任意单一字符。
|
||||
# - * 表示前一个字符可以出现0次或多次。
|
||||
# - ? 在这里用作非贪婪匹配,也就是说它会匹配尽可能少的字符。在(.*?)中,它确保我们匹配的任意文本是尽可能短的,也就是说,它会在</show_llm>和</show_render>标签之前停止匹配。
|
||||
# - () 括号在正则表达式中表示捕获组。
|
||||
# - 在这个例子中,(.*?)表示捕获任意长度的文本,直到遇到括号外部最近的限定符,即</show_llm>和</show_render>。
|
||||
|
||||
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=/1=-=-=-=-=-=-=-=-=-=-=-=-=-=/2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
const_extract_re = re.compile(
|
||||
r"<gpt_academic_string_mask><show_llm>(.*?)</show_llm><show_render>(.*?)</show_render></gpt_academic_string_mask>"
|
||||
)
|
||||
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=/1=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-/2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
const_extract_langbased_re = re.compile(
|
||||
r"<gpt_academic_string_mask><lang_english>(.*?)</lang_english><lang_chinese>(.*?)</lang_chinese></gpt_academic_string_mask>",
|
||||
flags=re.DOTALL,
|
||||
)
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def apply_gpt_academic_string_mask(string, mode="show_all"):
|
||||
"""
|
||||
当字符串中有掩码tag时(<gpt_academic_string_mask><show_...>),根据字符串要给谁看(大模型,还是web渲染),对字符串进行处理,返回处理后的字符串
|
||||
示意图:https://mermaid.live/edit#pako:eNqlkUtLw0AUhf9KuOta0iaTplkIPlpduFJwoZEwJGNbzItpita2O6tF8QGKogXFtwu7cSHiq3-mk_oznFR8IYLgrGbuOd9hDrcCpmcR0GDW9ubNPKaBMDauuwI_A9M6YN-3y0bODwxsYos4BdMoBrTg5gwHF-d0mBH6-vqFQe58ed5m9XPW2uteX3Tubrj0ljLYcwxxR3h1zB43WeMs3G19yEM9uapDMe_NG9i2dagKw1Fee4c1D9nGEbtc-5n6HbNtJ8IyHOs8tbs7V2HrlDX2w2Y7XD_5haHEtQiNsOwfMVa_7TzsvrWIuJGo02qTrdwLk9gukQylHv3Afv1ML270s-HZUndrmW1tdA-WfvbM_jMFYuAQ6uCCxVdciTJ1CPLEITpo_GphypeouzXuw6XAmyi7JmgBLZEYlHwLB2S4gHMUO-9DH7tTnvf1CVoFFkBLSOk4QmlRTqpIlaWUHINyNFXjaQWpCYRURUKiWovBYo8X4ymEJFlECQUpqaQkJmuvWygPpg
|
||||
"""
|
||||
if "<gpt_academic_string_mask>" not in string: # No need to process
|
||||
return string
|
||||
|
||||
if mode == "show_all":
|
||||
return string
|
||||
if mode == "show_llm":
|
||||
string = const_extract_re.sub(r"\1", string)
|
||||
elif mode == "show_render":
|
||||
string = const_extract_re.sub(r"\2", string)
|
||||
else:
|
||||
raise ValueError("Invalid mode")
|
||||
return string
|
||||
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def build_gpt_academic_masked_string(text_show_llm="", text_show_render=""):
|
||||
"""
|
||||
根据字符串要给谁看(大模型,还是web渲染),生成带掩码tag的字符串
|
||||
"""
|
||||
return f"<gpt_academic_string_mask><show_llm>{text_show_llm}</show_llm><show_render>{text_show_render}</show_render></gpt_academic_string_mask>"
|
||||
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def apply_gpt_academic_string_mask_langbased(string, lang_reference):
|
||||
"""
|
||||
当字符串中有掩码tag时(<gpt_academic_string_mask><lang_...>),根据语言,选择提示词,对字符串进行处理,返回处理后的字符串
|
||||
例如,如果lang_reference是英文,那么就只显示英文提示词,中文提示词就不显示了
|
||||
举例:
|
||||
输入1
|
||||
string = "注意,lang_reference这段文字是:<gpt_academic_string_mask><lang_english>英语</lang_english><lang_chinese>中文</lang_chinese></gpt_academic_string_mask>"
|
||||
lang_reference = "hello world"
|
||||
输出1
|
||||
"注意,lang_reference这段文字是:英语"
|
||||
|
||||
输入2
|
||||
string = "注意,lang_reference这段文字是中文" # 注意这里没有掩码tag,所以不会被处理
|
||||
lang_reference = "hello world"
|
||||
输出2
|
||||
"注意,lang_reference这段文字是中文" # 原样返回
|
||||
"""
|
||||
|
||||
if "<gpt_academic_string_mask>" not in string: # No need to process
|
||||
return string
|
||||
|
||||
def contains_chinese(string):
|
||||
chinese_regex = re.compile(u'[\u4e00-\u9fff]+')
|
||||
return chinese_regex.search(string) is not None
|
||||
|
||||
mode = "english" if not contains_chinese(lang_reference) else "chinese"
|
||||
if mode == "english":
|
||||
string = const_extract_langbased_re.sub(r"\1", string)
|
||||
elif mode == "chinese":
|
||||
string = const_extract_langbased_re.sub(r"\2", string)
|
||||
else:
|
||||
raise ValueError("Invalid mode")
|
||||
return string
|
||||
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def build_gpt_academic_masked_string_langbased(text_show_english="", text_show_chinese=""):
|
||||
"""
|
||||
根据语言,选择提示词,对字符串进行处理,返回处理后的字符串
|
||||
"""
|
||||
return f"<gpt_academic_string_mask><lang_english>{text_show_english}</lang_english><lang_chinese>{text_show_chinese}</lang_chinese></gpt_academic_string_mask>"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Test
|
||||
input_string = (
|
||||
"你好\n"
|
||||
+ build_gpt_academic_masked_string(text_show_llm="mermaid", text_show_render="")
|
||||
+ "你好\n"
|
||||
)
|
||||
print(
|
||||
apply_gpt_academic_string_mask(input_string, "show_llm")
|
||||
) # Should print the strings with 'abc' in place of the academic mask tags
|
||||
print(
|
||||
apply_gpt_academic_string_mask(input_string, "show_render")
|
||||
) # Should print the strings with 'xyz' in place of the academic mask tags
|
||||
@@ -0,0 +1,41 @@
|
||||
import unittest
|
||||
|
||||
def validate_path():
|
||||
import os, sys
|
||||
|
||||
os.path.dirname(__file__)
|
||||
root_dir_assume = os.path.abspath(os.path.dirname(__file__) + "/..")
|
||||
os.chdir(root_dir_assume)
|
||||
sys.path.append(root_dir_assume)
|
||||
|
||||
|
||||
validate_path() # validate path so you can run from base directory
|
||||
|
||||
from shared_utils.key_pattern_manager import is_openai_api_key
|
||||
|
||||
class TestKeyPatternManager(unittest.TestCase):
|
||||
def test_is_openai_api_key_with_valid_key(self):
|
||||
key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
self.assertTrue(is_openai_api_key(key))
|
||||
|
||||
key = "sx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
self.assertFalse(is_openai_api_key(key))
|
||||
|
||||
key = "sess-wg61ZafYHpNz7FFwIH7HGZlbVqUVaeV5tatHCWpl"
|
||||
self.assertTrue(is_openai_api_key(key))
|
||||
|
||||
key = "sess-wg61ZafYHpNz7FFwIH7HGZlbVqUVa5tatHCWpl"
|
||||
self.assertFalse(is_openai_api_key(key))
|
||||
|
||||
|
||||
def test_is_openai_api_key_with_invalid_key(self):
|
||||
key = "invalid_key"
|
||||
self.assertFalse(is_openai_api_key(key))
|
||||
|
||||
def test_is_openai_api_key_with_custom_pattern(self):
|
||||
# Assuming you have set a custom pattern in your configuration
|
||||
key = "custom-pattern-key"
|
||||
self.assertFalse(is_openai_api_key(key))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -20,10 +20,10 @@ if __name__ == "__main__":
|
||||
|
||||
# plugin_test(plugin='crazy_functions.函数动态生成->函数动态生成', main_input='交换图像的蓝色通道和红色通道', advanced_arg={"file_path_arg": "./build/ants.jpg"})
|
||||
|
||||
# plugin_test(plugin='crazy_functions.Latex输出PDF结果->Latex翻译中文并重新编译PDF', main_input="2307.07522")
|
||||
# plugin_test(plugin='crazy_functions.Latex输出PDF->Latex翻译中文并重新编译PDF', main_input="2307.07522")
|
||||
|
||||
plugin_test(
|
||||
plugin="crazy_functions.Latex输出PDF结果->Latex翻译中文并重新编译PDF",
|
||||
plugin="crazy_functions.Latex输出PDF->Latex翻译中文并重新编译PDF",
|
||||
main_input="G:/SEAFILE_LOCAL/50503047/我的资料库/学位/paperlatex/aaai/Fu_8368_with_appendix",
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ if __name__ == "__main__":
|
||||
|
||||
# plugin_test(plugin='crazy_functions.知识库文件注入->读取知识库作答', main_input="远程云服务器部署?")
|
||||
|
||||
# plugin_test(plugin='crazy_functions.Latex输出PDF结果->Latex翻译中文并重新编译PDF', main_input="2210.03629")
|
||||
# plugin_test(plugin='crazy_functions.Latex输出PDF->Latex翻译中文并重新编译PDF', main_input="2210.03629")
|
||||
|
||||
# advanced_arg = {"advanced_arg":"--llm_to_learn=gpt-3.5-turbo --prompt_prefix='根据下面的服装类型提示,想象一个穿着者,对这个人外貌、身处的环境、内心世界、人设进行描写。要求:100字以内,用第二人称。' --system_prompt=''" }
|
||||
# plugin_test(plugin='crazy_functions.chatglm微调工具->微调数据集生成', main_input='build/dev.json', advanced_arg=advanced_arg)
|
||||
|
||||
1
themes/base64.mjs
普通文件
1
themes/base64.mjs
普通文件
@@ -0,0 +1 @@
|
||||
// we have moved mermaid-related code to gradio-fix repository: binary-husky/gradio-fix@32150d0
|
||||
@@ -59,6 +59,7 @@
|
||||
|
||||
/* Scrollbar Width */
|
||||
::-webkit-scrollbar {
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
|
||||
179
themes/common.js
179
themes/common.js
@@ -234,7 +234,7 @@ let timeoutID = null;
|
||||
let lastInvocationTime = 0;
|
||||
let lastArgs = null;
|
||||
function do_something_but_not_too_frequently(min_interval, func) {
|
||||
return function(...args) {
|
||||
return function (...args) {
|
||||
lastArgs = args;
|
||||
const now = Date.now();
|
||||
if (!lastInvocationTime || (now - lastInvocationTime) >= min_interval) {
|
||||
@@ -242,14 +242,14 @@ function do_something_but_not_too_frequently(min_interval, func) {
|
||||
// 现在就执行
|
||||
setTimeout(() => {
|
||||
func.apply(this, lastArgs);
|
||||
}, 0);
|
||||
}, 0);
|
||||
} else if (!timeoutID) {
|
||||
// 等一会执行
|
||||
timeoutID = setTimeout(() => {
|
||||
timeoutID = null;
|
||||
lastInvocationTime = Date.now();
|
||||
func.apply(this, lastArgs);
|
||||
}, min_interval - (now - lastInvocationTime));
|
||||
}, min_interval - (now - lastInvocationTime));
|
||||
} else {
|
||||
// 压根不执行
|
||||
}
|
||||
@@ -263,13 +263,8 @@ function chatbotContentChanged(attempt = 1, force = false) {
|
||||
gradioApp().querySelectorAll('#gpt-chatbot .message-wrap .message.bot').forEach(addCopyButton);
|
||||
}, i === 0 ? 0 : 200);
|
||||
}
|
||||
// we have moved mermaid-related code to gradio-fix repository: binary-husky/gradio-fix@32150d0
|
||||
|
||||
const run_mermaid_render = do_something_but_not_too_frequently(1000, function () {
|
||||
const blocks = document.querySelectorAll(`pre.mermaid, diagram-div`);
|
||||
if (blocks.length == 0) { return; }
|
||||
uml("mermaid");
|
||||
});
|
||||
run_mermaid_render();
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +344,7 @@ function get_elements(consider_state_panel = false) {
|
||||
var chatbot_height = chatbot.style.height;
|
||||
// 交换输入区位置,使得输入区始终可用
|
||||
if (!swapped) {
|
||||
if (panel1.top != 0 && (panel1.bottom + panel1.top) / 2 < 0) { swap_input_area(); }
|
||||
if (panel1.top != 0 && (0.9 * panel1.bottom + 0.1 * panel1.top) < 0) { swap_input_area(); }
|
||||
}
|
||||
else if (swapped) {
|
||||
if (panel2.top != 0 && panel2.top > 0) { swap_input_area(); }
|
||||
@@ -672,9 +667,9 @@ function limit_scroll_position() {
|
||||
let scrollableDiv = document.querySelector('#gpt-chatbot > div.wrap');
|
||||
scrollableDiv.addEventListener('wheel', function (e) {
|
||||
let preventScroll = false;
|
||||
if (e.deltaX != 0) { prevented_offset = 0; return;}
|
||||
if (this.scrollHeight == this.clientHeight) { prevented_offset = 0; return;}
|
||||
if (e.deltaY < 0) { prevented_offset = 0; return;}
|
||||
if (e.deltaX != 0) { prevented_offset = 0; return; }
|
||||
if (this.scrollHeight == this.clientHeight) { prevented_offset = 0; return; }
|
||||
if (e.deltaY < 0) { prevented_offset = 0; return; }
|
||||
if (e.deltaY > 0 && this.scrollHeight - this.clientHeight - this.scrollTop <= 1) { preventScroll = true; }
|
||||
|
||||
if (preventScroll) {
|
||||
@@ -713,3 +708,161 @@ function GptAcademicJavaScriptInit(LAYOUT = "LEFT-RIGHT") {
|
||||
// setInterval(function () { uml("mermaid") }, 5000); // 每50毫秒执行一次
|
||||
|
||||
}
|
||||
|
||||
|
||||
function loadLive2D() {
|
||||
try {
|
||||
$("<link>").attr({ href: "file=themes/waifu_plugin/waifu.css", rel: "stylesheet", type: "text/css" }).appendTo('head');
|
||||
$('body').append('<div class="waifu"><div class="waifu-tips"></div><canvas id="live2d" class="live2d"></canvas><div class="waifu-tool"><span class="fui-home"></span> <span class="fui-chat"></span> <span class="fui-eye"></span> <span class="fui-user"></span> <span class="fui-photo"></span> <span class="fui-info-circle"></span> <span class="fui-cross"></span></div></div>');
|
||||
$.ajax({
|
||||
url: "file=themes/waifu_plugin/waifu-tips.js", dataType: "script", cache: true, success: function () {
|
||||
$.ajax({
|
||||
url: "file=themes/waifu_plugin/live2d.js", dataType: "script", cache: true, success: function () {
|
||||
/* 可直接修改部分参数 */
|
||||
live2d_settings['hitokotoAPI'] = "hitokoto.cn"; // 一言 API
|
||||
live2d_settings['modelId'] = 3; // 默认模型 ID
|
||||
live2d_settings['modelTexturesId'] = 44; // 默认材质 ID
|
||||
live2d_settings['modelStorage'] = false; // 不储存模型 ID
|
||||
live2d_settings['waifuSize'] = '210x187';
|
||||
live2d_settings['waifuTipsSize'] = '187x52';
|
||||
live2d_settings['canSwitchModel'] = true;
|
||||
live2d_settings['canSwitchTextures'] = true;
|
||||
live2d_settings['canSwitchHitokoto'] = false;
|
||||
live2d_settings['canTakeScreenshot'] = false;
|
||||
live2d_settings['canTurnToHomePage'] = false;
|
||||
live2d_settings['canTurnToAboutPage'] = false;
|
||||
live2d_settings['showHitokoto'] = false; // 显示一言
|
||||
live2d_settings['showF12Status'] = false; // 显示加载状态
|
||||
live2d_settings['showF12Message'] = false; // 显示看板娘消息
|
||||
live2d_settings['showF12OpenMsg'] = false; // 显示控制台打开提示
|
||||
live2d_settings['showCopyMessage'] = false; // 显示 复制内容 提示
|
||||
live2d_settings['showWelcomeMessage'] = true; // 显示进入面页欢迎词
|
||||
/* 在 initModel 前添加 */
|
||||
initModel("file=themes/waifu_plugin/waifu-tips.json");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (err) { console.log("[Error] JQuery is not defined.") }
|
||||
}
|
||||
|
||||
function get_checkbox_selected_items(elem_id){
|
||||
display_panel_arr = [];
|
||||
document.getElementById(elem_id).querySelector('[data-testid="checkbox-group"]').querySelectorAll('label').forEach(label => {
|
||||
// Get the span text
|
||||
const spanText = label.querySelector('span').textContent;
|
||||
// Get the input value
|
||||
const checked = label.querySelector('input').checked;
|
||||
if (checked) {
|
||||
display_panel_arr.push(spanText)
|
||||
}
|
||||
});
|
||||
return display_panel_arr;
|
||||
}
|
||||
|
||||
function set_checkbox(key, bool, set_twice=false) {
|
||||
set_success = false;
|
||||
elem_ids = ["cbsc", "cbs"]
|
||||
elem_ids.forEach(id => {
|
||||
document.getElementById(id).querySelector('[data-testid="checkbox-group"]').querySelectorAll('label').forEach(label => {
|
||||
// Get the span text
|
||||
const spanText = label.querySelector('span').textContent;
|
||||
if (spanText === key) {
|
||||
if (bool){
|
||||
label.classList.add('selected');
|
||||
} else {
|
||||
if (label.classList.contains('selected')) {
|
||||
label.classList.remove('selected');
|
||||
}
|
||||
}
|
||||
if (set_twice){
|
||||
setTimeout(() => {
|
||||
if (bool){
|
||||
label.classList.add('selected');
|
||||
} else {
|
||||
if (label.classList.contains('selected')) {
|
||||
label.classList.remove('selected');
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
label.querySelector('input').checked = bool;
|
||||
set_success = true;
|
||||
return
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (!set_success){
|
||||
console.log("设置checkbox失败,没有找到对应的key")
|
||||
}
|
||||
}
|
||||
|
||||
function apply_cookie_for_checkbox(dark) {
|
||||
// console.log("apply_cookie_for_checkboxes")
|
||||
let searchString = "输入清除键";
|
||||
let bool_value = "False";
|
||||
|
||||
////////////////// darkmode ///////////////////
|
||||
if (getCookie("js_darkmode_cookie")) {
|
||||
dark = getCookie("js_darkmode_cookie")
|
||||
}
|
||||
dark = dark == "True";
|
||||
if (document.querySelectorAll('.dark').length) {
|
||||
if (!dark) {
|
||||
document.querySelectorAll('.dark').forEach(el => el.classList.remove('dark'));
|
||||
}
|
||||
} else {
|
||||
if (dark) {
|
||||
document.querySelector('body').classList.add('dark');
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////// clearButton ///////////////////////////
|
||||
if (getCookie("js_clearbtn_show_cookie")) {
|
||||
// have cookie
|
||||
bool_value = getCookie("js_clearbtn_show_cookie")
|
||||
bool_value = bool_value == "True";
|
||||
searchString = "输入清除键";
|
||||
if (bool_value) {
|
||||
let clearButton = document.getElementById("elem_clear");
|
||||
let clearButton2 = document.getElementById("elem_clear2");
|
||||
clearButton.style.display = "block";
|
||||
clearButton2.style.display = "block";
|
||||
set_checkbox(searchString, true);
|
||||
} else {
|
||||
let clearButton = document.getElementById("elem_clear");
|
||||
let clearButton2 = document.getElementById("elem_clear2");
|
||||
clearButton.style.display = "none";
|
||||
clearButton2.style.display = "none";
|
||||
set_checkbox(searchString, false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////// live2d ///////////////////////////
|
||||
|
||||
if (getCookie("js_live2d_show_cookie")) {
|
||||
// have cookie
|
||||
searchString = "添加Live2D形象";
|
||||
bool_value = getCookie("js_live2d_show_cookie");
|
||||
bool_value = bool_value == "True";
|
||||
if (bool_value) {
|
||||
loadLive2D();
|
||||
set_checkbox(searchString, true);
|
||||
} else {
|
||||
$('.waifu').hide();
|
||||
set_checkbox(searchString, false);
|
||||
}
|
||||
} else {
|
||||
// do not have cookie
|
||||
// get conf
|
||||
display_panel_arr = get_checkbox_selected_items("cbsc");
|
||||
searchString = "添加Live2D形象";
|
||||
if (display_panel_arr.includes(searchString)) {
|
||||
loadLive2D();
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
themes/common.py
普通文件
18
themes/common.py
普通文件
@@ -0,0 +1,18 @@
|
||||
from toolbox import get_conf
|
||||
CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf("CODE_HIGHLIGHT", "ADD_WAIFU", "LAYOUT")
|
||||
|
||||
def get_common_html_javascript_code():
|
||||
js = "\n"
|
||||
for jsf in [
|
||||
"file=themes/common.js",
|
||||
]:
|
||||
js += f"""<script src="{jsf}"></script>\n"""
|
||||
|
||||
# 添加Live2D
|
||||
if ADD_WAIFU:
|
||||
for jsf in [
|
||||
"file=themes/waifu_plugin/jquery.min.js",
|
||||
"file=themes/waifu_plugin/jquery-ui.min.js",
|
||||
]:
|
||||
js += f"""<script src="{jsf}"></script>\n"""
|
||||
return js
|
||||
@@ -67,22 +67,9 @@ def adjust_theme():
|
||||
button_cancel_text_color_dark="white",
|
||||
)
|
||||
|
||||
js = ""
|
||||
for jsf in [
|
||||
os.path.join(theme_dir, "common.js"),
|
||||
os.path.join(theme_dir, "mermaid.min.js"),
|
||||
os.path.join(theme_dir, "mermaid_loader.js"),
|
||||
]:
|
||||
with open(jsf, "r", encoding="utf8") as f:
|
||||
js += f"<script>{f.read()}</script>"
|
||||
|
||||
# 添加一个萌萌的看板娘
|
||||
if ADD_WAIFU:
|
||||
js += """
|
||||
<script src="file=docs/waifu_plugin/jquery.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/autoload.js"></script>
|
||||
"""
|
||||
from themes.common import get_common_html_javascript_code
|
||||
js = get_common_html_javascript_code()
|
||||
|
||||
if not hasattr(gr, "RawTemplateResponse"):
|
||||
gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
|
||||
gradio_original_template_fn = gr.RawTemplateResponse
|
||||
|
||||
@@ -67,22 +67,8 @@ def adjust_theme():
|
||||
button_cancel_text_color_dark="white",
|
||||
)
|
||||
|
||||
js = ""
|
||||
for jsf in [
|
||||
os.path.join(theme_dir, "common.js"),
|
||||
os.path.join(theme_dir, "mermaid.min.js"),
|
||||
os.path.join(theme_dir, "mermaid_loader.js"),
|
||||
]:
|
||||
with open(jsf, "r", encoding="utf8") as f:
|
||||
js += f"<script>{f.read()}</script>"
|
||||
|
||||
# 添加一个萌萌的看板娘
|
||||
if ADD_WAIFU:
|
||||
js += """
|
||||
<script src="file=docs/waifu_plugin/jquery.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/autoload.js"></script>
|
||||
"""
|
||||
from themes.common import get_common_html_javascript_code
|
||||
js = get_common_html_javascript_code()
|
||||
if not hasattr(gr, "RawTemplateResponse"):
|
||||
gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
|
||||
gradio_original_template_fn = gr.RawTemplateResponse
|
||||
|
||||
@@ -31,23 +31,9 @@ def adjust_theme():
|
||||
THEME = THEME.lstrip("huggingface-")
|
||||
set_theme = set_theme.from_hub(THEME.lower())
|
||||
|
||||
js = ""
|
||||
for jsf in [
|
||||
os.path.join(theme_dir, "common.js"),
|
||||
os.path.join(theme_dir, "mermaid.min.js"),
|
||||
os.path.join(theme_dir, "mermaid_loader.js"),
|
||||
]:
|
||||
with open(jsf, "r", encoding="utf8") as f:
|
||||
js += f"<script>{f.read()}</script>"
|
||||
|
||||
|
||||
# 添加一个萌萌的看板娘
|
||||
if ADD_WAIFU:
|
||||
js += """
|
||||
<script src="file=docs/waifu_plugin/jquery.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/autoload.js"></script>
|
||||
"""
|
||||
from themes.common import get_common_html_javascript_code
|
||||
js = get_common_html_javascript_code()
|
||||
|
||||
if not hasattr(gr, "RawTemplateResponse"):
|
||||
gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
|
||||
gradio_original_template_fn = gr.RawTemplateResponse
|
||||
|
||||
@@ -76,22 +76,8 @@ def adjust_theme():
|
||||
chatbot_code_background_color_dark="*neutral_950",
|
||||
)
|
||||
|
||||
js = ""
|
||||
for jsf in [
|
||||
os.path.join(theme_dir, "common.js"),
|
||||
os.path.join(theme_dir, "mermaid.min.js"),
|
||||
os.path.join(theme_dir, "mermaid_loader.js"),
|
||||
]:
|
||||
with open(jsf, "r", encoding="utf8") as f:
|
||||
js += f"<script>{f.read()}</script>"
|
||||
|
||||
# 添加一个萌萌的看板娘
|
||||
if ADD_WAIFU:
|
||||
js += """
|
||||
<script src="file=docs/waifu_plugin/jquery.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
|
||||
<script src="file=docs/waifu_plugin/autoload.js"></script>
|
||||
"""
|
||||
from themes.common import get_common_html_javascript_code
|
||||
js = get_common_html_javascript_code()
|
||||
|
||||
with open(os.path.join(theme_dir, "green.js"), "r", encoding="utf8") as f:
|
||||
js += f"<script>{f.read()}</script>"
|
||||
|
||||
1590
themes/mermaid.min.js
vendored
1590
themes/mermaid.min.js
vendored
文件差异因一行或多行过长而隐藏
@@ -1,55 +1 @@
|
||||
import { deflate, inflate } from 'https://fastly.jsdelivr.net/gh/nodeca/pako@master/dist/pako.esm.mjs';
|
||||
import { toUint8Array, fromUint8Array, toBase64, fromBase64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.2/base64.mjs';
|
||||
|
||||
const base64Serde = {
|
||||
serialize: (state) => {
|
||||
return toBase64(state, true);
|
||||
},
|
||||
deserialize: (state) => {
|
||||
return fromBase64(state);
|
||||
}
|
||||
};
|
||||
|
||||
const pakoSerde = {
|
||||
serialize: (state) => {
|
||||
const data = new TextEncoder().encode(state);
|
||||
const compressed = deflate(data, { level: 9 });
|
||||
return fromUint8Array(compressed, true);
|
||||
},
|
||||
deserialize: (state) => {
|
||||
const data = toUint8Array(state);
|
||||
return inflate(data, { to: 'string' });
|
||||
}
|
||||
};
|
||||
|
||||
const serdes = {
|
||||
base64: base64Serde,
|
||||
pako: pakoSerde
|
||||
};
|
||||
|
||||
export const serializeState = (state, serde = 'pako') => {
|
||||
if (!(serde in serdes)) {
|
||||
throw new Error(`Unknown serde type: ${serde}`);
|
||||
}
|
||||
const json = JSON.stringify(state);
|
||||
const serialized = serdes[serde].serialize(json);
|
||||
return `${serde}:${serialized}`;
|
||||
};
|
||||
|
||||
const deserializeState = (state) => {
|
||||
let type, serialized;
|
||||
if (state.includes(':')) {
|
||||
let tempType;
|
||||
[tempType, serialized] = state.split(':');
|
||||
if (tempType in serdes) {
|
||||
type = tempType;
|
||||
} else {
|
||||
throw new Error(`Unknown serde type: ${tempType}`);
|
||||
}
|
||||
} else {
|
||||
type = 'base64';
|
||||
serialized = state;
|
||||
}
|
||||
const json = serdes[type].deserialize(serialized);
|
||||
return JSON.parse(json);
|
||||
};
|
||||
// we have moved mermaid-related code to gradio-fix repository: binary-husky/gradio-fix@32150d0
|
||||
|
||||
@@ -1,189 +1 @@
|
||||
const uml = async className => {
|
||||
|
||||
// Custom element to encapsulate Mermaid content.
|
||||
class MermaidDiv extends HTMLElement {
|
||||
|
||||
/**
|
||||
* Creates a special Mermaid div shadow DOM.
|
||||
* Works around issues of shared IDs.
|
||||
* @return {void}
|
||||
*/
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
// Create the Shadow DOM and attach style
|
||||
const shadow = this.attachShadow({ mode: "open" })
|
||||
const style = document.createElement("style")
|
||||
style.textContent = `
|
||||
:host {
|
||||
display: block;
|
||||
line-height: initial;
|
||||
font-size: 16px;
|
||||
}
|
||||
div.diagram {
|
||||
margin: 0;
|
||||
overflow: visible;
|
||||
}`
|
||||
shadow.appendChild(style)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof customElements.get("diagram-div") === "undefined") {
|
||||
customElements.define("diagram-div", MermaidDiv)
|
||||
}
|
||||
|
||||
const getFromCode = parent => {
|
||||
// Handles <pre><code> text extraction.
|
||||
let text = ""
|
||||
for (let j = 0; j < parent.childNodes.length; j++) {
|
||||
const subEl = parent.childNodes[j]
|
||||
if (subEl.tagName.toLowerCase() === "code") {
|
||||
for (let k = 0; k < subEl.childNodes.length; k++) {
|
||||
const child = subEl.childNodes[k]
|
||||
const whitespace = /^\s*$/
|
||||
if (child.nodeName === "#text" && !(whitespace.test(child.nodeValue))) {
|
||||
text = child.nodeValue
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
function createOrUpdateHyperlink(parentElement, linkText, linkHref) {
|
||||
// Search for an existing anchor element within the parentElement
|
||||
let existingAnchor = parentElement.querySelector("a");
|
||||
|
||||
// Check if an anchor element already exists
|
||||
if (existingAnchor) {
|
||||
// Update the hyperlink reference if it's different from the current one
|
||||
if (existingAnchor.href !== linkHref) {
|
||||
existingAnchor.href = linkHref;
|
||||
}
|
||||
// Update the target attribute to ensure it opens in a new tab
|
||||
existingAnchor.target = '_blank';
|
||||
|
||||
// If the text must be dynamic, uncomment and use the following line:
|
||||
// existingAnchor.textContent = linkText;
|
||||
} else {
|
||||
// If no anchor exists, create one and append it to the parentElement
|
||||
let anchorElement = document.createElement("a");
|
||||
anchorElement.href = linkHref; // Set hyperlink reference
|
||||
anchorElement.textContent = linkText; // Set text displayed
|
||||
anchorElement.target = '_blank'; // Ensure it opens in a new tab
|
||||
parentElement.appendChild(anchorElement); // Append the new anchor element to the parent
|
||||
}
|
||||
}
|
||||
|
||||
function removeLastLine(str) {
|
||||
// 将字符串按换行符分割成数组
|
||||
var lines = str.split('\n');
|
||||
lines.pop();
|
||||
// 将数组重新连接成字符串,并按换行符连接
|
||||
var result = lines.join('\n');
|
||||
return result;
|
||||
}
|
||||
|
||||
// 给出配置 Provide a default config in case one is not specified
|
||||
const defaultConfig = {
|
||||
startOnLoad: false,
|
||||
theme: "default",
|
||||
flowchart: {
|
||||
htmlLabels: false
|
||||
},
|
||||
er: {
|
||||
useMaxWidth: false
|
||||
},
|
||||
sequence: {
|
||||
useMaxWidth: false,
|
||||
noteFontWeight: "14px",
|
||||
actorFontSize: "14px",
|
||||
messageFontSize: "16px"
|
||||
}
|
||||
}
|
||||
if (document.body.classList.contains("dark")) {
|
||||
defaultConfig.theme = "dark"
|
||||
}
|
||||
|
||||
const Module = await import('./file=themes/mermaid_editor.js');
|
||||
|
||||
function do_render(block, code, codeContent, cnt) {
|
||||
var rendered_content = mermaid.render(`_diagram_${cnt}`, code);
|
||||
////////////////////////////// 记录有哪些代码已经被渲染了 ///////////////////////////////////
|
||||
let codeFinishRenderElement = block.querySelector("code_finish_render"); // 如果block下已存在code_already_rendered元素,则获取它
|
||||
if (codeFinishRenderElement) { // 如果block下已存在code_already_rendered元素
|
||||
codeFinishRenderElement.style.display = "none";
|
||||
} else {
|
||||
// 如果不存在code_finish_render元素,则将code元素中的内容添加到新创建的code_finish_render元素中
|
||||
let codeFinishRenderElementNew = document.createElement("code_finish_render"); // 创建一个新的code_already_rendered元素
|
||||
codeFinishRenderElementNew.style.display = "none";
|
||||
codeFinishRenderElementNew.textContent = "";
|
||||
block.appendChild(codeFinishRenderElementNew); // 将新创建的code_already_rendered元素添加到block中
|
||||
codeFinishRenderElement = codeFinishRenderElementNew;
|
||||
}
|
||||
|
||||
////////////////////////////// 创建一个用于渲染的容器 ///////////////////////////////////
|
||||
let mermaidRender = block.querySelector(".mermaid_render"); // 尝试获取已存在的<div class='mermaid_render'>
|
||||
if (!mermaidRender) {
|
||||
mermaidRender = document.createElement("div"); // 不存在,创建新的<div class='mermaid_render'>
|
||||
mermaidRender.classList.add("mermaid_render");
|
||||
block.appendChild(mermaidRender); // 将新创建的元素附加到block
|
||||
}
|
||||
mermaidRender.innerHTML = rendered_content
|
||||
codeFinishRenderElement.textContent = code // 标记已经渲染的部分
|
||||
|
||||
////////////////////////////// 创建一个“点击这里编辑脑图” ///////////////////////////////
|
||||
let pako_encode = Module.serializeState({
|
||||
"code": codeContent,
|
||||
"mermaid": "{\n \"theme\": \"default\"\n}",
|
||||
"autoSync": true,
|
||||
"updateDiagram": false
|
||||
});
|
||||
createOrUpdateHyperlink(block, "点击这里编辑脑图", "https://mermaid.live/edit#" + pako_encode)
|
||||
}
|
||||
|
||||
// 加载配置 Load up the config
|
||||
mermaid.mermaidAPI.globalReset() // 全局复位
|
||||
const config = (typeof mermaidConfig === "undefined") ? defaultConfig : mermaidConfig
|
||||
mermaid.initialize(config)
|
||||
// 查找需要渲染的元素 Find all of our Mermaid sources and render them.
|
||||
const blocks = document.querySelectorAll(`pre.mermaid`);
|
||||
|
||||
for (let i = 0; i < blocks.length; i++) {
|
||||
var block = blocks[i]
|
||||
////////////////////////////// 如果代码没有发生变化,就不渲染了 ///////////////////////////////////
|
||||
var code = getFromCode(block);
|
||||
let codeContent = block.querySelector("code").textContent; // 获取code元素中的文本内容
|
||||
let codePendingRenderElement = block.querySelector("code_pending_render"); // 如果block下已存在code_already_rendered元素,则获取它
|
||||
if (codePendingRenderElement) { // 如果block下已存在code_pending_render元素
|
||||
codePendingRenderElement.style.display = "none";
|
||||
if (codePendingRenderElement.textContent !== codeContent) {
|
||||
codePendingRenderElement.textContent = codeContent; // 如果现有的code_pending_render元素中的内容与code元素中的内容不同,更新code_pending_render元素中的内容
|
||||
}
|
||||
else {
|
||||
continue; // 如果相同,就不处理了
|
||||
}
|
||||
} else { // 如果不存在code_pending_render元素,则将code元素中的内容添加到新创建的code_pending_render元素中
|
||||
let codePendingRenderElementNew = document.createElement("code_pending_render"); // 创建一个新的code_already_rendered元素
|
||||
codePendingRenderElementNew.style.display = "none";
|
||||
codePendingRenderElementNew.textContent = codeContent;
|
||||
block.appendChild(codePendingRenderElementNew); // 将新创建的code_pending_render元素添加到block中
|
||||
codePendingRenderElement = codePendingRenderElementNew;
|
||||
}
|
||||
|
||||
////////////////////////////// 在这里才真正开始渲染 ///////////////////////////////////
|
||||
try {
|
||||
do_render(block, code, codeContent, i);
|
||||
// console.log("渲染", codeContent);
|
||||
} catch (err) {
|
||||
try {
|
||||
var lines = code.split('\n'); if (lines.length < 2) { continue; }
|
||||
do_render(block, removeLastLine(code), codeContent, i);
|
||||
// console.log("渲染", codeContent);
|
||||
} catch (err) {
|
||||
console.log("以下代码不能渲染", code, removeLastLine(code), err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// we have moved mermaid-related code to gradio-fix repository: binary-husky/gradio-fix@32150d0
|
||||
|
||||
1
themes/pako.esm.mjs
普通文件
1
themes/pako.esm.mjs
普通文件
@@ -0,0 +1 @@
|
||||
// we have moved mermaid-related code to gradio-fix repository: binary-husky/gradio-fix@32150d0
|
||||
109
themes/theme.py
109
themes/theme.py
@@ -46,8 +46,7 @@ cookie相关工具函数
|
||||
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
"""
|
||||
|
||||
|
||||
def init_cookie(cookies, chatbot):
|
||||
def init_cookie(cookies):
|
||||
# 为每一位访问的用户赋予一个独一无二的uuid编码
|
||||
cookies.update({"uuid": uuid.uuid4()})
|
||||
return cookies
|
||||
@@ -91,31 +90,107 @@ js_code_for_css_changing = """(css) => {
|
||||
}
|
||||
"""
|
||||
|
||||
js_code_for_darkmode_init = """(dark) => {
|
||||
dark = dark == "True";
|
||||
if (document.querySelectorAll('.dark').length) {
|
||||
if (!dark){
|
||||
document.querySelectorAll('.dark').forEach(el => el.classList.remove('dark'));
|
||||
}
|
||||
} else {
|
||||
if (dark){
|
||||
document.querySelector('body').classList.add('dark');
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
js_code_for_toggle_darkmode = """() => {
|
||||
if (document.querySelectorAll('.dark').length) {
|
||||
setCookie("js_darkmode_cookie", "False", 365);
|
||||
document.querySelectorAll('.dark').forEach(el => el.classList.remove('dark'));
|
||||
} else {
|
||||
setCookie("js_darkmode_cookie", "True", 365);
|
||||
document.querySelector('body').classList.add('dark');
|
||||
}
|
||||
document.querySelectorAll('code_pending_render').forEach(code => {code.remove();})
|
||||
}"""
|
||||
|
||||
|
||||
js_code_for_persistent_cookie_init = """(persistent_cookie) => {
|
||||
return getCookie("persistent_cookie");
|
||||
js_code_for_persistent_cookie_init = """(py_pickle_cookie, cookie) => {
|
||||
return [getCookie("py_pickle_cookie"), cookie];
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
js_code_reset = """
|
||||
(a,b,c)=>{
|
||||
return [[], [], "已重置"];
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
js_code_clear = """
|
||||
(a,b)=>{
|
||||
return ["", ""];
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
js_code_show_or_hide = """
|
||||
(display_panel_arr)=>{
|
||||
setTimeout(() => {
|
||||
// get conf
|
||||
display_panel_arr = get_checkbox_selected_items("cbs");
|
||||
|
||||
////////////////////// 输入清除键 ///////////////////////////
|
||||
let searchString = "输入清除键";
|
||||
let ele = "none";
|
||||
if (display_panel_arr.includes(searchString)) {
|
||||
let clearButton = document.getElementById("elem_clear");
|
||||
let clearButton2 = document.getElementById("elem_clear2");
|
||||
clearButton.style.display = "block";
|
||||
clearButton2.style.display = "block";
|
||||
setCookie("js_clearbtn_show_cookie", "True", 365);
|
||||
} else {
|
||||
let clearButton = document.getElementById("elem_clear");
|
||||
let clearButton2 = document.getElementById("elem_clear2");
|
||||
clearButton.style.display = "none";
|
||||
clearButton2.style.display = "none";
|
||||
setCookie("js_clearbtn_show_cookie", "False", 365);
|
||||
}
|
||||
|
||||
////////////////////// 基础功能区 ///////////////////////////
|
||||
searchString = "基础功能区";
|
||||
if (display_panel_arr.includes(searchString)) {
|
||||
ele = document.getElementById("basic-panel");
|
||||
ele.style.display = "block";
|
||||
} else {
|
||||
ele = document.getElementById("basic-panel");
|
||||
ele.style.display = "none";
|
||||
}
|
||||
|
||||
////////////////////// 函数插件区 ///////////////////////////
|
||||
searchString = "函数插件区";
|
||||
if (display_panel_arr.includes(searchString)) {
|
||||
ele = document.getElementById("plugin-panel");
|
||||
ele.style.display = "block";
|
||||
} else {
|
||||
ele = document.getElementById("plugin-panel");
|
||||
ele.style.display = "none";
|
||||
}
|
||||
|
||||
}, 50);
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
|
||||
js_code_show_or_hide_group2 = """
|
||||
(display_panel_arr)=>{
|
||||
setTimeout(() => {
|
||||
// console.log("display_panel_arr");
|
||||
// get conf
|
||||
display_panel_arr = get_checkbox_selected_items("cbsc");
|
||||
|
||||
////////////////////// 添加Live2D形象 ///////////////////////////
|
||||
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);
|
||||
}
|
||||
"""
|
||||
|
||||
二进制文件未显示。
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>
|
||||
<json>
|
||||
{
|
||||
"fontFamily": "flat-ui-icons",
|
||||
"majorVersion": 1,
|
||||
"minorVersion": 1,
|
||||
"fontURL": "http://designmodo.com/flat",
|
||||
"designer": "Sergey Shmidt",
|
||||
"designerURL": "http://designmodo.com",
|
||||
"license": "Attribution-NonCommercial-NoDerivs 3.0 Unported",
|
||||
"licenseURL": "http://creativecommons.org/licenses/by-nc-nd/3.0/",
|
||||
"version": "Version 1.1",
|
||||
"fontId": "flat-ui-icons",
|
||||
"psName": "flat-ui-icons",
|
||||
"subFamily": "Regular",
|
||||
"fullName": "flat-ui-icons",
|
||||
"description": "Generated by IcoMoon"
|
||||
}
|
||||
</json>
|
||||
</metadata>
|
||||
<defs>
|
||||
<font id="flat-ui-icons" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " d="" horiz-adv-x="512" />
|
||||
<glyph unicode="" d="M896 192l-384 512-384-512h768z" />
|
||||
<glyph unicode="" d="M128 704l384-512 384 512h-768z" />
|
||||
<glyph unicode="" d="M896 256h-768l384 384 384-384z" />
|
||||
<glyph unicode="" d="M512 256l-384 384h768l-384-384z" />
|
||||
<glyph unicode="" d="M896 0l-768 448 768 448v-896z" />
|
||||
<glyph unicode="" d="M128 896l768-448-768-448v896z" />
|
||||
<glyph unicode="" d="M224.96 448.768l447.168 447.232 128-131.008-321.152-318.016 321.152-320.896-128.256-128.256-446.912 450.944z" />
|
||||
<glyph unicode="" d="M353.152-2.112l-128.192 128.256 321.088 320.896-321.152 317.952 128 131.008 447.168-447.232-446.912-450.88z" />
|
||||
<glyph unicode="" d="M928 351.936h-320v-319.936c0-35.392-28.608-64-64-64h-64c-35.328 0-64 28.608-64 64v319.936h-320c-35.328 0-64 28.736-64 64.064v64.064c0 35.328 28.672 63.872 64 63.872h320v320.064c0 35.328 28.672 64 64 64h64c35.392 0 64-28.672 64-64v-320.064h320c35.392 0 64-28.544 64-63.872v-64.064c0-35.328-28.608-64.064-64-64.064z" />
|
||||
<glyph unicode="" d="M919.808 764.032c12.48-12.416 12.48-32.832 0-45.248l-248.896-249.024c-12.352-12.416-12.352-32.832 0-45.312l248.768-249.088c12.48-12.416 12.48-32.832 0-45.248l-90.624-90.432c-12.352-12.416-32.768-12.416-45.248 0l-248.64 249.088c-12.416 12.416-32.832 12.416-45.248 0l-248.896-248.896c-12.416-12.48-32.832-12.48-45.248 0l-90.496 90.624c-12.416 12.352-12.416 32.768 0 45.248l248.96 248.896c12.416 12.416 12.416 32.832 0 45.312l-248.768 249.024c-12.416 12.48-12.416 32.832 0 45.248l90.56 90.496c12.416 12.416 32.832 12.416 45.248 0l248.64-249.024c12.416-12.48 32.832-12.48 45.248-0.064l248.832 248.96c12.48 12.352 32.896 12.352 45.248 0l90.56-90.56z" />
|
||||
<glyph unicode="" d="M923.136 822.592c-12.352 12.544-32.768 12.544-45.12 0l-476.16-474.496c-12.48-12.544-32.832-12.544-45.248 0l-208.64 212.736c-6.144 6.208-14.272 9.408-22.336 9.472-8.256 0-16.576-3.008-22.848-9.472l-92.16-83.008c-6.144-6.272-9.472-14.144-9.472-22.336 0-8.32 3.328-17.024 9.472-23.232l210.368-220.992c12.416-12.48 32.832-33.024 45.248-45.632l90.432-91.264c12.416-12.48 32.768-12.48 45.248 0l611.712 611.328c12.48 12.48 12.48 33.088 0 45.632l-90.496 91.264z" />
|
||||
<glyph unicode="" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512c0 281.6-230.4 512-512 512zM512 140.8c-168.96 0-307.2 138.24-307.2 307.2s138.24 307.2 307.2 307.2c168.96 0 307.2-138.24 307.2-307.2 0-168.96-138.24-307.2-307.2-307.2z" />
|
||||
<glyph unicode="" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512c0 281.6-230.4 512-512 512zM512 140.8c-168.96 0-307.2 138.24-307.2 307.2s138.24 307.2 307.2 307.2c168.96 0 307.2-138.24 307.2-307.2 0-168.96-138.24-307.2-307.2-307.2zM512 601.6c-87.040 0-153.6-66.56-153.6-153.6s66.56-153.6 153.6-153.6 153.6 66.56 153.6 153.6c0 87.040-66.56 153.6-153.6 153.6z" />
|
||||
<glyph unicode="" d="M256 960h512c143.36 0 256-112.64 256-256v-512c0-143.36-112.64-256-256-256h-512c-143.36 0-256 112.64-256 256v512c0 143.36 112.64 256 256 256z" />
|
||||
<glyph unicode="" d="M768 960h-512c-143.36 0-256-112.64-256-256v-512c0-143.36 112.64-256 256-256h512c143.36 0 256 112.64 256 256v512c0 143.36-112.64 256-256 256zM844.8 550.4l-368.64-368.64c-5.12-5.12-20.48-5.12-25.6 0l-56.32 56.32c-5.12 5.12-20.48 20.48-25.6 25.6l-128 133.12c-5.12 5.12-5.12 10.24-5.12 15.36s0 10.24 5.12 15.36l56.32 51.2c5.12 0 10.24 5.12 10.24 5.12 5.12 0 10.24 0 15.36-5.12l122.88-128c5.12-5.12 20.48-5.12 25.6 0l286.72 286.72c5.12 5.12 20.48 5.12 25.6 0l56.32-56.32c10.24-10.24 10.24-20.48 5.12-30.72z" />
|
||||
<glyph unicode="" d="M512 960c-282.752 0-512-229.248-512-512 0-282.688 229.248-512 512-512 282.816 0 512 229.248 512 512 0 282.752-229.184 512-512 512zM576.768 195.136c0-37.056-28.992-67.072-64.768-67.072s-64.768 30.016-64.768 67.072v313.088c0 37.056 28.992 67.072 64.768 67.072s64.768-30.016 64.768-67.072v-313.088zM512 640.32c-35.776 0-64.768 28.608-64.768 63.872s28.992 63.744 64.768 63.744 64.768-28.544 64.768-63.808-28.992-63.808-64.768-63.808z" />
|
||||
<glyph unicode="" d="M512 960c-282.752 0-512-229.248-512-512s229.248-512 512-512c282.752 0 512 229.248 512 512 0 282.752-229.248 512-512 512zM512 128.064c-35.776 0-64.768 28.544-64.768 63.808 0 35.2 28.992 63.808 64.768 63.808 35.776 0 64.768-28.608 64.768-63.808 0-35.264-28.992-63.808-64.768-63.808zM576.768 387.776c0-37.056-28.992-67.072-64.768-67.072-35.776 0-64.768 30.080-64.768 67.072v313.088c0 37.056 28.992 67.072 64.768 67.072 35.776 0 64.768-30.080 64.768-67.072v-313.088z" />
|
||||
<glyph unicode="" d="M512-64c-282.752 0-512 229.248-512 512 0 282.688 229.248 512 512 512 282.752 0 512-229.248 512-512 0-282.752-229.248-512-512-512zM512 128.064c35.776 0 64.768 28.544 64.768 63.808 0 35.2-28.992 63.808-64.768 63.808-35.776 0-64.768-28.608-64.768-63.808 0-35.264 28.992-63.808 64.768-63.808zM650.752 724.288c-33.92 27.904-82.24 43.456-140.032 43.456-42.56 0-78.912-7.68-110.144-20.16-16.576-6.72-69.632-39.68-80.64-48.896l32.384-48.32c5.312-9.344 13.952-14.080 25.92-14.080 4.992 0 10.624 1.984 16.96 5.888 4.608 2.88 41.088 21.696 56.512 26.368 32.32 9.6 67.84 5.696 84.16 0.64 22.272-6.848 38.4-19.904 47.36-37.76 5.888-11.776 13.376-44.16-4.224-74.432-14.656-25.088-37.568-44.16-62.848-61.056-13.504-9.216-26.048-18.624-37.376-28.416-0.512 0-1.792-0.96-4.672-3.52 1.408 1.216 3.264 2.304 4.672 3.52 3.2 0.128-30.784-43.328-30.784-83.52 0-42.88 0-64 0-64h128v64c0 33.28 16.128 51.968 16.448 56.704 11.008 7.872 61.056 46.144 72.96 59.904 22.208 25.6 38.592 59.392 38.592 107.008 0 48.832-19.392 88.832-53.248 116.672z" />
|
||||
<glyph unicode="" d="M512 960c-282.752 0-512-229.184-512-511.936 0-282.816 229.248-512.064 512-512.064 282.752 0 512 229.248 512 512.064 0 282.752-229.248 511.936-512 511.936zM842.88 552.128l-367.296-367.232c-7.488-7.488-19.712-7.488-27.136 0l-54.272 54.784c-7.424 7.552-19.712 19.904-27.136 27.392l-126.336 132.8c-3.712 3.712-5.696 8.96-5.696 13.888 0 4.992 1.984 9.728 5.696 13.504l55.36 49.92c3.776 3.84 8.768 5.632 13.696 5.632 4.864-0.064 9.728-1.984 13.44-5.632l125.248-127.872c7.488-7.616 19.648-7.616 27.136 0l285.888 285.12c7.424 7.488 19.712 7.488 27.136 0l54.336-54.912c7.424-7.488 7.424-19.84-0.064-27.392z" />
|
||||
<glyph unicode="" d="M874.048 810.048c-199.936 200-524.096 199.936-724.096 0-199.936-199.872-199.936-524.096 0.064-724.032 199.936-199.936 524.096-199.936 724.032-0.064 200 199.936 200 524.16 0 724.096zM747.2 309.056c27.52-27.52 28.224-71.296 1.728-97.856-26.56-26.56-70.4-25.728-97.792 1.728l-139.072 139.008-139.584-139.584c-27.52-27.456-71.296-28.224-97.792-1.728-26.56 26.56-25.728 70.4 1.664 97.856l139.648 139.584-139.648 139.648c-27.456 27.392-28.224 71.168-1.664 97.728 26.496 26.56 70.336 25.792 97.792-1.664l139.584-139.584 139.072 139.072c27.456 27.456 71.232 28.224 97.792 1.664 26.496-26.56 25.728-70.336-1.728-97.792l-139.008-139.072 139.008-139.008z" />
|
||||
<glyph unicode="" d="M512 960.064c-282.752 0-512-229.312-512-512.064 0-282.816 229.248-512.064 512-512.064s512 229.248 512 512.064c0 282.752-229.248 512.064-512 512.064zM764.224 383.296h-187.392v-187.52c0-36.992-28.992-67.072-64.768-67.072s-64.768 30.080-64.768 67.072v187.52h-188.16c-36.992 0-67.072 28.928-67.072 64.704s30.080 64.768 67.072 64.768h188.16v188.16c0 37.056 28.992 67.072 64.768 67.072s64.768-30.016 64.768-67.072v-188.16h187.456c37.056 0 67.072-29.056 67.072-64.768s-30.016-64.704-67.136-64.704z" />
|
||||
<glyph unicode="" d="M288 960h-192c-35.328 0-64-28.608-64-64v-896c0-35.392 28.672-64 64-64h192c35.328 0 64 28.608 64 64v896c0 35.392-28.672 64-64 64zM928 960h-192c-35.392 0-64-28.608-64-64v-896c0-35.392 28.608-64 64-64h192c35.392 0 64 28.608 64 64v896c0 35.392-28.608 64-64 64z" />
|
||||
<glyph unicode="" d="M880 475.776l-832 480c-9.856 5.696-22.144 5.696-32 0-9.856-5.76-16-16.32-16-27.776v-960c0-11.456 6.144-22.016 16-27.712 4.928-2.88 10.496-4.288 16-4.288s11.072 1.408 16 4.288l832 480c9.856 5.696 16 16.256 16 27.712s-6.144 22.016-16 27.776z" />
|
||||
<glyph unicode="" d="M493.184 896c-48.384 0-63.040-27.84-63.040-27.84s-183.104-216.192-266.56-216.192c-82.176 0-81.344 0-81.344 0-45.44 0-82.24-36.416-82.24-81.28v-244.096c0-44.928 36.8-81.28 82.176-81.28 0 0 1.344 0 82.176 0 81.024 0 269.568-218.88 269.568-218.88 14.912-15.488 35.904-25.152 59.264-25.152 45.376 0 82.176 36.352 82.176 81.28v732.096c0 44.928-36.8 81.344-82.176 81.344zM843.968 817.728l-47.424-70.976c86.656-70.4 142.208-177.728 142.208-298.176s-55.488-227.84-142.208-298.112l47.424-70.976c109.44 85.888 180.032 219.136 180.032 369.088 0 150.016-70.592 283.2-180.032 369.152zM748.8 675.328l-47.872-71.68c41.344-38.912 67.392-93.76 67.392-155.072s-26.048-116.096-67.392-155.072l47.872-71.616c63.872 54.72 104.576 136 104.576 226.688 0 90.816-40.704 171.968-104.576 226.752z" />
|
||||
<glyph unicode="" d="M492.8 896c-51.2 0-64-25.6-64-25.6s-179.2-217.6-262.4-217.6c-83.2 0-83.2 0-83.2 0-44.8 0-83.2-38.4-83.2-83.2v-243.2c0-44.8 38.4-83.2 83.2-83.2 0 0 0 0 83.2 0 83.2 0 268.8-217.6 268.8-217.6 12.8-12.8 32-25.6 57.6-25.6 44.8 0 83.2 38.4 83.2 83.2v729.6c0 44.8-38.4 83.2-83.2 83.2z" />
|
||||
<glyph unicode="" d="M832 640l-213.056-208.448-125.696 125.696 210.752 210.688-160 160.064h448v-448l-160 160zM526.976 342.528l-206.976-202.496 167.488-172.032h-455.488v452.288l160-164.288 210.752 210.752 124.224-124.224z" />
|
||||
<glyph unicode="" d="M991.936 863.36h-959.872c-17.6 0-32-15.36-32-34.176v-124.672c0-18.048 14.4-32.832 32-32.832h959.872c17.6 0 32 14.72 32 32.832v124.672c0 18.816-14.4 34.176-32 34.176zM991.936 543.36h-959.872c-17.6 0-32-15.36-32-34.24v-124.608c0-18.112 14.4-32.832 32-32.832h959.872c17.6 0 32 14.72 32 32.832v124.672c0 18.816-14.4 34.176-32 34.176zM991.936 223.36h-959.872c-17.6 0-32-15.36-32-34.24v-124.608c0-17.984 14.4-32.768 32-32.768h959.872c17.6 0 32 14.72 32 32.768v124.608c0 18.88-14.4 34.24-32 34.24z" />
|
||||
<glyph unicode="" d="M352 896h-320c-19.2 0-32-12.8-32-32v-320c0-19.2 12.8-32 32-32h320c19.2 0 32 12.8 32 32v320c0 19.2-12.8 32-32 32zM352 384h-320c-19.2 0-32-12.8-32-32v-320c0-19.2 12.8-32 32-32h320c19.2 0 32 12.8 32 32v320c0 19.2-12.8 32-32 32zM992 896h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 640h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 384h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 128h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32z" />
|
||||
<glyph unicode="" d="M288 896h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM288 576h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM608 896h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM608 576h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM928 896h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM928 576h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM288 256h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM608 256h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM928 256h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32z" />
|
||||
<glyph unicode="" d="M416 960h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32zM992 960h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32zM416 384h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32zM992 384h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32z" />
|
||||
<glyph unicode="" d="M992 896h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 640h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 384h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 128h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 896h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 640h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 384h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 128h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32z" />
|
||||
<glyph unicode="" d="M992 896h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 640h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 384h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 128h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32z" />
|
||||
<glyph unicode="" d="M992 832h-640c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h640c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 512h-640c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h640c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 192h-640c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h640c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM256 768c0-70.692-57.308-128-128-128-70.692 0-128 57.308-128 128 0 70.692 57.308 128 128 128 70.692 0 128-57.308 128-128zM256 448c0-70.692-57.308-128-128-128-70.692 0-128 57.308-128 128 0 70.692 57.308 128 128 128 70.692 0 128-57.308 128-128zM256 128c0-70.692-57.308-128-128-128-70.692 0-128 57.308-128 128 0 70.692 57.308 128 128 128 70.692 0 128-57.308 128-128z" />
|
||||
<glyph unicode="" d="M896 960h-768c-70.656 0-128-57.344-128-128v-768c0-70.656 57.344-128 128-128h768c70.656 0 128 57.344 128 128v768c0 70.656-57.344 128-128 128zM384 895.936c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM192 895.936c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM896.064 64h-768.064v640h768.064v-640z" />
|
||||
<glyph unicode="" d="M938.752 767.744h-106.688v106.624c0 47.104-38.208 85.312-85.312 85.312h-661.44c-47.104 0-85.312-38.208-85.312-85.312v-660.672c0-47.168 37.248-85.376 83.136-85.376h108.864v-106.688c0-47.104 37.248-85.312 83.136-85.312h665.792c45.952 0 83.2 38.208 83.2 85.312v660.736c-0.064 47.104-38.272 85.376-85.376 85.376zM384 895.616c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM192 895.616c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM128 255.68l-0.064 448h576.064v-448h-576zM896 63.68h-576v64.64h428.864c45.952 0 83.2 38.208 83.2 85.376v297.984h63.936v-448z" />
|
||||
<glyph unicode="" d="M768 191.936c-121.6 0-197.888 68.736-256 144.448-58.112-75.712-134.4-144.448-256-144.448-102.848 0-256 68.224-256 256.064 0 187.776 153.152 256 256 256 121.6 0 197.888-68.672 256-144.448 58.112 75.776 134.4 144.448 256 144.448 102.912 0 256-68.224 256-256 0-187.84-153.088-256.064-256-256.064zM256 576c-29.632-0.512-128-11.136-128-128 0-121.856 106.624-128 128-128 78.272 0 123.264 47.808 178.752 128-55.488 80.128-100.48 128-178.752 128zM589.248 448c55.424-80.128 100.352-127.872 178.432-128 30.336 0.448 128.32 11.264 128.32 128 0 121.856-106.624 128-128 128-78.272 0-123.264-47.872-178.752-128z" />
|
||||
<glyph unicode="" d="M800 512c-22.976 0-59.328 0-96 0v-128c22.656 0 44.8 0 64 0 12.096 0 23.296 0 32 0 123.712 0 224-100.288 224-224s-100.288-224-224-224-224 100.224-224 224c0 22.976 0 59.264 0 96h-128c0-22.656 0-44.864 0-64 0-12.096 0-23.232 0-32 0-123.776-100.288-224-224-224s-224 100.224-224 224 100.288 224 224 224c22.976 0 59.328 0 96 0v128c-22.592 0-44.864 0-64 0-12.096 0-23.232 0-32 0-123.712 0-224 100.224-224 224 0 123.712 100.288 224 224 224s224-100.288 224-224c0-22.976 0-59.328 0-96h128c0 22.592 0 44.864 0 64 0 12.096 0 23.232 0 32 0 123.712 100.288 224 224 224s224-100.288 224-224c0-123.776-100.288-224-224-224zM320 736c0 52.992-43.008 96-96 96s-96-43.008-96-96c0-53.056 43.008-96 96-96 7.744 0 19.52 0 32 0 29.568 0 64 0 64 0s0 69.056 0 96zM320 192c0 29.504 0 64 0 64s-69.056 0-96 0c-52.992 0-96-43.008-96-96s43.008-96 96-96 96 43.008 96 96c0 7.744 0 19.52 0 32zM704 160c0-52.992 43.008-96 96-96s96 43.008 96 96-43.008 96-96 96c-7.744 0-19.52 0-32 0-29.568 0-64 0-64 0s0-69.12 0-96zM576 512h-128v-128h128v128zM800 832c-52.992 0-96-43.008-96-96 0-7.744 0-19.456 0-32 0-29.632 0-64 0-64s69.056 0 96 0c52.992 0 96 42.944 96 96 0 52.992-43.008 96-96 96z" />
|
||||
<glyph unicode="" d="M801.984 406.4c-28.672 17.664-65.408 7.232-81.92-23.36-0.576-1.024-0.576-2.24-1.152-3.264l-1.472 0.96c-41.984-74.432-117.696-124.736-205.184-124.736s-163.136 50.304-205.184 124.736l-1.408-0.832c-0.704 1.6-0.704 3.456-1.6 5.12-16.576 30.528-53.312 41.024-82.048 23.36s-38.528-56.832-21.952-87.36c1.28-2.24 3.264-3.648 4.672-5.696l-1.088-0.704c53.12-94.208 143.104-161.6 248.576-180.608v-70.016h-120.064c-33.152 0-60.032-28.672-60.032-64 0-35.392 26.88-64 60.032-64h360.128c33.216 0 60.032 28.608 60.032 64 0 35.328-26.816 64-60.032 64h-120v69.952c105.472 19.008 195.456 86.528 248.576 180.672l-0.384 0.256c1.088 1.472 2.624 2.432 3.456 4.096 16.64 30.656 6.784 69.76-21.952 87.424zM512.256 320c99.456 0 180.032 85.952 180.032 192v256c0 106.048-80.64 192-180.032 192-99.456 0-180.096-85.952-180.096-192v-256c0-106.048 80.64-192 180.096-192z" />
|
||||
<glyph unicode="" d="M948.544 446.848c100.48 102.784 100.352 269.312 0 372.032-51.392 52.48-118.976 78.144-186.24 76.992-94.144-1.536-249.344-128.96-249.344-128.96s-159.616 129.216-256 129.088c-65.728-0.128-131.392-25.856-181.504-77.056-100.416-102.784-100.48-269.248 0-372.032l436.544-446.336 436.544 446.272z" />
|
||||
<glyph unicode="" d="M512.128 432.064c-87.872 0-159.104 73.728-159.104 164.8 0 91.136 71.232 164.864 159.104 164.864s159.104-73.728 159.104-164.864c0-91.008-71.232-164.8-159.104-164.8zM512.128 960.384c-194.496 0-352.128-163.328-352.128-364.8 0-190.272 159.488-435.776 265.984-555.264 39.808-44.544 86.144-104.704 86.144-104.704s49.792 60.352 92.48 106.304c106.368 114.496 259.648 344.448 259.648 553.6 0 201.536-157.632 364.864-352.128 364.864z" />
|
||||
<glyph unicode="" d="M960.512 710.272c-21.76 35.968-48.576 71.168-81.344 103.808-33.216 32.896-68.992 59.968-105.6 81.6l64.32 64.32c0 0 93.056 0 139.648-46.528 46.464-46.592 46.464-139.648 46.464-139.648l-63.488-63.552zM387.2 128.768h-194.432v194.432l23.36 23.36c39.552-18.56 78.784-44.928 114.176-80.32 35.392-35.328 61.696-74.688 80.32-114.176l-23.424-23.296zM906.752 656.512l-440-448.32c-22.72 37.632-50.688 74.304-84.992 108.352-34.688 34.432-72.064 62.72-110.336 85.312l449.152 440.896c37.824-17.856 75.456-42.944 109.312-76.864s59.008-71.424 76.864-109.376zM128 832v-767.936h768v319.936l128 127.936v-482.88c0-51.392-41.6-93.056-93.056-93.056h-837.888c-51.392 0-93.056 41.664-93.056 93.056v837.824c0 51.456 41.664 93.12 93.056 93.12h482.944l-128-128h-320z" />
|
||||
<glyph unicode="" d="M960.256 96.064v-0.768l-256.256 256.256v-127.488c0-70.72-57.344-128.064-128-128.064h-448c-70.656 0-128 57.344-128 128.064v447.872c0 70.72 57.344 128.064 128 128.064h448c70.656 0 128-57.344 128-128.064v-128.576l256 256v0.64c35.392 0 64-28.608 64-64v-576c0-35.264-28.544-63.808-63.744-63.936z" />
|
||||
<glyph unicode="" d="M897.024 768h-147.84l-42.88 90.624c-9.792 21.312-45.056 37.376-79.36 37.376h-244.8c-34.304 0-69.568-16.064-79.424-37.376l-41.856-90.624h-132.864c-128 0-128-64-128-64v-640c0 0 0-64 128-64h768c128 0 128 64 128 64v640c0 0 0 64-126.976 64zM512 128.064c-141.376 0-256 114.496-256 255.872 0 141.44 114.624 256.064 256 256.064s256-114.624 256-256.064c0-141.376-114.624-255.872-256-255.872zM512 544c-88.384 0-160-71.616-160-160 0-88.32 71.616-160 160-160s160 71.68 160 160c0 88.384-71.616 160-160 160z" />
|
||||
<glyph unicode="" d="M512.064 960c-282.688 0-511.872-229.184-511.872-511.936 0-282.816 229.184-511.936 511.872-511.936 282.752 0 511.936 229.12 511.936 511.936 0 282.752-229.184 511.936-511.936 511.936zM678.976 268.48l-14.848-14.976c-12.416-12.352-33.344-12.992-46.464-1.28l-171.52 147.52c-13.12 11.712-23.040 35.712-22.208 53.248l17.856 283.072c0.896 17.6 16 31.936 33.664 31.936h21.056c17.6 0 32.704-14.336 33.536-31.936l14.656-231.808c0.896-17.536 11.2-42.688 22.848-55.808l112.768-133.568c11.648-12.992 11.136-33.984-1.344-46.4z" />
|
||||
<glyph unicode="" d="M512.064 800c-338.944 0-512.96-352.896-512.96-352.896s131.328-352.96 512.96-352.96c345.472 0 512.832 351.616 512.832 351.616s-168.64 354.24-512.832 354.24zM512.832 226.496c-123.968 0-213.504 96.576-213.504 220.608 0 124.096 89.536 220.544 213.504 220.544 123.904 0 213.44-96.448 213.44-220.544 0-124.032-89.6-220.608-213.44-220.608zM512.832 579.456c-70.784-0.128-128.128-61.44-128.128-132.352 0-70.848 57.344-132.352 128.128-132.352s128.064 61.504 128.064 132.352c0 70.912-57.28 132.544-128.064 132.352z" />
|
||||
<glyph unicode="" d="M457.856 168.064l289.28-226.496c4.736-3.776 7.616-5.632 10.368-5.632 8 0 10.496 5.504 10.496 14.528v214.4c0 15.104 9.984 27.136 23.36 27.136h105.152c127.488 0 127.36 61.44 127.36 61.44v640.064c0 0 0 66.56-127.872 66.56h-767.936c-128 0-128-66.56-128-66.56v-640.064c0 0-0.064-61.44 128.448-61.44h256c0 0 53.568-1.472 73.344-23.936z" />
|
||||
<glyph unicode="" d="M1024 26.752c0-50.176-41.6-90.752-93.12-90.752h-291.264v351.68c0 53.056-38.016 96.128-85.056 96.128h-85.12c-46.976 0-85.12-43.072-85.12-96.128v-351.68h-291.264c-51.392 0-93.056 40.576-93.056 90.752v478.976c0 23.36 9.344 44.48 24.192 60.544l-0.96 1.856 425.92 372.992c34.304 25.152 89.984 25.152 124.288 0l427.264-372.992-0.448-2.368c14.592-16.064 23.744-36.928 23.744-60.032v-478.976z" />
|
||||
<glyph unicode="" d="M896-64h-192v128h192.064v640h-768.064v-640h192v-128h-192c-70.656 0-128 57.344-128 128v768c0 70.656 57.344 128 128 128h768c70.656 0 128-57.344 128-128v-768c0-70.656-57.344-128-128-128zM192 895.936c-35.392 0-64-28.608-64-63.936 0-35.392 28.608-64 64-64s64 28.608 64 64c0 35.328-28.608 63.936-64 63.936zM384 895.936c-35.392 0-64-28.608-64-63.936 0-35.392 28.608-64 64-64s64 28.608 64 64c0 35.328-28.608 63.936-64 63.936zM271.936 200.704c-22.208 23.232-22.208 60.864 0 84.16l196.928 209.408c6.144 6.464 13.44 10.496 21.12 13.44 0.064 0.064 0.192 0.064 0.32 0.128 5.888 2.24 11.84 3.456 17.984 3.712 2.24 0.192 4.416 0.384 6.656 0.256 2.752-0.192 5.376-1.024 8-1.6 11.328-2.24 22.272-6.72 30.976-15.872l196.864-209.408c22.272-23.296 22.272-60.928 0-84.16-22.272-23.104-58.304-23.104-80.576 0l-94.208 119.232v-319.936c0-34.176-32.064-64.064-64.64-64.064-32.512 0-63.36 29.888-63.36 64.064v319.936l-95.488-119.296c-22.272-23.168-58.304-23.168-80.576 0z" />
|
||||
<glyph unicode="" d="M723.392 353.6c-11.328 11.456-15.104 32.704-8.384 47.296 0 0 47.232 102.464 47.232 177.728 0 210.624-170.432 381.376-380.736 381.376s-380.8-170.752-380.8-381.312c0-210.624 170.496-381.376 380.8-381.376 75.2 0 177.408 47.36 177.408 47.36 14.656 6.784 35.968 2.944 47.232-8.448l291.456-291.776c11.456-11.392 30.080-11.392 41.344 0l75.776 75.904c11.456 11.456 11.456 30.144 0 41.472l-291.328 291.776zM381.504 373.376c-113.088 0-205.056 92.032-205.056 205.312 0 113.216 92.032 205.312 205.056 205.312s204.992-92.096 204.992-205.312c0-113.28-91.904-205.312-204.992-205.312z" />
|
||||
<glyph unicode="" d="M449.024 596.288c106.56 0 193.024 81.344 193.024 181.888-0.064 100.416-86.464 181.824-193.024 181.824s-193.024-81.408-193.024-181.824c0-100.48 86.464-181.888 193.024-181.888zM600.32 583.68c-42.56-29.44-94.592-47.424-151.296-47.424-56.96 0-109.12 18.112-151.744 47.744-173.248-37.312-297.28-136.832-297.28-254.016v-258.88c0-17.152 14.4-31.104 32-31.104h64c17.6 0 32 12.608 32 28.096 0 8.96 0 201.856 0 201.856 0 16.64 9.536 9.984 21.376 9.984 11.776 0 21.312-9.024 21.312-19.968l0.32-179.968c0.896-10.368 9.6-84.416 20.544-86.592 0 0 66.56-57.344 256.448-57.344 191.232 0 256.448 57.344 256.448 57.344 10.944 2.112 19.712 76.16 20.544 86.592l0.32 179.968c0 11.008 9.536 19.968 21.376 19.968 11.776 0 21.312-9.024 21.312-19.968 0 0 0-182.912 0-191.872 0-15.488 14.4-28.096 32-28.096h64c17.6 0 32 14.016 32 31.104v258.88c0 116.864-123.392 216.128-295.68 253.696z" />
|
||||
<glyph unicode="" d="M896 864c-50.496 0-768 0-768 0-50.496 0-128-41.152-128-90.944v-18.112c0 0 432.768-361.856 512-361.856s512 360.704 512 360.704v19.2c0 49.856-77.504 91.008-128 91.008zM0 608.96v-512.896c0 0 0-64.064 128-64.064h768c128.192 0 128 64.064 128 64.064v514.496c0 0-364.16-324.992-512-324.992-146.304 0-512 323.392-512 323.392z" />
|
||||
<glyph unicode="" d="M896-64h-768c-35.328 0-64 28.608-64 64.064v447.936c0 35.328 28.672 64 64 64h64v128c0 176.704 143.232 320 320 320s320-143.296 320-320v-128h64c35.392 0 64-28.672 64-64v-447.936c0-35.456-28.608-64.064-64-64.064zM704 640c0 105.984-85.952 192-192 192s-192-86.016-192-192v-128h384v128z" />
|
||||
<glyph unicode="" d="M767.872 787.008l-0.128-0.064c-0.896 0.64-1.6 1.536-2.624 2.24-29.184 20.032-68.992 12.608-89.024-16.704-19.968-29.312-12.48-69.312 16.64-89.344 0.768-0.64 1.536-0.896 2.24-1.28l-0.256-0.448c82.88-58.048 137.28-154.496 137.28-263.744 0-177.536-143.296-321.472-320-321.472s-320 143.936-320 321.472c0 109.248 54.4 205.696 137.28 263.744l-0.256 0.448c0.704 0.384 1.472 0.64 2.24 1.216 29.184 20.032 36.608 60.032 16.64 89.344-20.032 29.312-59.84 36.8-89.024 16.704-0.96-0.704-1.728-1.536-2.688-2.24l-0.064 0.128c-116.032-81.408-192.128-216.32-192.128-369.344 0-248.576 200.576-450.176 448-450.176s448 201.6 448 450.176c0 153.024-76.096 287.936-192.128 369.344zM512 352c35.392 0 64 28.608 64 64v447.936c0 35.392-28.608 64.064-64 64.064-35.328 0-64-28.672-64-64.064v-447.936c0-35.392 28.672-64 64-64z" />
|
||||
<glyph unicode="" d="M320 576c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM512 384c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM320 384c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM896 895.936h-128c0 35.392-28.608 64.064-64 64.064s-64-28.672-64-64.064h-256c0 35.392-28.672 64.064-64 64.064s-64-28.672-64-64.064h-128c-70.656 0-128-57.28-128-127.936v-640c0-70.72 57.344-128 128-128h768c70.656 0 128 57.28 128 128v640c0 70.656-57.344 127.936-128 127.936zM896 128h-768v640h128c0-35.392 28.672-64 64-64s64 28.608 64 64h256c0-35.392 28.608-64 64-64s64 28.608 64 64h128v-640zM704 576c-35.392 0-64-28.608-64-64s28.608-64 64-64 64 28.608 64 64-28.608 64-64 64zM512 576c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM704 384c-35.392 0-64-28.608-64-64s28.608-64 64-64 64 28.608 64 64-28.608 64-64 64z" />
|
||||
<glyph unicode="" d="M918.272 527.040c-17.344 2.56-35.968 18.304-41.344 35.008l-26.112 63.232c-8.128 15.552-6.272 39.872 4.352 53.952l42.112 56.192c10.624 14.080 9.728 36.352-1.984 49.536l-46.272 46.4c-13.12 11.712-35.52 12.544-49.6 1.984l-56.128-42.24c-14.144-10.496-38.4-12.48-54.016-4.288l-63.168 26.048c-16.832 5.312-32.64 24-35.008 41.472l-9.984 69.504c-2.496 17.408-18.816 33.152-36.352 34.944 0 0-10.816 1.216-32.768 1.216s-32.768-1.216-32.768-1.216c-17.536-1.792-33.92-17.536-36.352-34.944l-9.984-69.504c-2.432-17.472-18.176-36.16-35.008-41.472l-63.168-26.048c-15.552-8.192-39.808-6.208-53.888 4.288l-56.256 42.24c-14.016 10.624-36.416 9.728-49.6-1.984l-46.208-46.272c-11.648-13.184-12.544-35.52-1.984-49.6l42.176-56.192c10.56-14.080 12.48-38.4 4.288-53.952l-26.048-63.296c-5.376-16.704-24-32.448-41.408-35.008l-69.504-9.792c-17.472-2.56-33.216-18.88-35.008-36.416 0 0-1.152-10.88-1.152-32.832 0-21.952 1.152-32.896 1.152-32.896 1.856-17.472 17.6-33.792 35.008-36.288l69.504-9.856c17.408-2.496 36.032-18.304 41.408-35.008l26.112-63.232c8.192-15.616 6.272-39.808-4.288-53.888l-42.176-56.256c-10.56-14.144-13.12-33.28-5.632-42.496 7.424-9.216 28.864-32.064 28.928-32.064 0-0.128 7.232-6.72 16-14.656 8.768-8.064 44.48-19.2 58.56-8.64l56.256 42.112c14.080 10.624 38.336 12.544 53.888 4.352l63.040-25.984c16.832-5.44 32.576-24 35.008-41.472l9.984-69.504c2.432-17.344 18.816-33.28 36.288-35.072 0 0 10.88-1.152 32.832-1.152s32.768 1.152 32.768 1.152c17.472 1.792 33.856 17.664 36.352 35.072l9.984 69.504c2.368 17.472 18.112 36.032 35.008 41.472l63.104 25.984c15.616 8.192 39.872 6.272 54.016-4.224l56.256-42.24c14.144-10.56 36.352-9.664 49.6 1.92l46.272 46.336c11.648 13.184 12.48 35.52 1.856 49.6l-42.112 56.256c-10.624 14.080-12.48 38.272-4.352 53.888l26.112 63.232c5.376 16.768 24 32.512 41.344 35.008l69.504 9.856c17.344 2.496 33.152 18.816 35.008 36.288 0 0 1.152 10.88 1.152 32.896 0 21.952-1.152 32.832-1.152 32.832-1.856 17.536-17.6 33.856-35.008 36.416l-69.44 9.792zM512 320c-70.656 0-128 57.344-128 128 0 70.72 57.344 128 128 128 70.592 0 128-57.344 128-128 0-70.656-57.344-128-128-128z" />
|
||||
<glyph unicode="" d="M768 697.024v0h128c35.392 0 64-28.672 64-64v-640c0-35.392-28.608-64-64-64h-672c-88.384 0-160 71.616-160 160v703.936c0 88.384 71.616 160.064 160 160.064h672c35.392 0 64-28.672 64-64 0-35.392-28.608-64.064-64-64.064h-640c-35.328 0-64-28.608-64-64s28.672-64 64-64h128v-256l64 64 64-64v256h256z" />
|
||||
<glyph unicode="" d="M0 64v192h128v-192.128h640v768.128h-640v-192h-128v192c0 70.656 57.344 128 128 128h640c70.72 0 128-57.344 128-128v-768c0-70.72-57.28-128-128-128h-640c-70.656 0-128 57.28-128 128zM264.768 688c23.232 22.272 60.864 22.272 84.096 0l209.408-196.8c6.528-6.208 10.496-13.568 13.504-21.184 0.064-0.128 0.064-0.192 0.128-0.32 2.24-5.824 3.456-11.84 3.648-17.984 0.256-2.24 0.448-4.416 0.256-6.72-0.128-2.688-1.024-5.248-1.664-7.936-2.176-11.264-6.656-22.208-15.872-30.976l-209.408-196.8c-23.232-22.272-60.864-22.272-84.096 0-23.168 22.272-23.168 58.24 0 80.512l119.232 94.208h-320c-34.112 0-64 32.064-64 64.64 0 32.512 29.888 63.36 64 63.36h320l-119.232 95.552c-23.232 22.144-23.232 58.304 0 80.448z" />
|
||||
<glyph unicode="" d="M928 704h-64v-640c0 0-1.984-128-128-128 0 0-318.016 0-448 0s-128 128-128 128v640h-64c-35.328 0-64 28.672-64 64s28.672 64 64 64h320v32c0 53.056 42.944 96 96 96 52.992 0 96-42.944 96-96v-32h320c35.392 0 64-28.608 64-64s-28.608-64-64-64zM736 704h-448v-640h448v640zM416 640c35.328 0 64-28.672 64-64v-384c0-35.392-28.672-64-64-64s-64 28.608-64 64v384c0 35.328 28.672 64 64 64zM608 640c35.392 0 64-28.672 64-64v-384c0-35.392-28.608-64-64-64s-64 28.608-64 64v384c0 35.328 28.608 64 64 64z" />
|
||||
<glyph unicode="" d="M896 768c0 0-278.016 0.064-320 0.064s-89.984 127.936-128 127.936-320 0-320 0c-70.656 0-128-57.28-128-128v-640.064c0-126.656 128-128 128-128h768c70.656 0 128 57.344 128 128v512c0 70.72-57.344 128.064-128 128.064zM896.064 127.936h-768.064v640.064c0 0 214.016 0 254.016 0s89.984-128 128-128c40 0 386.048 0 386.048 0v-512.064z" />
|
||||
<glyph unicode="" d="M895.424 960.064h-767.872c-127.296 0-127.552-128.064-127.552-128.064v-511.936c0 0 0.704-128.064 128-128.064h256c0 0 53.568-1.472 73.344-23.936l289.344-226.496c4.736-3.776 7.616-5.632 10.432-5.632 8 0 10.368 5.504 10.368 14.592v214.336c0 15.104 9.984 27.2 23.424 27.2h105.088c125.312 0 128 128.064 128 128.064v511.872c0 0-1.28 128.064-128.576 128.064zM896 320.064h-256v-128l-164.608 128h-347.392v511.936h768v-511.936z" />
|
||||
<glyph unicode="" d="M896 63.872h-768v768h320v128l-358.976 0.064c-49.152 0-89.024-39.936-89.024-89.088v-845.952c0-49.152 39.872-89.024 89.024-89.024h845.952c49.152 0 89.024 39.872 89.024 89.024v358.976h-128v-320zM1024 896c0 14.656-6.080 27.52-14.72 38.272-1.344 1.728-2.048 3.712-3.584 5.312-0.192 0.128-0.256 0.384-0.384 0.576-0.384 0.32-0.448 0.832-0.832 1.216-4.096 4.096-9.152 6.528-13.952 9.28-2.112 1.216-3.84 3.008-6.080 3.968-8.704 3.776-17.92 5.376-27.264 5.12-0.128 0-0.256 0.064-0.384 0.064h-313.024c-36.992 0.064-67.008-28.544-67.008-63.808 0-35.2 30.080-63.808 67.136-63.808h161.216l-402.56-403.328c-24.832-24.768-24.832-64.768 0-89.472 24.832-24.768 65.024-24.768 89.792 0l403.968 403.52v-163.2c0-37.056 28.608-67.072 63.872-67.072s63.808 30.016 63.808 67.072v313.024c0 0.64-0.32 1.152-0.32 1.728 0 0.512 0.32 1.024 0.32 1.536z" />
|
||||
<glyph unicode="" d="M0 576.448v107.712c0 45.952 38.208 83.136 85.312 83.136h107.392v90.432c0 21.056 21.568 102.208 48.192 102.208h96.384c26.624 0 48.192-81.152 48.192-102.208v-90.432h319.232v90.432c0 21.056 21.632 102.208 48.192 102.208h96.384c26.624 0 48.192-81.152 48.192-102.208v-90.432h41.28c47.168 0 85.376-37.184 85.376-83.136v-107.776h-1024.128zM1024.064 511.36v-492.224c0-45.952-38.208-83.2-85.376-83.2h-853.376c-47.104 0-85.312 37.248-85.312 83.2v492.224h1024.064z" />
|
||||
<glyph unicode="" d="M32 447.936c288 32.064 448 192.064 480 480.064 32.064-288 192.064-448 480.128-480.064-288.064-32-448.064-192-480.128-480-32 288-192 448-480 480z" />
|
||||
<glyph unicode="" d="M1024 448l-380.8-128-10.304-384-245.696 304.96-387.2-109.376 228.992 316.416-228.992 316.416 387.2-109.312 245.696 304.896 10.304-384 380.8-128z" />
|
||||
<glyph unicode="" d="M768 223.552c35.392 0 64 28.672 64 64.064s-28.608 64.064-64 64.064-64-28.672-64-64.064 28.608-64.064 64-64.064zM938.752 864h-853.376c-47.168 0-85.376-38.208-85.376-85.376v-661.184c0-47.168 38.208-85.44 85.376-85.44h853.376c47.104 0 85.312 38.272 85.312 85.44v661.184c0 47.168-38.208 85.376-85.312 85.376zM896.064 160.192h-768.064v255.552h768.064v-255.552zM896.064 607.872h-768.064v128.064h768.064v-128.064z" />
|
||||
<glyph unicode="" d="M939.712 875.712c-112.448 112.448-294.784 112.448-407.296-0.064l-448-448c-112.512-112.512-112.512-294.848-0.064-407.296s294.784-112.512 407.296 0l94.848 92.16c-51.008 1.152-97.536 17.728-136.96 44.672l-48.448-46.4c-62.528-62.528-163.84-62.528-226.304 0-62.464 62.464-62.464 163.84 0.064 226.304l448 448c62.528 62.528 163.84 62.528 226.24 0 62.528-62.528 62.592-163.776 0.064-226.24l-223.232-224.768c-18.752-18.752-49.152-18.752-67.904 0s-18.752 49.152 0 67.904l168.576 170.176c12.48 12.48 12.544 32.768 0 45.248l-45.248 45.248c-12.48 12.48-32.768 12.48-45.248 0l-168.576-170.176c-68.736-68.736-68.736-180.16 0-248.896s180.16-68.736 248.896 0l223.232 224.832c112.448 112.448 112.448 294.848 0.064 407.296z" />
|
||||
<glyph unicode="" d="M939.648 875.648c-54.464 54.4-126.784 84.352-203.648 84.352-76.928 0-149.248-29.952-203.648-84.352 0 0-181.696-181.632-192.128-191.936-54.208-54.336-84.096-126.72-84.224-204.096 0.128-76.8 30.080-148.992 84.352-203.264l23.36-23.424c6.272-6.272 14.528-9.344 22.656-9.344 8.192 0 16.384 3.136 22.656 9.344l45.248 45.248c12.48 12.48 12.48 32.768 0 45.248l-23.424 23.424c-61.376 61.376-62.208 162.048-1.792 224.512 1.856 1.856 193.856 193.792 193.856 193.792 30.208 30.208 70.336 46.848 113.088 46.848s82.88-16.64 113.152-46.784v-0.064c62.528-62.592 62.528-163.776 0-226.24l-9.856-9.856c15.424-41.6 24.64-86.208 24.704-133.056 0-8.512-1.216-16.704-1.664-25.024l77.312 77.376c112.448 112.512 112.384 294.912 0 407.296zM660.16 643.136c-6.208 6.272-14.464 9.344-22.592 9.344-8.256 0-16.448-3.136-22.656-9.344l-45.248-45.248c-12.544-12.48-12.544-32.768 0-45.248l23.36-23.424c61.376-61.376 62.272-162.048 1.856-224.512-1.856-1.856-193.856-193.792-193.856-193.792-30.144-30.272-70.272-46.912-113.088-46.912-42.688 0-82.816 16.64-113.088 46.784v0.064c-62.528 62.592-62.528 163.776-0.064 226.24l9.92 9.856c-15.488 41.6-24.704 86.208-24.704 133.056 0 8.512 1.152 16.704 1.664 25.024l-77.312-77.376c-112.512-112.512-112.448-294.848 0-407.232 54.464-54.464 126.784-84.416 203.648-84.416s149.184 29.952 203.648 84.352c0 0 181.696 181.632 192.128 191.936 54.208 54.336 84.096 126.72 84.224 204.096-0.128 76.8-30.144 148.992-84.352 203.264l-23.488 23.488z" />
|
||||
<glyph unicode="" d="M1012.736 484.16l-241.216 352c-11.968 17.408-31.68 27.84-52.8 27.84h-654.72c-35.392 0-64-28.672-64-64v-704c0-35.328 28.608-64 64-64h654.72c21.12 0 40.896 10.368 52.8 27.84l241.216 352c15.040 21.76 15.040 50.56 0 72.32zM736 352c-52.992 0-96 43.008-96 96s43.008 96 96 96 96-43.008 96-96-43.008-96-96-96z" />
|
||||
<glyph unicode="" d="M842.752 960h-660.544c-47.552 0-86.208-38.144-86.208-64v-853.376c0-68.416 38.656-106.624 86.208-106.624h660.544c47.040 0 85.248 38.208 85.248 85.312v853.376c0 47.168-38.208 85.312-85.248 85.312zM544 128h-256c-35.392 0-64 28.608-64 64s28.608 64 64 64h256c35.392 0 64-28.608 64-64s-28.608-64-64-64zM736 384h-448c-35.392 0-64 28.608-64 64s28.608 64 64 64h448c35.392 0 64-28.608 64-64s-28.608-64-64-64zM736 640h-448c-35.392 0-64 28.608-64 64s28.608 64 64 64h448c35.392 0 64-28.608 64-64s-28.608-64-64-64z" />
|
||||
<glyph unicode="" d="M938.752 32h-853.376c-47.168 0-85.376 37.248-85.376 83.264v665.472c0 46.016 38.208 83.264 85.376 83.264h853.376c47.104 0 85.312-37.248 85.312-83.264v-665.472c0-46.016-38.208-83.264-85.312-83.264zM896.064 736h-768.064v-511.808c0 0 64 64.064 128 128.064 64 64.064 128 0 128 0l64-64c0 0 118.72 120.768 192 192.128 66.88 66.944 128 0 128 0l128-128.128 0.064 383.744zM320 480c-35.328 0-64 28.672-64 63.936 0 35.392 28.672 64.064 64 64.064s64-28.672 64-64.064c0-35.264-28.672-63.936-64-63.936z" />
|
||||
<glyph unicode="" d="M928-64h-832c-51.2 0-96 44.8-96 96v832c0 51.2 44.8 96 96 96h825.6c57.6 0 102.4-44.8 102.4-96v-825.6c0-57.6-44.8-102.4-96-102.4zM748.8 768c-121.6 0-172.8-83.2-172.8-166.4v-89.6h-64v-128h64v-384h128v384h128v128h-128v70.4c0 38.4 6.4 57.6 51.2 57.6h76.8v121.6s-38.4 6.4-83.2 6.4z" />
|
||||
<glyph unicode="" d="M1017.6 646.4c0 83.2-64 147.2-147.2 147.2-115.2 6.4-236.8 6.4-358.4 6.4-121.6 0-243.2 0-358.4-6.4-83.2 0-147.2-64-147.2-147.2-6.4-70.4-6.4-134.4-6.4-198.4s0-128 6.4-198.4c0-83.2 64-147.2 147.2-147.2 115.2-6.4 236.8-6.4 358.4-6.4 121.6 0 243.2 0 358.4 6.4 83.2 0 147.2 64 147.2 147.2 6.4 64 6.4 128 6.4 198.4 0 64 0 128-6.4 198.4zM384 224v448l320-224-320-224z" />
|
||||
<glyph unicode="" d="M876.8 896c-147.2 6.4-243.2-76.8-294.4-243.2 25.6 12.8 51.2 19.2 76.8 19.2 51.2 0 76.8-32 70.4-89.6 0-38.4-25.6-89.6-70.4-153.6-38.4-70.4-70.4-102.4-96-102.4-25.6 0-51.2 51.2-76.8 160-6.4 25.6-19.2 108.8-38.4 236.8-19.2 115.2-70.4 172.8-147.2 160-32 0-83.2-32-153.6-96-44.8-38.4-96-83.2-147.2-128l51.2-64c44.8 32 70.4 51.2 76.8 51.2 38.4 0 70.4-57.6 96-166.4 32-108.8 57.6-211.2 83.2-313.6 38.4-108.8 89.6-166.4 153.6-166.4 96 0 211.2 89.6 352 275.2 134.4 179.2 204.8 313.6 211.2 416 6.4 134.4-44.8 204.8-147.2 204.8z" />
|
||||
<glyph unicode="" d="M1024 768c-38.4-19.2-76.8-25.6-121.6-32 44.8 25.6 76.8 64 89.6 115.2-38.4-25.6-83.2-38.4-134.4-51.2-38.4 38.4-96 64-153.6 64-108.8 0-204.8-96-204.8-211.2 0-19.2 0-32 6.4-44.8-172.8 6.4-332.8 89.6-435.2 217.6-19.2-32-25.6-64-25.6-102.4 0-70.4 38.4-134.4 96-172.8-32 0-64 12.8-96 25.6 0-102.4 70.4-185.6 166.4-204.8-19.2-12.8-38.4-12.8-57.6-12.8-12.8 0-25.6 0-38.4 6.4 25.6-83.2 102.4-147.2 198.4-147.2-70.4-57.6-160-89.6-262.4-89.6h-51.2c96-64 204.8-96 320-96 384 0 595.2 320 595.2 595.2v25.6c44.8 32 83.2 70.4 108.8 115.2z" />
|
||||
<glyph unicode="" d="M179.2 57.6c76.8 115.2 211.2 185.6 358.4 185.6 134.4 0 256-64 339.2-160 89.6 96 147.2 224 147.2 364.8 0 281.6-230.4 512-512 512s-512-230.4-512-512c0-153.6 70.4-294.4 179.2-390.4zM787.2 294.4c-6.4-19.2-19.2-19.2-38.4-12.8-70.4 32-147.2 51.2-224 51.2-83.2 0-160-19.2-230.4-51.2-6.4-6.4-25.6-6.4-32 19.2-6.4 12.8 6.4 25.6 12.8 32 76.8 38.4 160 57.6 249.6 57.6s172.8-19.2 243.2-51.2c12.8-12.8 25.6-25.6 19.2-44.8zM832 422.4c-6.4-6.4-12.8-12.8-25.6-12.8h-6.4c-83.2 38.4-179.2 64-275.2 64s-185.6-19.2-268.8-57.6h-6.4c-12.8 0-19.2 6.4-25.6 12.8l-6.4 12.8c0 6.4 6.4 19.2 12.8 19.2 89.6 38.4 192 64 300.8 64 108.8 0 211.2-25.6 300.8-64v-38.4zM185.6 633.6c102.4 44.8 217.6 64 339.2 64 115.2 0 230.4-25.6 332.8-64 12.8-6.4 25.6-19.2 25.6-38.4 0-25.6-19.2-44.8-44.8-44.8h-6.4c-96 38.4-198.4 57.6-307.2 57.6s-211.2-19.2-307.2-51.2h-6.4c-25.6 0-44.8 19.2-44.8 44.8 0 6.4 6.4 25.6 19.2 32zM537.6 76.8c-89.6 0-166.4-44.8-211.2-108.8 57.6-19.2 121.6-32 185.6-32 83.2 0 160 19.2 224 51.2-44.8 57.6-115.2 89.6-198.4 89.6z" />
|
||||
<glyph unicode="" d="M979.2 371.2c6.4 25.6 6.4 51.2 6.4 76.8 0 262.4-211.2 473.6-473.6 473.6-25.6 0-51.2 0-76.8-6.4-38.4 32-89.6 44.8-147.2 44.8-160 0-288-128-288-288 0-57.6 12.8-108.8 44.8-153.6-6.4-19.2-6.4-44.8-6.4-70.4 0-262.4 211.2-473.6 473.6-473.6 25.6 0 51.2 0 76.8 6.4 44.8-25.6 96-44.8 153.6-44.8 160 0 288 128 288 288-6.4 57.6-19.2 108.8-51.2 147.2zM736 230.4c-19.2-32-51.2-51.2-89.6-70.4-38.4-19.2-83.2-25.6-134.4-25.6-64 0-115.2 12.8-160 32-32 12.8-51.2 38.4-70.4 64-19.2 32-25.6 57.6-25.6 83.2 0 12.8 6.4 25.6 19.2 38.4 12.8 12.8 25.6 19.2 44.8 19.2 12.8 0 25.6-6.4 38.4-12.8 6.4-6.4 12.8-19.2 19.2-38.4 6.4-19.2 19.2-32 25.6-44.8 6.4-12.8 19.2-25.6 38.4-32 19.2-6.4 38.4-12.8 64-12.8 38.4 0 70.4 6.4 89.6 25.6 25.6 19.2 32 38.4 32 57.6 0 19.2-6.4 32-19.2 44.8-6.4 19.2-19.2 25.6-38.4 32-19.2 6.4-51.2 12.8-83.2 19.2-44.8 12.8-83.2 25.6-115.2 38.4-32 12.8-57.6 32-76.8 51.2-19.2 25.6-25.6 57.6-25.6 89.6 0 32 12.8 64 32 89.6 19.2 25.6 44.8 44.8 83.2 57.6 38.4 12.8 76.8 19.2 128 19.2 38.4 0 70.4-6.4 102.4-12.8 25.6-6.4 51.2-19.2 70.4-38.4 19.2-12.8 32-32 44.8-44.8s12.8-32 12.8-51.2c0-12.8-6.4-25.6-19.2-38.4-12.8-12.8-25.6-19.2-44.8-19.2-12.8 0-25.6 6.4-32 12.8-6.4 6.4-19.2 19.2-25.6 32-12.8 25.6-25.6 38.4-44.8 51.2-12.8 12.8-38.4 19.2-76.8 19.2-32 0-57.6-6.4-76.8-19.2-19.2-12.8-32-25.6-32-44.8 0-12.8 6.4-19.2 12.8-32l25.6-19.2c12.8-6.4 25.6-12.8 38.4-12.8 12.8-6.4 32-6.4 64-12.8 32-12.8 64-25.6 96-32 32-6.4 51.2-19.2 76.8-32 19.2-12.8 38.4-32 51.2-51.2 6.4-25.6 12.8-51.2 12.8-76.8 0-38.4-12.8-70.4-32-102.4z" />
|
||||
<glyph unicode="" d="M512 960c-281.6 0-512-230.4-512-512 0-211.2 128-390.4 307.2-467.2 0 38.4 0 76.8 6.4 115.2 12.8 38.4 64 281.6 64 281.6s-12.8 32-12.8 76.8c0 76.8 44.8 134.4 96 134.4s70.4-32 70.4-76.8-32-115.2-44.8-179.2c-12.8-57.6 25.6-96 83.2-96 96 0 160 121.6 160 275.2 0 115.2-76.8 198.4-211.2 198.4-153.6 0-249.6-115.2-249.6-243.2 0-44.8 12.8-76.8 32-102.4 6.4-12.8 12.8-12.8 6.4-25.6 0-6.4-6.4-32-12.8-38.4-6.4-12.8-12.8-19.2-25.6-12.8-70.4 32-102.4 108.8-102.4 198.4 0 147.2 121.6 320 364.8 320 198.4 0 326.4-140.8 326.4-294.4 0-198.4-108.8-352-275.2-352-57.6 0-108.8 32-128 64 0 0-32-115.2-38.4-140.8-12.8-38.4-32-76.8-51.2-108.8 51.2-32 96-38.4 147.2-38.4 281.6 0 512 230.4 512 512s-230.4 512-512 512z" />
|
||||
<glyph unicode="" d="M256 915.2c-134.4-51.2-224-147.2-249.6-288-12.8-83.2-6.4-172.8 32-249.6 6.4-19.2 19.2-32 32-51.2l19.2-19.2c12.8 6.4 25.6 6.4 32 12.8 44.8 25.6 76.8 64 115.2 96-128 153.6 6.4 332.8 172.8 377.6 160 38.4 371.2-25.6 416-192 19.2-64 6.4-140.8-44.8-192-25.6-25.6-64-44.8-102.4-51.2-25.6-6.4-44.8-6.4-70.4 0-12.8 6.4-25.6 6.4-38.4 6.4-19.2 6.4-38.4 6.4-38.4 25.6v268.8c0 19.2 0 12.8-12.8 19.2-12.8 0-25.6 0-38.4 6.4-38.4 0-83.2 0-121.6-6.4-12.8 0-19.2 0-19.2-19.2v-140.8l6.4-294.4c0-32 0-102.4-32-115.2-38.4-19.2-70.4 19.2-108.8 25.6 6.4-51.2-25.6-147.2 32-172.8 51.2-25.6 115.2-32 172.8-12.8 115.2 38.4 153.6 172.8 140.8 275.2 179.2-51.2 377.6 38.4 454.4 198.4 57.6 115.2 32 262.4-51.2 358.4-166.4 185.6-480 224-697.6 134.4z" />
|
||||
<glyph unicode="" d="M928-64h-832c-51.2 0-96 44.8-96 96v832c0 51.2 44.8 96 96 96h825.6c57.6 0 102.4-44.8 102.4-96v-825.6c0-57.6-44.8-102.4-96-102.4zM262.4 768c-44.8 0-76.8-32-76.8-76.8 0-38.4 25.6-76.8 70.4-76.8 44.8 0 70.4 32 70.4 76.8 6.4 44.8-19.2 76.8-64 76.8zM339.2 569.6h-147.2v-441.6h147.2v441.6zM876.8 377.6c0 134.4-64 204.8-160 204.8-76.8 0-108.8-44.8-128-70.4v64h-153.6v-441.6h147.2v236.8c0 12.8 0 25.6 6.4 32 12.8 25.6 32 51.2 76.8 51.2 51.2 0 70.4-38.4 70.4-96v-230.4h147.2v249.6z" />
|
||||
<glyph unicode="" d="M0 89.6v0zM236.8 396.8c89.6 0 153.6 96 140.8 211.2-19.2 121.6-108.8 217.6-198.4 217.6-89.6 6.4-153.6-89.6-140.8-211.2 19.2-115.2 108.8-217.6 198.4-217.6zM1024 704v83.2c0 96-76.8 172.8-166.4 172.8h-684.8c-96 0-172.8-76.8-172.8-166.4 57.6 51.2 140.8 96 224 96h358.4l-83.2-70.4h-108.8c70.4-25.6 115.2-115.2 115.2-204.8 0-76.8-44.8-140.8-102.4-185.6-57.6-44.8-70.4-64-70.4-102.4 0-32 64-89.6 96-108.8 96-64 128-128 128-230.4 0-19.2 0-32-6.4-51.2h307.2c96 0 172.8 76.8 172.8 172.8v531.2h-192v-192h-64v192h-198.4v64h192v192h64v-192h192zM185.6 192h64c-25.6 25.6-51.2 57.6-51.2 96 0 25.6 6.4 44.8 19.2 64h-32c-76.8 6.4-140.8 32-185.6 70.4v-275.2c51.2 32 115.2 44.8 185.6 44.8zM6.4 70.4v19.2c-6.4-6.4-6.4-12.8 0-19.2zM454.4 6.4c-12.8 57.6-70.4 89.6-140.8 140.8-25.6 6.4-57.6 12.8-89.6 12.8-89.6 0-172.8-32-217.6-89.6 12.8-76.8 83.2-134.4 166.4-134.4h288v32c0 12.8 0 25.6-6.4 38.4z" />
|
||||
<glyph unicode="" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512-230.4 512-512 512zM825.6 697.6c51.2-64 83.2-140.8 83.2-230.4-57.6 12.8-115.2 19.2-166.4 19.2-38.4 0-76.8-6.4-115.2-12.8l-25.6 64c83.2 32 160 83.2 224 160zM512 844.8c96 0 179.2-32 249.6-89.6-51.2-64-121.6-108.8-198.4-140.8-51.2 108.8-102.4 179.2-134.4 224 25.6 6.4 51.2 6.4 83.2 6.4zM332.8 806.4c32-32 83.2-102.4 147.2-217.6-121.6-38.4-243.2-44.8-320-44.8h-38.4c32 115.2 108.8 211.2 211.2 262.4zM115.2 448c12.8 6.4 25.6 6.4 44.8 6.4 83.2 0 217.6 6.4 364.8 51.2 6.4-19.2 12.8-32 25.6-51.2-102.4-32-179.2-83.2-230.4-134.4-51.2-51.2-89.6-96-108.8-128-64 70.4-96 160-96 256zM512 51.2c-89.6 0-172.8 32-236.8 76.8 12.8 25.6 44.8 70.4 89.6 115.2 51.2 44.8 115.2 96 204.8 128 32-83.2 57.6-185.6 76.8-294.4-38.4-19.2-83.2-25.6-134.4-25.6zM736 121.6c-19.2 102.4-44.8 185.6-76.8 268.8 25.6 6.4 51.2 6.4 83.2 6.4 44.8 0 102.4-6.4 153.6-19.2-12.8-108.8-70.4-198.4-160-256z" />
|
||||
<glyph unicode="" d="M921.6 678.4h-256v64h256v-64zM499.2 416c12.8-25.6 25.6-57.6 25.6-96s-6.4-70.4-25.6-102.4l-51.2-51.2c-19.2-12.8-44.8-25.6-70.4-32s-57.6-6.4-89.6-6.4h-288v640h307.2c76.8 0 134.4-25.6 166.4-70.4 19.2-25.6 25.6-57.6 25.6-96s-12.8-70.4-32-96c-6.4-12.8-19.2-25.6-44.8-32 32-12.8 57.6-32 76.8-57.6zM147.2 518.4h134.4c25.6 0 51.2 6.4 70.4 12.8 19.2 12.8 25.6 32 25.6 57.6 0 32-12.8 51.2-32 57.6-25.6 6.4-51.2 12.8-83.2 12.8h-115.2v-140.8zM390.4 332.8c0 32-12.8 57.6-38.4 70.4-12.8 6.4-38.4 12.8-64 12.8h-140.8v-172.8h134.4c25.6 0 51.2 6.4 64 12.8 25.6 6.4 44.8 32 44.8 76.8zM1017.6 435.2c6.4-19.2 6.4-51.2 6.4-89.6h-332.8c0-44.8 19.2-76.8 44.8-96 19.2-12.8 38.4-19.2 64-19.2s51.2 6.4 64 19.2c19.2 6.4 25.6 19.2 32 32h121.6c0-25.6-19.2-57.6-44.8-83.2-38.4-44.8-96-64-172.8-64-57.6 0-115.2 19.2-160 57.6-44.8 32-70.4 96-70.4 179.2 0 76.8 19.2 140.8 64 185.6 44.8 44.8 96 64 166.4 64 38.4 0 76.8-6.4 108.8-19.2 32-12.8 57.6-38.4 76.8-70.4 19.2-32 25.6-64 32-96zM902.4 422.4c0 32-12.8 57.6-32 70.4-19.2 19.2-44.8 25.6-70.4 25.6-32 0-51.2-6.4-70.4-25.6-19.2-19.2-25.6-38.4-32-70.4h204.8z" />
|
||||
<glyph unicode="" d="M565.888 547.328l69.824-33.728 105.408 33.728v61.184c0 126.080-102.784 228.608-229.12 228.608s-229.056-102.592-229.056-228.608v-321.024c0-29.632-24.192-53.696-53.824-53.696s-53.824 24.064-53.824 53.696v134.4h-175.296v-134.4c0-126.080 102.72-228.608 229.12-228.608 126.336 0 229.12 102.592 229.12 228.608v321.024c0 29.568 24.192 53.696 53.824 53.696 29.696 0 53.888-24.128 53.888-53.696l-0.064-61.184zM848.704 421.888v-134.4c0-29.632-24.128-53.696-53.824-53.696-29.696 0-53.888 24.064-53.888 53.696v137.088l-105.344-33.728-69.824 33.728v-137.088c0-126.080 102.784-228.608 229.12-228.608s229.056 102.592 229.056 228.608v134.4h-175.296z" />
|
||||
<glyph unicode="" d="M608 307.2c-19.2-19.2 0-51.2 0-51.2l128-217.6s19.2-25.6 38.4-25.6 38.4 12.8 38.4 12.8l102.4 147.2s12.8 19.2 12.8 32c0 25.6-32 32-32 32l-243.2 76.8c-6.4 0-25.6 6.4-44.8-6.4zM595.2 416c12.8-19.2 44.8-12.8 44.8-12.8l243.2 70.4s32 12.8 38.4 32c6.4 19.2-6.4 38.4-6.4 38.4l-108.8 134.4s-12.8 19.2-32 19.2c-25.6 0-38.4-25.6-38.4-25.6l-140.8-217.6s-6.4-19.2 0-38.4zM480 499.2c32 6.4 38.4 51.2 38.4 51.2v345.6c-6.4 0-6.4 38.4-25.6 51.2-32 19.2-44.8 6.4-51.2 6.4l-198.4-70.4s-19.2-6.4-32-25.6c-12.8-25.6 12.8-57.6 12.8-57.6l211.2-288s19.2-19.2 44.8-12.8zM435.2 358.4c0 25.6-32 44.8-32 44.8l-217.6 108.8s-32 12.8-44.8 6.4c-19.2-12.8-25.6-25.6-32-32l-12.8-172.8s0-32 6.4-44.8c12.8-19.2 44.8-6.4 44.8-6.4l256 57.6c12.8 0 25.6 6.4 32 38.4zM492.8 262.4c-19.2 12.8-44.8-6.4-44.8-6.4l-172.8-185.6s-19.2-25.6-12.8-44.8c6.4-19.2 12.8-25.6 25.6-32l172.8-51.2s19.2-6.4 38.4 0c19.2 0 12.8 32 12.8 32l6.4 256s0 25.6-25.6 32z" />
|
||||
<glyph unicode="" d="M518.4 416l115.2-313.6v-6.4c-38.4-12.8-83.2-19.2-128-19.2-38.4 0-76.8 6.4-108.8 12.8l121.6 326.4zM896 448c0-140.8-76.8-256-192-326.4l115.2 332.8c19.2 51.2 32 96 32 134.4v38.4c32-51.2 44.8-115.2 44.8-179.2zM128 448c0 51.2 12.8 108.8 32 153.6l185.6-486.4c-128 57.6-217.6 185.6-217.6 332.8zM192 652.8c70.4 102.4 185.6 166.4 320 166.4 102.4 0 192-38.4 262.4-96h-6.4c-38.4 0-64-32-64-64s19.2-57.6 38.4-89.6c12.8-25.6 32-57.6 32-102.4 0-32-12.8-70.4-32-121.6l-38.4-128-140.8 403.2c25.6 0 44.8 6.4 44.8 6.4 19.2 0 19.2 32 0 32 0 0-64-6.4-102.4-6.4-38.4 0-102.4 6.4-102.4 6.4-19.2 0-25.6-32 0-32 0 0 19.2 0 38.4-6.4l57.6-160-83.2-243.2-140.8 403.2c25.6 6.4 44.8 6.4 44.8 6.4 19.2 0 19.2 32 0 32 0 0-64-6.4-102.4-6.4h-25.6zM851.2 960h-678.4c-96 0-172.8-76.8-172.8-172.8v-678.4c0-96 76.8-172.8 172.8-172.8h678.4c96 0 172.8 76.8 172.8 172.8v678.4c0 96-76.8 172.8-172.8 172.8zM960 448c0-249.6-198.4-448-448-448s-448 198.4-448 448 198.4 448 448 448 448-198.4 448-448z" />
|
||||
<glyph unicode="" d="M409.6 62.494v343.341h493.929v-439.718l-493.929 96.376zM409.6 839.529l493.929 90.353v-439.718h-493.929v349.365zM331.294 490.165h-331.294v271.059l331.294 60.235v-331.294zM331.294 80.565l-331.294 66.259v259.012h331.294v-325.271z" horiz-adv-x="904" />
|
||||
<glyph unicode="" d="M64 768c19.2-128 128-659.2 377.6-812.8 38.4-25.6 83.2-19.2 115.2 6.4 121.6 102.4 243.2 275.2 275.2 358.4 64-6.4 108.8 12.8 108.8 12.8v128h-115.2c-140.8 0-236.8 166.4-179.2 313.6 38.4 102.4 108.8 25.6 121.6 0 12.8-32 6.4-115.2-6.4-172.8 19.2-51.2 140.8-76.8 166.4-38.4 32 96 44.8 262.4-38.4 352-57.6 38.4-198.4 70.4-300.8 6.4s-102.4-204.8-96-275.2c6.4-70.4 32-217.6 172.8-300.8 12.8-12.8-153.6-230.4-160-217.6-185.6 179.2-249.6 544-262.4 640h-179.2z" />
|
||||
<glyph unicode="" d="M576 512v-236.8c0-57.6 0-96 6.4-108.8 6.4-19.2 19.2-32 38.4-44.8 25.6-12.8 51.2-19.2 76.8-19.2 51.2 0 83.2 6.4 134.4 38.4v-153.6c-44.8-19.2-83.2-32-115.2-38.4-38.4-12.8-76.8-12.8-115.2-12.8-44.8 0-76.8 6.4-108.8 19.2-38.4 12.8-64 32-89.6 51.2-25.6 19.2-44.8 44.8-51.2 70.4-12.8 25.6-12.8 57.6-12.8 108.8v352h-147.2v147.2c38.4 12.8 83.2 32 115.2 57.6 25.6 25.6 51.2 51.2 70.4 89.6 19.2 32 32 76.8 38.4 128h160v-256h256v-192h-256z" />
|
||||
<glyph unicode="" d="M646.4 236.8h-192l-64-300.8h-262.4l25.6 108.8h-153.6l198.4 915.2h448c134.4 0 288-96 236.8-313.6-38.4-192-192-300.8-371.2-300.8h-185.6l-64-300.8h-44.8l-12.8-44.8h134.4l64 300.8h243.2c76.8 0 147.2 25.6 198.4 64l32 25.6c51.2 51.2 83.2 115.2 102.4 192 12.8 76.8 6.4 140.8-32 185.6-19.2 19.2-38.4 38.4-64 51.2 96-38.4 166.4-134.4 134.4-288-38.4-179.2-192-294.4-371.2-294.4zM492.8 524.8c70.4 0 134.4 57.6 153.6 128 19.2 70.4-25.6 128-89.6 128h-128l-64-256h128z" />
|
||||
<glyph unicode="" d="M780.8 160c-204.8 0-275.2 89.6-313.6 204.8l-38.4 121.6c-25.6 89.6-64 153.6-166.4 153.6-70.4 0-147.2-51.2-147.2-198.4 0-115.2 57.6-185.6 140.8-185.6 89.6 0 153.6 70.4 153.6 70.4l44.8-102.4s-64-64-198.4-64c-166.4 0-256 96-256 275.2 0 192 89.6 300.8 262.4 300.8 153.6 0 236.8-57.6 281.6-211.2l38.4-121.6c25.6-89.6 76.8-147.2 198.4-147.2 76.8 0 121.6 19.2 121.6 64 0 32-19.2 57.6-76.8 76.8l-76.8 19.2c-96 25.6-134.4 76.8-134.4 153.6 0 128 102.4 172.8 211.2 172.8 121.6 0 192-44.8 204.8-153.6l-115.2-12.8c-6.4 51.2-38.4 70.4-89.6 70.4s-83.2-25.6-83.2-64 12.8-57.6 64-70.4l76.8-19.2c89.6-25.6 140.8-70.4 140.8-166.4 0-121.6-96-166.4-243.2-166.4z" />
|
||||
<glyph unicode="" d="M928 960h-832c-51.2 0-96-44.8-96-96v-825.6c0-57.6 44.8-102.4 96-102.4h825.6c57.6 0 96 44.8 96 96v832c6.4 51.2-38.4 96-89.6 96zM512 646.4c108.8 0 198.4-89.6 198.4-198.4s-89.6-198.4-198.4-198.4-198.4 89.6-198.4 198.4 89.6 198.4 198.4 198.4zM896 102.4c0-19.2-19.2-38.4-38.4-38.4h-691.2c-19.2 0-38.4 19.2-38.4 38.4v409.6h89.6c-6.4-25.6-6.4-51.2-6.4-76.8 0-166.4 128-307.2 300.8-307.2s300.8 140.8 300.8 307.2c0 25.6-6.4 51.2-12.8 76.8h96v-409.6zM896 678.4c0-19.2-19.2-38.4-38.4-38.4h-115.2c-19.2 0-38.4 19.2-38.4 38.4v115.2c0 19.2 19.2 38.4 38.4 38.4h115.2c19.2 0 38.4-19.2 38.4-38.4v-115.2z" />
|
||||
<glyph unicode="" d="M64 960l64-896 384-128 384 128 64 896h-896zM780.8 659.2h-428.8l12.8-115.2h409.6l-32-352-230.4-64-230.4 64-12.8 179.2h115.2v-89.6l128-32 128 32 12.8 147.2h-390.4l-32 345.6h563.2l-12.8-115.2z" />
|
||||
<glyph unicode="" d="M0 435.2c0-44.8 6.4-89.6 12.8-128s19.2-70.4 38.4-96c12.8-25.6 32-51.2 57.6-70.4s51.2-38.4 76.8-51.2c25.6-12.8 57.6-25.6 96-32l108.8-19.2s76.8-6.4 121.6-6.4 83.2 0 121.6 6.4 70.4 6.4 108.8 19.2c38.4 6.4 70.4 19.2 96 32s51.2 32 76.8 51.2c25.6 19.2 44.8 44.8 57.6 70.4 12.8 25.6 25.6 57.6 38.4 96 12.8 38.4 12.8 83.2 12.8 128 0 83.2-25.6 153.6-83.2 217.6l6.4 25.6c0 12.8 6.4 25.6 6.4 44.8v64l-19.2 76.8h-32c-12.8 0-25.6-6.4-44.8-6.4-19.2-6.4-38.4-12.8-64-25.6l-76.8-51.2c-51.2 12.8-121.6 19.2-204.8 19.2s-153.6-6.4-198.4-19.2c-32 19.2-57.6 32-83.2 44.8-25.6 12.8-44.8 19.2-64 25.6l-38.4 12.8h-38.4l-19.2-76.8c-6.4-25.6-6.4-44.8 0-64 0-19.2 6.4-32 6.4-44.8 0-12.8 6.4-19.2 6.4-25.6-57.6-64-83.2-134.4-83.2-217.6zM128 307.2c0 44.8 19.2 89.6 64 134.4 12.8 12.8 25.6 19.2 44.8 25.6 19.2 6.4 38.4 12.8 57.6 12.8h64c19.2 0 44.8 0 76.8-6.4h153.6c25.6 0 51.2 6.4 70.4 6.4h64c19.2 0 44.8-6.4 57.6-12.8 19.2-6.4 32-12.8 44.8-25.6 44.8-38.4 64-83.2 64-134.4 0-25.6-6.4-51.2-12.8-76.8l-25.6-57.6c-12.8-12.8-25.6-25.6-44.8-38.4-19.2-12.8-38.4-19.2-57.6-25.6-19.2-6.4-44.8-12.8-70.4-12.8-32 0-57.6-6.4-76.8-6.4-25.6 6.4-57.6 6.4-89.6 6.4h-89.6c-25.6 0-51.2 0-76.8 6.4-32 0-51.2 6.4-70.4 12.8-19.2 6.4-38.4 12.8-57.6 25.6-25.6 12.8-44.8 19.2-51.2 38.4-12.8 12.8-19.2 32-25.6 57.6-12.8 19.2-12.8 44.8-12.8 70.4zM640 320c0-51.2 25.6-96 64-96s64 44.8 64 96-25.6 96-64 96c-32 0-64-44.8-64-96zM256 320c0-51.2 32-96 64-96s64 44.8 64 96-25.6 96-64 96-64-44.8-64-96z" />
|
||||
<glyph unicode="" d="M985.6 364.8l-390.4-390.4c-44.8-44.8-121.6-44.8-166.4 0l-396.8 390.4c-44.8 44.8-44.8 121.6 0 166.4l390.4 390.4c51.2 51.2 128 51.2 172.8 6.4l179.2-179.2-262.4-268.8-102.4 102.4c-32 32-83.2 32-108.8 0l-83.2-83.2c-32-32-32-76.8 0-108.8l236.8-236.8c25.6-25.6 57.6-25.6 83.2-19.2 12.8 6.4 19.2 6.4 25.6 19.2l396.8 403.2 19.2-19.2c57.6-51.2 57.6-128 6.4-172.8zM550.4 224c-12.8-12.8-44.8-12.8-44.8-12.8s-32 0-38.4 12.8l-179.2 185.6c-12.8 12.8-12.8 38.4 0 57.6l51.2 51.2c12.8 12.8 44.8 12.8 57.6 0l115.2-121.6 352 352c12.8 12.8 44.8 12.8 57.6 0l51.2-51.2c12.8-12.8 12.8-44.8 0-57.6l-422.4-416z" />
|
||||
<glyph unicode="" d="M512 748.8l211.2 179.2 300.8-198.4-204.8-166.4-307.2 185.6zM1024 396.8l-300.8-198.4-211.2 172.8 300.8 185.6 211.2-160zM300.8 198.4l-300.8 198.4 204.8 166.4 307.2-192-211.2-172.8zM0 729.6l300.8 198.4 211.2-179.2-300.8-192-211.2 172.8zM512 332.8l211.2-179.2 89.6 57.6v-64l-300.8-179.2-300.8 179.2v64l89.6-51.2 211.2 172.8z" />
|
||||
<glyph unicode="" d="M864 249.6c-38.4 0-64 32-64 64v256c0 38.4 32 64 64 64 38.4 0 64-32 64-64v-256c0-32-25.6-64-64-64zM697.6 102.4h-38.4v-108.8c0-38.4-25.6-64-57.6-64s-57.6 25.6-57.6 64v108.8h-70.4v-108.8c0-38.4-25.6-64-57.6-64s-57.6 25.6-57.6 64v108.8h-32c-19.2 0-38.4 19.2-38.4 44.8v428.8h448v-422.4c0-32-12.8-51.2-38.4-51.2zM736 633.6h-448c0 89.6 32 153.6 76.8 192l-70.4 83.2c-6.4 12.8-6.4 25.6 0 38.4 12.8 12.8 25.6 12.8 38.4 0l83.2-96c32 12.8 64 19.2 96 19.2s70.4-6.4 96-19.2l83.2 96c12.8 12.8 25.6 12.8 38.4 0s12.8-32 0-38.4l-70.4-83.2c44.8-32 76.8-102.4 76.8-192zM441.6 761.6c-12.8 0-25.6-12.8-25.6-32s12.8-32 25.6-32 25.6 12.8 25.6 32-12.8 32-25.6 32zM582.4 761.6c-12.8 0-25.6-12.8-25.6-32s12.8-32 25.6-32 25.6 19.2 25.6 32-12.8 32-25.6 32zM160 249.6c-38.4 0-64 32-64 64v256c0 38.4 25.6 64 64 64s64-32 64-64v-256c0-32-25.6-64-64-64z" />
|
||||
<glyph unicode="" d="M921.6 211.2c-32-153.6-115.2-211.2-147.2-249.6-32-25.6-121.6-25.6-153.6-6.4-38.4 25.6-134.4 25.6-166.4 0-44.8-32-115.2-19.2-128-12.8-256 179.2-352 716.8 12.8 774.4 64 12.8 134.4-32 134.4-32 51.2-25.6 70.4-12.8 115.2 6.4 96 44.8 243.2 44.8 313.6-76.8-147.2-96-153.6-294.4 19.2-403.2zM716.8 960c12.8-70.4-64-224-204.8-230.4-12.8 38.4 32 217.6 204.8 230.4z" />
|
||||
</font></defs></svg>
|
||||
|
之后 宽度: | 高度: | 大小: 56 KiB |
二进制文件未显示。
二进制文件未显示。
13
themes/waifu_plugin/jquery-ui.min.js
vendored
普通文件
13
themes/waifu_plugin/jquery-ui.min.js
vendored
普通文件
文件差异因一行或多行过长而隐藏
4
themes/waifu_plugin/jquery.min.js
vendored
普通文件
4
themes/waifu_plugin/jquery.min.js
vendored
普通文件
文件差异因一行或多行过长而隐藏
4238
themes/waifu_plugin/live2d.js
普通文件
4238
themes/waifu_plugin/live2d.js
普通文件
文件差异内容过多而无法显示
加载差异
1
themes/waifu_plugin/source
普通文件
1
themes/waifu_plugin/source
普通文件
@@ -0,0 +1 @@
|
||||
https://github.com/fghrsh/live2d_demo
|
||||
373
themes/waifu_plugin/waifu-tips.js
普通文件
373
themes/waifu_plugin/waifu-tips.js
普通文件
@@ -0,0 +1,373 @@
|
||||
window.live2d_settings = Array(); /*
|
||||
|
||||
く__,.ヘヽ. / ,ー、 〉
|
||||
\ ', !-─‐-i / /´
|
||||
/`ー' L//`ヽ、 Live2D 看板娘 参数设置
|
||||
/ /, /| , , ', Version 1.4.2
|
||||
イ / /-‐/ i L_ ハ ヽ! i Update 2018.11.12
|
||||
レ ヘ 7イ`ト レ'ァ-ト、!ハ| |
|
||||
!,/7 '0' ´0iソ| |
|
||||
|.从" _ ,,,, / |./ | 网页添加 Live2D 看板娘
|
||||
レ'| i>.、,,__ _,.イ / .i | https://www.fghrsh.net/post/123.html
|
||||
レ'| | / k_7_/レ'ヽ, ハ. |
|
||||
| |/i 〈|/ i ,.ヘ | i | Thanks
|
||||
.|/ / i: ヘ! \ | journey-ad / https://github.com/journey-ad/live2d_src
|
||||
kヽ>、ハ _,.ヘ、 /、! xiazeyu / https://github.com/xiazeyu/live2d-widget.js
|
||||
!'〈//`T´', \ `'7'ーr' Live2d Cubism SDK WebGL 2.1 Projrct & All model authors.
|
||||
レ'ヽL__|___i,___,ンレ|ノ
|
||||
ト-,/ |___./
|
||||
'ー' !_,.:*********************************************************************************/
|
||||
|
||||
|
||||
// 后端接口
|
||||
live2d_settings['modelAPI'] = '//live2d.fghrsh.net/api/'; // 自建 API 修改这里
|
||||
live2d_settings['tipsMessage'] = 'waifu-tips.json'; // 同目录下可省略路径
|
||||
live2d_settings['hitokotoAPI'] = 'lwl12.com'; // 一言 API,可选 'lwl12.com', 'hitokoto.cn', 'jinrishici.com'(古诗词)
|
||||
|
||||
// 默认模型
|
||||
live2d_settings['modelId'] = 1; // 默认模型 ID,可在 F12 控制台找到
|
||||
live2d_settings['modelTexturesId'] = 53; // 默认材质 ID,可在 F12 控制台找到
|
||||
|
||||
// 工具栏设置
|
||||
live2d_settings['showToolMenu'] = true; // 显示 工具栏 ,可选 true(真), false(假)
|
||||
live2d_settings['canCloseLive2d'] = true; // 显示 关闭看板娘 按钮,可选 true(真), false(假)
|
||||
live2d_settings['canSwitchModel'] = true; // 显示 模型切换 按钮,可选 true(真), false(假)
|
||||
live2d_settings['canSwitchTextures'] = true; // 显示 材质切换 按钮,可选 true(真), false(假)
|
||||
live2d_settings['canSwitchHitokoto'] = true; // 显示 一言切换 按钮,可选 true(真), false(假)
|
||||
live2d_settings['canTakeScreenshot'] = true; // 显示 看板娘截图 按钮,可选 true(真), false(假)
|
||||
live2d_settings['canTurnToHomePage'] = true; // 显示 返回首页 按钮,可选 true(真), false(假)
|
||||
live2d_settings['canTurnToAboutPage'] = true; // 显示 跳转关于页 按钮,可选 true(真), false(假)
|
||||
|
||||
// 模型切换模式
|
||||
live2d_settings['modelStorage'] = true; // 记录 ID (刷新后恢复),可选 true(真), false(假)
|
||||
live2d_settings['modelRandMode'] = 'switch'; // 模型切换,可选 'rand'(随机), 'switch'(顺序)
|
||||
live2d_settings['modelTexturesRandMode']= 'rand'; // 材质切换,可选 'rand'(随机), 'switch'(顺序)
|
||||
|
||||
// 提示消息选项
|
||||
live2d_settings['showHitokoto'] = true; // 显示一言
|
||||
live2d_settings['showF12Status'] = true; // 显示加载状态
|
||||
live2d_settings['showF12Message'] = false; // 显示看板娘消息
|
||||
live2d_settings['showF12OpenMsg'] = true; // 显示控制台打开提示
|
||||
live2d_settings['showCopyMessage'] = true; // 显示 复制内容 提示
|
||||
live2d_settings['showWelcomeMessage'] = true; // 显示进入面页欢迎词
|
||||
|
||||
//看板娘样式设置
|
||||
live2d_settings['waifuSize'] = '280x250'; // 看板娘大小,例如 '280x250', '600x535'
|
||||
live2d_settings['waifuTipsSize'] = '250x70'; // 提示框大小,例如 '250x70', '570x150'
|
||||
live2d_settings['waifuFontSize'] = '12px'; // 提示框字体,例如 '12px', '30px'
|
||||
live2d_settings['waifuToolFont'] = '14px'; // 工具栏字体,例如 '14px', '36px'
|
||||
live2d_settings['waifuToolLine'] = '20px'; // 工具栏行高,例如 '20px', '36px'
|
||||
live2d_settings['waifuToolTop'] = '0px' // 工具栏顶部边距,例如 '0px', '-60px'
|
||||
live2d_settings['waifuMinWidth'] = '768px'; // 面页小于 指定宽度 隐藏看板娘,例如 'disable'(禁用), '768px'
|
||||
live2d_settings['waifuEdgeSide'] = 'left:0'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px)
|
||||
live2d_settings['waifuDraggable'] = 'disable'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽)
|
||||
live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假)
|
||||
|
||||
// 其他杂项设置
|
||||
live2d_settings['l2dVersion'] = '1.4.2'; // 当前版本
|
||||
live2d_settings['l2dVerDate'] = '2018.11.12'; // 版本更新日期
|
||||
live2d_settings['homePageUrl'] = 'auto'; // 主页地址,可选 'auto'(自动), '{URL 网址}'
|
||||
live2d_settings['aboutPageUrl'] = 'https://www.fghrsh.net/post/123.html'; // 关于页地址, '{URL 网址}'
|
||||
live2d_settings['screenshotCaptureName']= 'live2d.png'; // 看板娘截图文件名,例如 'live2d.png'
|
||||
|
||||
/****************************************************************************************************/
|
||||
|
||||
String.prototype.render = function(context) {
|
||||
var tokenReg = /(\\)?\{([^\{\}\\]+)(\\)?\}/g;
|
||||
|
||||
return this.replace(tokenReg, function (word, slash1, token, slash2) {
|
||||
if (slash1 || slash2) { return word.replace('\\', ''); }
|
||||
|
||||
var variables = token.replace(/\s/g, '').split('.');
|
||||
var currentObject = context;
|
||||
var i, length, variable;
|
||||
|
||||
for (i = 0, length = variables.length; i < length; ++i) {
|
||||
variable = variables[i];
|
||||
currentObject = currentObject[variable];
|
||||
if (currentObject === undefined || currentObject === null) return '';
|
||||
}
|
||||
return currentObject;
|
||||
});
|
||||
};
|
||||
|
||||
var re = /x/;
|
||||
// console.log(re);
|
||||
|
||||
function empty(obj) {return typeof obj=="undefined"||obj==null||obj==""?true:false}
|
||||
function getRandText(text) {return Array.isArray(text) ? text[Math.floor(Math.random() * text.length + 1)-1] : text}
|
||||
|
||||
function showMessage(text, timeout, flag) {
|
||||
if(flag || sessionStorage.getItem('waifu-text') === '' || sessionStorage.getItem('waifu-text') === null){
|
||||
if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1];
|
||||
if (live2d_settings.showF12Message) console.log('[Message]', text.replace(/<[^<>]+>/g,''));
|
||||
|
||||
if(flag) sessionStorage.setItem('waifu-text', text);
|
||||
|
||||
$('.waifu-tips').stop();
|
||||
$('.waifu-tips').html(text).fadeTo(200, 1);
|
||||
if (timeout === undefined) timeout = 5000;
|
||||
hideMessage(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
function hideMessage(timeout) {
|
||||
$('.waifu-tips').stop().css('opacity',1);
|
||||
if (timeout === undefined) timeout = 5000;
|
||||
window.setTimeout(function() {sessionStorage.removeItem('waifu-text')}, timeout);
|
||||
$('.waifu-tips').delay(timeout).fadeTo(200, 0);
|
||||
}
|
||||
|
||||
function initModel(waifuPath, type) {
|
||||
/* console welcome message */
|
||||
// eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8.d(" ");8.d("\\U,.\\y\\5.\\1\\1\\1\\1/\\1,\\u\\2 \\H\\n\\1\\1\\1\\1\\1\\b \', !-\\r\\j-i\\1/\\1/\\g\\n\\1\\1\\1 \\1 \\a\\4\\f\'\\1\\1\\1 L/\\a\\4\\5\\2\\n\\1\\1 \\1 /\\1 \\a,\\1 /|\\1 ,\\1 ,\\1\\1\\1 \',\\n\\1\\1\\1\\q \\1/ /-\\j/\\1\\h\\E \\9 \\5!\\1 i\\n\\1\\1\\1 \\3 \\6 7\\q\\4\\c\\1 \\3\'\\s-\\c\\2!\\t|\\1 |\\n\\1\\1\\1\\1 !,/7 \'0\'\\1\\1 \\X\\w| \\1 |\\1\\1\\1\\n\\1\\1\\1\\1 |.\\x\\"\\1\\l\\1\\1 ,,,, / |./ \\1 |\\n\\1\\1\\1\\1 \\3\'| i\\z.\\2,,A\\l,.\\B / \\1.i \\1|\\n\\1\\1\\1\\1\\1 \\3\'| | / C\\D/\\3\'\\5,\\1\\9.\\1|\\n\\1\\1\\1\\1\\1\\1 | |/i \\m|/\\1 i\\1,.\\6 |\\F\\1|\\n\\1\\1\\1\\1\\1\\1.|/ /\\1\\h\\G \\1 \\6!\\1\\1\\b\\1|\\n\\1\\1\\1 \\1 \\1 k\\5>\\2\\9 \\1 o,.\\6\\2 \\1 /\\2!\\n\\1\\1\\1\\1\\1\\1 !\'\\m//\\4\\I\\g\', \\b \\4\'7\'\\J\'\\n\\1\\1\\1\\1\\1\\1 \\3\'\\K|M,p,\\O\\3|\\P\\n\\1\\1\\1\\1\\1 \\1\\1\\1\\c-,/\\1|p./\\n\\1\\1\\1\\1\\1 \\1\\1\\1\'\\f\'\\1\\1!o,.:\\Q \\R\\S\\T v"+e.V+" / W "+e.N);8.d(" ");',60,60,'|u3000|uff64|uff9a|uff40|u30fd|uff8d||console|uff8a|uff0f|uff3c|uff84|log|live2d_settings|uff70|u00b4|uff49||u2010||u3000_|u3008||_|___|uff72|u2500|uff67|u30cf|u30fc||u30bd|u4ece|u30d8|uff1e|__|u30a4|k_|uff17_|u3000L_|u3000i|uff1a|u3009|uff34|uff70r|u30fdL__||___i|l2dVerDate|u30f3|u30ce|nLive2D|u770b|u677f|u5a18|u304f__|l2dVersion|FGHRSH|u00b40i'.split('|'),0,{}));
|
||||
|
||||
/* 判断 JQuery */
|
||||
if (typeof($.ajax) != 'function') typeof(jQuery.ajax) == 'function' ? window.$ = jQuery : console.log('[Error] JQuery is not defined.');
|
||||
|
||||
/* 加载看板娘样式 */
|
||||
live2d_settings.waifuSize = live2d_settings.waifuSize.split('x');
|
||||
live2d_settings.waifuTipsSize = live2d_settings.waifuTipsSize.split('x');
|
||||
live2d_settings.waifuEdgeSide = live2d_settings.waifuEdgeSide.split(':');
|
||||
|
||||
$("#live2d").attr("width",live2d_settings.waifuSize[0]);
|
||||
$("#live2d").attr("height",live2d_settings.waifuSize[1]);
|
||||
$(".waifu-tips").width(live2d_settings.waifuTipsSize[0]);
|
||||
$(".waifu-tips").height(live2d_settings.waifuTipsSize[1]);
|
||||
$(".waifu-tips").css("top",live2d_settings.waifuToolTop);
|
||||
$(".waifu-tips").css("font-size",live2d_settings.waifuFontSize);
|
||||
$(".waifu-tool").css("font-size",live2d_settings.waifuToolFont);
|
||||
$(".waifu-tool span").css("line-height",live2d_settings.waifuToolLine);
|
||||
|
||||
if (live2d_settings.waifuEdgeSide[0] == 'left') $(".waifu").css("left",live2d_settings.waifuEdgeSide[1]+'px');
|
||||
else if (live2d_settings.waifuEdgeSide[0] == 'right') $(".waifu").css("right",live2d_settings.waifuEdgeSide[1]+'px');
|
||||
|
||||
window.waifuResize = function() { $(window).width() <= Number(live2d_settings.waifuMinWidth.replace('px','')) ? $(".waifu").hide() : $(".waifu").show(); };
|
||||
if (live2d_settings.waifuMinWidth != 'disable') { waifuResize(); $(window).resize(function() {waifuResize()}); }
|
||||
|
||||
try {
|
||||
if (live2d_settings.waifuDraggable == 'axis-x') $(".waifu").draggable({ axis: "x", revert: live2d_settings.waifuDraggableRevert });
|
||||
else if (live2d_settings.waifuDraggable == 'unlimited') $(".waifu").draggable({ revert: live2d_settings.waifuDraggableRevert });
|
||||
else $(".waifu").css("transition", 'all .3s ease-in-out');
|
||||
} catch(err) { console.log('[Error] JQuery UI is not defined.') }
|
||||
|
||||
live2d_settings.homePageUrl = live2d_settings.homePageUrl == 'auto' ? window.location.protocol+'//'+window.location.hostname+'/' : live2d_settings.homePageUrl;
|
||||
if (window.location.protocol == 'file:' && live2d_settings.modelAPI.substr(0,2) == '//') live2d_settings.modelAPI = 'http:'+live2d_settings.modelAPI;
|
||||
|
||||
$('.waifu-tool .fui-home').click(function (){
|
||||
//window.location = 'https://www.fghrsh.net/';
|
||||
window.location = live2d_settings.homePageUrl;
|
||||
});
|
||||
|
||||
$('.waifu-tool .fui-info-circle').click(function (){
|
||||
//window.open('https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02');
|
||||
window.open(live2d_settings.aboutPageUrl);
|
||||
});
|
||||
|
||||
if (typeof(waifuPath) == "object") loadTipsMessage(waifuPath); else {
|
||||
$.ajax({
|
||||
cache: true,
|
||||
url: waifuPath == '' ? live2d_settings.tipsMessage : (waifuPath.substr(waifuPath.length-15)=='waifu-tips.json'?waifuPath:waifuPath+'waifu-tips.json'),
|
||||
dataType: "json",
|
||||
success: function (result){ loadTipsMessage(result); }
|
||||
});
|
||||
}
|
||||
|
||||
if (!live2d_settings.showToolMenu) $('.waifu-tool').hide();
|
||||
if (!live2d_settings.canCloseLive2d) $('.waifu-tool .fui-cross').hide();
|
||||
if (!live2d_settings.canSwitchModel) $('.waifu-tool .fui-eye').hide();
|
||||
if (!live2d_settings.canSwitchTextures) $('.waifu-tool .fui-user').hide();
|
||||
if (!live2d_settings.canSwitchHitokoto) $('.waifu-tool .fui-chat').hide();
|
||||
if (!live2d_settings.canTakeScreenshot) $('.waifu-tool .fui-photo').hide();
|
||||
if (!live2d_settings.canTurnToHomePage) $('.waifu-tool .fui-home').hide();
|
||||
if (!live2d_settings.canTurnToAboutPage) $('.waifu-tool .fui-info-circle').hide();
|
||||
|
||||
if (waifuPath === undefined) waifuPath = '';
|
||||
var modelId = localStorage.getItem('modelId');
|
||||
var modelTexturesId = localStorage.getItem('modelTexturesId');
|
||||
|
||||
if (!live2d_settings.modelStorage || modelId == null) {
|
||||
var modelId = live2d_settings.modelId;
|
||||
var modelTexturesId = live2d_settings.modelTexturesId;
|
||||
} loadModel(modelId, modelTexturesId);
|
||||
}
|
||||
|
||||
function loadModel(modelId, modelTexturesId=0) {
|
||||
if (live2d_settings.modelStorage) {
|
||||
localStorage.setItem('modelId', modelId);
|
||||
localStorage.setItem('modelTexturesId', modelTexturesId);
|
||||
} else {
|
||||
sessionStorage.setItem('modelId', modelId);
|
||||
sessionStorage.setItem('modelTexturesId', modelTexturesId);
|
||||
} loadlive2d('live2d', live2d_settings.modelAPI+'get/?id='+modelId+'-'+modelTexturesId, (live2d_settings.showF12Status ? console.log('[Status]','live2d','模型',modelId+'-'+modelTexturesId,'加载完成'):null));
|
||||
}
|
||||
|
||||
function loadTipsMessage(result) {
|
||||
window.waifu_tips = result;
|
||||
|
||||
$.each(result.mouseover, function (index, tips){
|
||||
$(document).on("mouseover", tips.selector, function (){
|
||||
var text = getRandText(tips.text);
|
||||
text = text.render({text: $(this).text()});
|
||||
showMessage(text, 3000);
|
||||
});
|
||||
});
|
||||
$.each(result.click, function (index, tips){
|
||||
$(document).on("click", tips.selector, function (){
|
||||
var text = getRandText(tips.text);
|
||||
text = text.render({text: $(this).text()});
|
||||
showMessage(text, 3000, true);
|
||||
});
|
||||
});
|
||||
$.each(result.seasons, function (index, tips){
|
||||
var now = new Date();
|
||||
var after = tips.date.split('-')[0];
|
||||
var before = tips.date.split('-')[1] || after;
|
||||
|
||||
if((after.split('/')[0] <= now.getMonth()+1 && now.getMonth()+1 <= before.split('/')[0]) &&
|
||||
(after.split('/')[1] <= now.getDate() && now.getDate() <= before.split('/')[1])){
|
||||
var text = getRandText(tips.text);
|
||||
text = text.render({year: now.getFullYear()});
|
||||
showMessage(text, 6000, true);
|
||||
}
|
||||
});
|
||||
|
||||
if (live2d_settings.showF12OpenMsg) {
|
||||
re.toString = function() {
|
||||
showMessage(getRandText(result.waifu.console_open_msg), 5000, true);
|
||||
return '';
|
||||
};
|
||||
}
|
||||
|
||||
if (live2d_settings.showCopyMessage) {
|
||||
$(document).on('copy', function() {
|
||||
showMessage(getRandText(result.waifu.copy_message), 5000, true);
|
||||
});
|
||||
}
|
||||
|
||||
$('.waifu-tool .fui-photo').click(function(){
|
||||
showMessage(getRandText(result.waifu.screenshot_message), 5000, true);
|
||||
window.Live2D.captureName = live2d_settings.screenshotCaptureName;
|
||||
window.Live2D.captureFrame = true;
|
||||
});
|
||||
|
||||
$('.waifu-tool .fui-cross').click(function(){
|
||||
sessionStorage.setItem('waifu-dsiplay', 'none');
|
||||
showMessage(getRandText(result.waifu.hidden_message), 1300, true);
|
||||
window.setTimeout(function() {$('.waifu').hide();}, 1300);
|
||||
});
|
||||
|
||||
window.showWelcomeMessage = function(result) {
|
||||
showMessage('欢迎使用GPT-Academic', 6000);
|
||||
}; if (live2d_settings.showWelcomeMessage) showWelcomeMessage(result);
|
||||
|
||||
var waifu_tips = result.waifu;
|
||||
|
||||
function loadOtherModel() {
|
||||
var modelId = modelStorageGetItem('modelId');
|
||||
var modelRandMode = live2d_settings.modelRandMode;
|
||||
|
||||
$.ajax({
|
||||
cache: modelRandMode == 'switch' ? true : false,
|
||||
url: live2d_settings.modelAPI+modelRandMode+'/?id='+modelId,
|
||||
dataType: "json",
|
||||
success: function(result) {
|
||||
loadModel(result.model['id']);
|
||||
var message = result.model['message'];
|
||||
$.each(waifu_tips.model_message, function(i,val) {if (i==result.model['id']) message = getRandText(val)});
|
||||
showMessage(message, 3000, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadRandTextures() {
|
||||
var modelId = modelStorageGetItem('modelId');
|
||||
var modelTexturesId = modelStorageGetItem('modelTexturesId');
|
||||
var modelTexturesRandMode = live2d_settings.modelTexturesRandMode;
|
||||
|
||||
$.ajax({
|
||||
cache: modelTexturesRandMode == 'switch' ? true : false,
|
||||
url: live2d_settings.modelAPI+modelTexturesRandMode+'_textures/?id='+modelId+'-'+modelTexturesId,
|
||||
dataType: "json",
|
||||
success: function(result) {
|
||||
if (result.textures['id'] == 1 && (modelTexturesId == 1 || modelTexturesId == 0))
|
||||
showMessage(waifu_tips.load_rand_textures[0], 3000, true);
|
||||
else showMessage(waifu_tips.load_rand_textures[1], 3000, true);
|
||||
loadModel(modelId, result.textures['id']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function modelStorageGetItem(key) { return live2d_settings.modelStorage ? localStorage.getItem(key) : sessionStorage.getItem(key); }
|
||||
|
||||
/* 检测用户活动状态,并在空闲时显示一言 */
|
||||
if (live2d_settings.showHitokoto) {
|
||||
window.getActed = false; window.hitokotoTimer = 0; window.hitokotoInterval = false;
|
||||
$(document).mousemove(function(e){getActed = true;}).keydown(function(){getActed = true;});
|
||||
setInterval(function(){ if (!getActed) ifActed(); else elseActed(); }, 1000);
|
||||
}
|
||||
|
||||
function ifActed() {
|
||||
if (!hitokotoInterval) {
|
||||
hitokotoInterval = true;
|
||||
hitokotoTimer = window.setInterval(showHitokotoActed, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
function elseActed() {
|
||||
getActed = hitokotoInterval = false;
|
||||
window.clearInterval(hitokotoTimer);
|
||||
}
|
||||
|
||||
function showHitokotoActed() {
|
||||
if ($(document)[0].visibilityState == 'visible') showHitokoto();
|
||||
}
|
||||
|
||||
function showHitokoto() {
|
||||
switch(live2d_settings.hitokotoAPI) {
|
||||
case 'lwl12.com':
|
||||
$.getJSON('https://api.lwl12.com/hitokoto/v1?encode=realjson',function(result){
|
||||
if (!empty(result.source)) {
|
||||
var text = waifu_tips.hitokoto_api_message['lwl12.com'][0];
|
||||
if (!empty(result.author)) text += waifu_tips.hitokoto_api_message['lwl12.com'][1];
|
||||
text = text.render({source: result.source, creator: result.author});
|
||||
window.setTimeout(function() {showMessage(text+waifu_tips.hitokoto_api_message['lwl12.com'][2], 3000, true);}, 5000);
|
||||
} showMessage(result.text, 5000, true);
|
||||
});break;
|
||||
case 'fghrsh.net':
|
||||
$.getJSON('https://api.fghrsh.net/hitokoto/rand/?encode=jsc&uid=3335',function(result){
|
||||
if (!empty(result.source)) {
|
||||
var text = waifu_tips.hitokoto_api_message['fghrsh.net'][0];
|
||||
text = text.render({source: result.source, date: result.date});
|
||||
window.setTimeout(function() {showMessage(text, 3000, true);}, 5000);
|
||||
showMessage(result.hitokoto, 5000, true);
|
||||
}
|
||||
});break;
|
||||
case 'jinrishici.com':
|
||||
$.ajax({
|
||||
url: 'https://v2.jinrishici.com/one.json',
|
||||
xhrFields: {withCredentials: true},
|
||||
success: function (result, status) {
|
||||
if (!empty(result.data.origin.title)) {
|
||||
var text = waifu_tips.hitokoto_api_message['jinrishici.com'][0];
|
||||
text = text.render({title: result.data.origin.title, dynasty: result.data.origin.dynasty, author:result.data.origin.author});
|
||||
window.setTimeout(function() {showMessage(text, 3000, true);}, 5000);
|
||||
} showMessage(result.data.content, 5000, true);
|
||||
}
|
||||
});break;
|
||||
default:
|
||||
$.getJSON('https://v1.hitokoto.cn',function(result){
|
||||
if (!empty(result.from)) {
|
||||
var text = waifu_tips.hitokoto_api_message['hitokoto.cn'][0];
|
||||
text = text.render({source: result.from, creator: result.creator});
|
||||
window.setTimeout(function() {showMessage(text, 3000, true);}, 5000);
|
||||
}
|
||||
showMessage(result.hitokoto, 5000, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$('.waifu-tool .fui-eye').click(function (){loadOtherModel()});
|
||||
$('.waifu-tool .fui-user').click(function (){loadRandTextures()});
|
||||
$('.waifu-tool .fui-chat').click(function (){showHitokoto()});
|
||||
}
|
||||
128
themes/waifu_plugin/waifu-tips.json
普通文件
128
themes/waifu_plugin/waifu-tips.json
普通文件
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"waifu": {
|
||||
"console_open_msg": ["哈哈,你打开了控制台,是想要看看我的秘密吗?"],
|
||||
"copy_message": ["你都复制了些什么呀,转载要记得加上出处哦"],
|
||||
"screenshot_message": ["照好了嘛,是不是很可爱呢?"],
|
||||
"hidden_message": ["我们还能再见面的吧…"],
|
||||
"load_rand_textures": ["我还没有其他衣服呢", "我的新衣服好看嘛"],
|
||||
"hour_tips": {
|
||||
"t0-5": ["快睡觉去吧,年纪轻轻小心猝死哦"],
|
||||
"t5-7": ["早上好!一日之计在于晨,美好的一天就要开始了"],
|
||||
"t7-11": ["上午好!工作顺利嘛,不要久坐,多起来走动走动哦!"],
|
||||
"t11-14": ["中午了,工作了一个上午,现在是午餐时间!"],
|
||||
"t14-17": ["午后很容易犯困呢,今天的运动目标完成了吗?"],
|
||||
"t17-19": ["傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~"],
|
||||
"t19-21": ["晚上好,今天过得怎么样?"],
|
||||
"t21-23": ["已经这么晚了呀,早点休息吧,晚安~"],
|
||||
"t23-24": ["你是夜猫子呀?这么晚还不睡觉,明天起的来嘛"],
|
||||
"default": ["嗨~ 快来逗我玩吧!"]
|
||||
},
|
||||
"referrer_message": {
|
||||
"localhost": ["欢迎使用<span style=\"color:rgba(245, 20, 20, 0.62);\">『ChatGPT", "』</span>", " - "],
|
||||
"baidu": ["Hello! 来自 百度搜索 的朋友<br>你是搜索 <span style=\"color:rgba(245, 20, 20, 0.62);\">", "</span> 找到的我吗?"],
|
||||
"so": ["Hello! 来自 360搜索 的朋友<br>你是搜索 <span style=\"color:rgba(245, 20, 20, 0.62);\">", "</span> 找到的我吗?"],
|
||||
"google": ["Hello! 来自 谷歌搜索 的朋友<br>欢迎使用<span style=\"color:rgba(245, 20, 20, 0.62);\">『ChatGPT", "』</span>", " - "],
|
||||
"default": ["Hello! 来自 <span style=\"color:rgba(245, 20, 20, 0.62);\">", "</span> 的朋友"],
|
||||
"none": ["欢迎使用<span style=\"color:rgba(245, 20, 20, 0.62);\">『ChatGPT", "』</span>", " - "]
|
||||
},
|
||||
"referrer_hostname": {
|
||||
"example.com": ["示例网站"],
|
||||
"www.fghrsh.net": ["FGHRSH 的博客"]
|
||||
},
|
||||
"model_message": {
|
||||
"1": ["来自 Potion Maker 的 Pio 酱 ~"],
|
||||
"2": ["来自 Potion Maker 的 Tia 酱 ~"]
|
||||
},
|
||||
"hitokoto_api_message": {
|
||||
"lwl12.com": ["这句一言来自 <span style=\"color:#0099cc;\">『{source}』</span>", ",是 <span style=\"color:#0099cc;\">{creator}</span> 投稿的", "。"],
|
||||
"fghrsh.net": ["这句一言出处是 <span style=\"color:#0099cc;\">『{source}』</span>,是 <span style=\"color:#0099cc;\">FGHRSH</span> 在 {date} 收藏的!"],
|
||||
"jinrishici.com": ["这句诗词出自 <span style=\"color:#0099cc;\">《{title}》</span>,是 {dynasty}诗人 {author} 创作的!"],
|
||||
"hitokoto.cn": ["这句一言来自 <span style=\"color:#0099cc;\">『{source}』</span>,是 <span style=\"color:#0099cc;\">{creator}</span> 在 hitokoto.cn 投稿的。"]
|
||||
}
|
||||
},
|
||||
"mouseover": [
|
||||
{ "selector": ".container a[href^='http']", "text": ["要看看 <span style=\"color:#0099cc;\">{text}</span> 么?"] },
|
||||
{ "selector": ".fui-home", "text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦"] },
|
||||
{ "selector": ".fui-chat", "text": ["一言一语,一颦一笑。一字一句,一颗赛艇。"] },
|
||||
{ "selector": ".fui-eye", "text": ["嗯··· 要切换 Live2D形象 吗?"] },
|
||||
{ "selector": ".fui-user", "text": ["喜欢换装吗?"] },
|
||||
{ "selector": ".fui-photo", "text": ["要拍张纪念照片吗?"] },
|
||||
{ "selector": ".fui-info-circle", "text": ["这里有关于我的信息呢"] },
|
||||
{ "selector": ".fui-cross", "text": ["你不喜欢我了吗..."] },
|
||||
{ "selector": "#tor_show", "text": ["翻页比较麻烦吗,点击可以显示这篇文章的目录呢"] },
|
||||
{ "selector": "#comment_go", "text": ["想要去评论些什么吗?"] },
|
||||
{ "selector": "#night_mode", "text": ["深夜时要爱护眼睛呀"] },
|
||||
{ "selector": "#qrcode", "text": ["手机扫一下就能继续看,很方便呢"] },
|
||||
{ "selector": ".comment_reply", "text": ["要吐槽些什么呢"] },
|
||||
{ "selector": "#back-to-top", "text": ["回到开始的地方吧"] },
|
||||
{ "selector": "#author", "text": ["该怎么称呼你呢"] },
|
||||
{ "selector": "#mail", "text": ["留下你的邮箱,不然就是无头像人士了"] },
|
||||
{ "selector": "#url", "text": ["你的家在哪里呢,好让我去参观参观"] },
|
||||
{ "selector": "#textarea", "text": ["认真填写哦,垃圾评论是禁止事项"] },
|
||||
{ "selector": ".OwO-logo", "text": ["要插入一个表情吗"] },
|
||||
{ "selector": "#csubmit", "text": ["要[提交]^(Commit)了吗,首次评论需要审核,请耐心等待~"] },
|
||||
{ "selector": ".ImageBox", "text": ["点击图片可以放大呢"] },
|
||||
{ "selector": "input[name=s]", "text": ["找不到想看的内容?搜索看看吧"] },
|
||||
{ "selector": ".previous", "text": ["去上一页看看吧"] },
|
||||
{ "selector": ".next", "text": ["去下一页看看吧"] },
|
||||
{ "selector": ".dropdown-toggle", "text": ["这里是菜单"] },
|
||||
{ "selector": "c-player a.play-icon", "text": ["想要听点音乐吗"] },
|
||||
{ "selector": "c-player div.time", "text": ["在这里可以调整<span style=\"color:#0099cc;\">播放进度</span>呢"] },
|
||||
{ "selector": "c-player div.volume", "text": ["在这里可以调整<span style=\"color:#0099cc;\">音量</span>呢"] },
|
||||
{ "selector": "c-player div.list-button", "text": ["<span style=\"color:#0099cc;\">播放列表</span>里都有什么呢"] },
|
||||
{ "selector": "c-player div.lyric-button", "text": ["有<span style=\"color:#0099cc;\">歌词</span>的话就能跟着一起唱呢"] },
|
||||
{ "selector": ".waifu #live2d", "text": [
|
||||
"别玩了,快去学习!",
|
||||
"偶尔放松下眼睛吧。",
|
||||
"看什么看(*^▽^*)",
|
||||
"焦虑时,吃顿大餐心情就好啦^_^",
|
||||
"你这个年纪,怎么睡得着觉的你^_^",
|
||||
"打开“界面外观”菜单,可选择关闭Live2D形象",
|
||||
"经常去Github看看我们的更新吧,也许有好玩的新功能呢。",
|
||||
"试试本地大模型吧,有的也很强大的哦。",
|
||||
"很多强大的函数插件隐藏在下拉菜单中呢。",
|
||||
"插件使用之前,需要把文件上传进去哦。",
|
||||
"上传文件时,可以把文件直接拖进对话中的哦。",
|
||||
"上传文件时,可以文件或图片粘贴到输入区哦。",
|
||||
"想添加基础功能按钮吗?打开“界面外观”菜单进行自定义吧!",
|
||||
"敏感或机密的信息,不可以问AI的哦!",
|
||||
"LLM究竟是划时代的创新,还是扼杀创造力的毒药呢?",
|
||||
"休息一下,起来走动走动吧!",
|
||||
"今天的阳光也很不错哦,不妨外出晒晒。",
|
||||
"笑一笑,生活更美好!",
|
||||
"遇到难题,深呼吸就能解决一半。",
|
||||
"偶尔换换环境,灵感也许就来了。",
|
||||
"小憩片刻,醒来便是满血复活。",
|
||||
"技术改变生活,让我们共同进步。",
|
||||
"保持好奇心,探索未知的世界。",
|
||||
"遇到困难,记得还有朋友和AI陪在你身边。",
|
||||
"劳逸结合,方能长久。",
|
||||
"偶尔给自己放个假,放松心情。",
|
||||
"不要害怕失败,勇敢尝试才能成功。"
|
||||
] }
|
||||
],
|
||||
"click": [
|
||||
{
|
||||
"selector": ".waifu #live2d",
|
||||
"text": [
|
||||
"是…是不小心碰到了吧",
|
||||
"再摸的话我可要报警了!⌇●﹏●⌇",
|
||||
"110吗,这里有个变态一直在摸我(ó﹏ò。)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"seasons": [
|
||||
{ "date": "01/01", "text": ["<span style=\"color:#0099cc;\">元旦</span>了呢,新的一年又开始了,今年是{year}年~"] },
|
||||
{ "date": "02/14", "text": ["又是一年<span style=\"color:#0099cc;\">情人节</span>,{year}年找到对象了嘛~"] },
|
||||
{ "date": "03/08", "text": ["今天是<span style=\"color:#0099cc;\">妇女节</span>!"] },
|
||||
{ "date": "03/12", "text": ["今天是<span style=\"color:#0099cc;\">植树节</span>,要保护环境呀"] },
|
||||
{ "date": "04/01", "text": ["悄悄告诉你一个秘密~<span style=\"background-color:#34495e;\">今天是愚人节,不要被骗了哦~</span>"] },
|
||||
{ "date": "05/01", "text": ["今天是<span style=\"color:#0099cc;\">五一劳动节</span>,计划好假期去哪里了吗~"] },
|
||||
{ "date": "06/01", "text": ["<span style=\"color:#0099cc;\">儿童节</span>了呢,快活的时光总是短暂,要是永远长不大该多好啊…"] },
|
||||
{ "date": "09/03", "text": ["<span style=\"color:#0099cc;\">中国人民抗日战争胜利纪念日</span>,铭记历史、缅怀先烈、珍爱和平、开创未来。"] },
|
||||
{ "date": "09/10", "text": ["<span style=\"color:#0099cc;\">教师节</span>,在学校要给老师问声好呀~"] },
|
||||
{ "date": "10/01", "text": ["<span style=\"color:#0099cc;\">国庆节</span>,新中国已经成立69年了呢"] },
|
||||
{ "date": "11/05-11/12", "text": ["今年的<span style=\"color:#0099cc;\">双十一</span>是和谁一起过的呢~"] },
|
||||
{ "date": "12/20-12/31", "text": ["这几天是<span style=\"color:#0099cc;\">圣诞节</span>,主人肯定又去剁手买买买了~"] }
|
||||
]
|
||||
}
|
||||
290
themes/waifu_plugin/waifu.css
普通文件
290
themes/waifu_plugin/waifu.css
普通文件
@@ -0,0 +1,290 @@
|
||||
.waifu {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
font-size: 0;
|
||||
-webkit-transform: translateY(3px);
|
||||
transform: translateY(3px);
|
||||
}
|
||||
.waifu:hover {
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
.waifu-tips {
|
||||
opacity: 0;
|
||||
margin: -20px 20px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid rgba(224, 186, 140, 0.62);
|
||||
border-radius: 12px;
|
||||
background-color: rgba(236, 217, 188, 0.5);
|
||||
box-shadow: 0 3px 15px 2px rgba(191, 158, 118, 0.2);
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
animation-delay: 5s;
|
||||
animation-duration: 50s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-name: shake;
|
||||
animation-timing-function: ease-in-out;
|
||||
}
|
||||
.waifu-tool {
|
||||
display: none;
|
||||
color: #aaa;
|
||||
top: 50px;
|
||||
right: 10px;
|
||||
position: absolute;
|
||||
}
|
||||
.waifu:hover .waifu-tool {
|
||||
display: block;
|
||||
}
|
||||
.waifu-tool span {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
color: #5b6c7d;
|
||||
transition: 0.2s;
|
||||
}
|
||||
.waifu-tool span:hover {
|
||||
color: #34495e;
|
||||
}
|
||||
.waifu #live2d{
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@keyframes shake {
|
||||
2% {
|
||||
transform: translate(0.5px, -1.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
4% {
|
||||
transform: translate(0.5px, 1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
6% {
|
||||
transform: translate(1.5px, 1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
8% {
|
||||
transform: translate(2.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
10% {
|
||||
transform: translate(0.5px, 2.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
12% {
|
||||
transform: translate(1.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
14% {
|
||||
transform: translate(0.5px, 0.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
16% {
|
||||
transform: translate(-1.5px, -0.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
18% {
|
||||
transform: translate(0.5px, 0.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
20% {
|
||||
transform: translate(2.5px, 2.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
22% {
|
||||
transform: translate(0.5px, -1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
24% {
|
||||
transform: translate(-1.5px, 1.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
26% {
|
||||
transform: translate(1.5px, 0.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
28% {
|
||||
transform: translate(-0.5px, -0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
30% {
|
||||
transform: translate(1.5px, -0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
32% {
|
||||
transform: translate(2.5px, -1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
34% {
|
||||
transform: translate(2.5px, 2.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
36% {
|
||||
transform: translate(0.5px, -1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
38% {
|
||||
transform: translate(2.5px, -0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
40% {
|
||||
transform: translate(-0.5px, 2.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
42% {
|
||||
transform: translate(-1.5px, 2.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
44% {
|
||||
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
46% {
|
||||
transform: translate(1.5px, -0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
48% {
|
||||
transform: translate(2.5px, -0.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
52% {
|
||||
transform: translate(-0.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
54% {
|
||||
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
56% {
|
||||
transform: translate(0.5px, 2.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
58% {
|
||||
transform: translate(2.5px, 2.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
60% {
|
||||
transform: translate(2.5px, -1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
62% {
|
||||
transform: translate(-1.5px, 0.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
64% {
|
||||
transform: translate(-1.5px, 1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
66% {
|
||||
transform: translate(0.5px, 2.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
68% {
|
||||
transform: translate(2.5px, -1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
70% {
|
||||
transform: translate(2.5px, 2.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
72% {
|
||||
transform: translate(-0.5px, -1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
74% {
|
||||
transform: translate(-1.5px, 2.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
76% {
|
||||
transform: translate(-1.5px, 2.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
78% {
|
||||
transform: translate(-1.5px, 2.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
80% {
|
||||
transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
82% {
|
||||
transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
84% {
|
||||
transform: translate(-0.5px, 0.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
86% {
|
||||
transform: translate(2.5px, 1.5px) rotate(0.5deg);
|
||||
}
|
||||
|
||||
88% {
|
||||
transform: translate(-1.5px, 0.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
90% {
|
||||
transform: translate(-1.5px, -0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
92% {
|
||||
transform: translate(-1.5px, -1.5px) rotate(1.5deg);
|
||||
}
|
||||
|
||||
94% {
|
||||
transform: translate(0.5px, 0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
96% {
|
||||
transform: translate(2.5px, -0.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
98% {
|
||||
transform: translate(-1.5px, -1.5px) rotate(-0.5deg);
|
||||
}
|
||||
|
||||
0%, 100% {
|
||||
transform: translate(0, 0) rotate(0);
|
||||
}
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Flat-UI-Icons';
|
||||
src: url('flat-ui-icons-regular.eot');
|
||||
src: url('flat-ui-icons-regular.eot?#iefix') format('embedded-opentype'), url('flat-ui-icons-regular.woff') format('woff'), url('flat-ui-icons-regular.ttf') format('truetype'), url('flat-ui-icons-regular.svg#flat-ui-icons-regular') format('svg');
|
||||
}
|
||||
[class^="fui-"],
|
||||
[class*="fui-"] {
|
||||
font-family: 'Flat-UI-Icons';
|
||||
speak: none;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
.fui-cross:before {
|
||||
content: "\e609";
|
||||
}
|
||||
.fui-info-circle:before {
|
||||
content: "\e60f";
|
||||
}
|
||||
.fui-photo:before {
|
||||
content: "\e62a";
|
||||
}
|
||||
.fui-eye:before {
|
||||
content: "\e62c";
|
||||
}
|
||||
.fui-chat:before {
|
||||
content: "\e62d";
|
||||
}
|
||||
.fui-home:before {
|
||||
content: "\e62e";
|
||||
}
|
||||
.fui-user:before {
|
||||
content: "\e631";
|
||||
}
|
||||
114
toolbox.py
114
toolbox.py
@@ -21,6 +21,14 @@ from shared_utils.connect_void_terminal import get_chat_handle
|
||||
from shared_utils.connect_void_terminal import get_plugin_handle
|
||||
from shared_utils.connect_void_terminal import get_plugin_default_kwargs
|
||||
from shared_utils.connect_void_terminal import get_chat_default_kwargs
|
||||
from shared_utils.text_mask import apply_gpt_academic_string_mask
|
||||
from shared_utils.text_mask import build_gpt_academic_masked_string
|
||||
from shared_utils.text_mask import apply_gpt_academic_string_mask_langbased
|
||||
from shared_utils.text_mask import build_gpt_academic_masked_string_langbased
|
||||
from shared_utils.handle_upload import html_local_file
|
||||
from shared_utils.handle_upload import html_local_img
|
||||
from shared_utils.handle_upload import file_manifest_filter_type
|
||||
from shared_utils.handle_upload import extract_archive
|
||||
|
||||
pj = os.path.join
|
||||
default_user_name = "default_user"
|
||||
@@ -69,7 +77,9 @@ class ChatBotWithCookies(list):
|
||||
|
||||
def ArgsGeneralWrapper(f):
|
||||
"""
|
||||
装饰器函数,用于重组输入参数,改变输入参数的顺序与结构。
|
||||
装饰器函数ArgsGeneralWrapper,用于重组输入参数,改变输入参数的顺序与结构。
|
||||
该装饰器是大多数功能调用的入口。
|
||||
函数示意图:https://mermaid.live/edit#pako:eNqNVFtPGkEY_StkntoEDQtLoTw0sWqapjQxVWPabmOm7AiEZZcsQ9QiiW012qixqdeqqIn10geBh6ZR8PJnmAWe-hc6l3VhrWnLEzNzzvnO953ZyYOYoSIQAWOaMR5LQBN7hvoU3UN_g5iu7imAXEyT4wUF3Pd0dT3y9KGYYUJsmK8V0GPGs0-QjkyojZgwk0Fm82C2dVghX08U8EaoOHjOfoEMU0XmADRhOksVWnNLjdpM82qFzB6S5Q_WWsUhuqCc3JtAsVR_OoMnhyZwXgHWwbS1d4gnsLVZJp-P6mfVxveqAgqC70Jz_pQCOGDKM5xFdNNPDdilF6uSU_hOYqu4a3MHYDZLDzq5fodrC3PWcEaFGPUaRiqJWK_W9g9rvRITa4dhy_0nw67SiePMp3oSR6PPn41DGgllkvkizYwsrmtaejTFd8V4yekGmT1zqrt4XGlAy8WTuiPULF01LksZvukSajfQQRAxmYi5S0D81sDcyzapVdn6sYFHkjhhGyel3frVQnvsnbR23lEjlhIlaOJiFPWzU5G4tfNJo8ejwp47-TbvJkKKZvmxA6SKo16oaazJysfG6klr9T0pbTW2ZqzlL_XaT8fYbQLXe4mSmvoCZXMaa7FePW6s7jVqK9bujvse3WFjY5_Z4KfsA4oiPY4T7Drvn1tLJTbG1to1qR79ulgk89-oJbvZzbIwJty6u20LOReWa9BvwserUd9s9MIKc3x5TUWEoAhUyJK5y85w_yG-dFu_R9waoU7K581y8W_qLle35-rG9Nxcrz8QHRsc0K-r9NViYRT36KsFvCCNzDRMqvSVyzOKAnACpZECIvSvCs2UAhS9QHEwh43BST0GItjMIS_I8e-sLwnj9A262cxA_ZVh0OUY1LJiDSJ5MAEiUijYLUtBORR6KElyQPaCSRDpksNSd8AfluSgHPaFC17wjrOlbgbzyyFf4IFPDvoD_sJvnkdK-g
|
||||
"""
|
||||
def decorated(request: gradio.Request, cookies, max_length, llm_model, txt, txt2, top_p, temperature, chatbot, history, system_prompt, plugin_advanced_arg, *args):
|
||||
txt_passon = txt
|
||||
@@ -323,54 +333,6 @@ def find_free_port():
|
||||
return s.getsockname()[1]
|
||||
|
||||
|
||||
def extract_archive(file_path, dest_dir):
|
||||
import zipfile
|
||||
import tarfile
|
||||
import os
|
||||
|
||||
# Get the file extension of the input file
|
||||
file_extension = os.path.splitext(file_path)[1]
|
||||
|
||||
# Extract the archive based on its extension
|
||||
if file_extension == ".zip":
|
||||
with zipfile.ZipFile(file_path, "r") as zipobj:
|
||||
zipobj.extractall(path=dest_dir)
|
||||
print("Successfully extracted zip archive to {}".format(dest_dir))
|
||||
|
||||
elif file_extension in [".tar", ".gz", ".bz2"]:
|
||||
with tarfile.open(file_path, "r:*") as tarobj:
|
||||
tarobj.extractall(path=dest_dir)
|
||||
print("Successfully extracted tar archive to {}".format(dest_dir))
|
||||
|
||||
# 第三方库,需要预先pip install rarfile
|
||||
# 此外,Windows上还需要安装winrar软件,配置其Path环境变量,如"C:\Program Files\WinRAR"才可以
|
||||
elif file_extension == ".rar":
|
||||
try:
|
||||
import rarfile
|
||||
|
||||
with rarfile.RarFile(file_path) as rf:
|
||||
rf.extractall(path=dest_dir)
|
||||
print("Successfully extracted rar archive to {}".format(dest_dir))
|
||||
except:
|
||||
print("Rar format requires additional dependencies to install")
|
||||
return "\n\n解压失败! 需要安装pip install rarfile来解压rar文件。建议:使用zip压缩格式。"
|
||||
|
||||
# 第三方库,需要预先pip install py7zr
|
||||
elif file_extension == ".7z":
|
||||
try:
|
||||
import py7zr
|
||||
|
||||
with py7zr.SevenZipFile(file_path, mode="r") as f:
|
||||
f.extractall(path=dest_dir)
|
||||
print("Successfully extracted 7z archive to {}".format(dest_dir))
|
||||
except:
|
||||
print("7z format requires additional dependencies to install")
|
||||
return "\n\n解压失败! 需要安装pip install py7zr来解压7z文件"
|
||||
else:
|
||||
return ""
|
||||
return ""
|
||||
|
||||
|
||||
def find_recent_files(directory):
|
||||
"""
|
||||
me: find files that is created with in one minutes under a directory with python, write a function
|
||||
@@ -468,39 +430,8 @@ def del_outdated_uploads(outdate_time_seconds, target_path_base=None):
|
||||
return
|
||||
|
||||
|
||||
def html_local_file(file):
|
||||
base_path = os.path.dirname(__file__) # 项目目录
|
||||
if os.path.exists(str(file)):
|
||||
file = f'file={file.replace(base_path, ".")}'
|
||||
return file
|
||||
|
||||
|
||||
def html_local_img(__file, layout="left", max_width=None, max_height=None, md=True):
|
||||
style = ""
|
||||
if max_width is not None:
|
||||
style += f"max-width: {max_width};"
|
||||
if max_height is not None:
|
||||
style += f"max-height: {max_height};"
|
||||
__file = html_local_file(__file)
|
||||
a = f'<div align="{layout}"><img src="{__file}" style="{style}"></div>'
|
||||
if md:
|
||||
a = f""
|
||||
return a
|
||||
|
||||
|
||||
def file_manifest_filter_type(file_list, filter_: list = None):
|
||||
new_list = []
|
||||
if not filter_:
|
||||
filter_ = ["png", "jpg", "jpeg"]
|
||||
for file in file_list:
|
||||
if str(os.path.basename(file)).split(".")[-1] in filter_:
|
||||
new_list.append(html_local_img(file, md=False))
|
||||
else:
|
||||
new_list.append(file)
|
||||
return new_list
|
||||
|
||||
|
||||
def to_markdown_tabs(head: list, tabs: list, alignment=":---:", column=False):
|
||||
def to_markdown_tabs(head: list, tabs: list, alignment=":---:", column=False, omit_path=None):
|
||||
"""
|
||||
Args:
|
||||
head: 表头:[]
|
||||
@@ -524,6 +455,9 @@ def to_markdown_tabs(head: list, tabs: list, alignment=":---:", column=False):
|
||||
for i in range(max_len):
|
||||
row_data = [tab[i] if i < len(tab) else "" for tab in transposed_tabs]
|
||||
row_data = file_manifest_filter_type(row_data, filter_=None)
|
||||
# for dat in row_data:
|
||||
# if (omit_path is not None) and os.path.exists(dat):
|
||||
# dat = os.path.relpath(dat, omit_path)
|
||||
tabs_list += "".join([tab_format % i for i in row_data]) + "|\n"
|
||||
|
||||
return tabs_list
|
||||
@@ -559,15 +493,21 @@ def on_file_uploaded(
|
||||
)
|
||||
|
||||
# 整理文件集合 输出消息
|
||||
moved_files = [fp for fp in glob.glob(f"{target_path_base}/**/*", recursive=True)]
|
||||
moved_files_str = to_markdown_tabs(head=["文件"], tabs=[moved_files])
|
||||
files = glob.glob(f"{target_path_base}/**/*", recursive=True)
|
||||
moved_files = [fp for fp in files]
|
||||
max_file_to_show = 10
|
||||
if len(moved_files) > max_file_to_show:
|
||||
moved_files = moved_files[:max_file_to_show//2] + [f'... ( 📌省略{len(moved_files) - max_file_to_show}个文件的显示 ) ...'] + \
|
||||
moved_files[-max_file_to_show//2:]
|
||||
moved_files_str = to_markdown_tabs(head=["文件"], tabs=[moved_files], omit_path=target_path_base)
|
||||
chatbot.append(
|
||||
[
|
||||
"我上传了文件,请查收",
|
||||
f"[Local Message] 收到以下文件: \n\n{moved_files_str}"
|
||||
+ f"\n\n调用路径参数已自动修正到: \n\n{txt}"
|
||||
+ f"\n\n现在您点击任意函数插件时,以上文件将被作为输入参数"
|
||||
+ upload_msg,
|
||||
f"[Local Message] 收到以下文件 (上传到路径:{target_path_base}): " +
|
||||
f"\n\n{moved_files_str}" +
|
||||
f"\n\n调用路径参数已自动修正到: \n\n{txt}" +
|
||||
f"\n\n现在您点击任意函数插件时,以上文件将被作为输入参数" +
|
||||
upload_msg,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
4
version
4
version
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": 3.70,
|
||||
"version": 3.72,
|
||||
"show_feature": true,
|
||||
"new_feature": "支持Mermaid绘图库(让大模型绘制脑图) <-> 支持Gemini-pro <-> 支持直接拖拽文件到上传区 <-> 支持将图片粘贴到输入区 <-> 修复若干隐蔽的内存BUG <-> 修复多用户冲突问题 <-> 接入Deepseek Coder <-> AutoGen多智能体插件测试版"
|
||||
"new_feature": "支持切换多个智谱ai模型 <-> 用绘图功能增强部分插件 <-> 基础功能区支持自动切换中英提示词 <-> 支持Mermaid绘图库(让大模型绘制脑图) <-> 支持Gemini-pro <-> 支持直接拖拽文件到上传区 <-> 支持将图片粘贴到输入区"
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户