Merge pull request #194 from fulyaec/enhance-chataca
修改AUTHENTICATION的判断,使得AUTHENTICATION为None/[]/""时都可以正确判断
This commit is contained in:
commit
e5cc1eacd7
@ -1,9 +1,12 @@
|
||||
from functools import HotReload # HotReload 的意思是热更新,修改函数插件后,不需要重启程序,代码直接生效
|
||||
|
||||
# UserVisibleLevel是过滤器参数。
|
||||
# 由于UI界面空间有限,所以通过这种方式决定UI界面中显示哪些插件
|
||||
# 默认函数插件 VisibleLevel 是 0
|
||||
# 当 UserVisibleLevel >= 函数插件的 VisibleLevel 时,该函数插件才会被显示出来
|
||||
UserVisibleLevel = 1
|
||||
|
||||
|
||||
def get_crazy_functionals():
|
||||
from crazy_functions.读文章写摘要 import 读文章写摘要
|
||||
from crazy_functions.生成函数注释 import 批量生成函数注释
|
||||
@ -16,6 +19,7 @@ def get_crazy_functionals():
|
||||
|
||||
function_plugins = {
|
||||
"请解析并解构此项目本身": {
|
||||
# HotReload 的意思是热更新,修改函数插件后,不需要重启程序,代码直接生效
|
||||
"Function": 解析项目本身
|
||||
},
|
||||
"解析整个py项目": {
|
||||
@ -39,10 +43,12 @@ def get_crazy_functionals():
|
||||
"Function": 批量生成函数注释
|
||||
},
|
||||
"[多线程demo] 把本项目源代码切换成全英文": {
|
||||
"Function": 全项目切换英文
|
||||
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
||||
"Function": HotReload(全项目切换英文)
|
||||
},
|
||||
"[函数插件模板demo] 历史上的今天": {
|
||||
"Function": 高阶功能模板函数
|
||||
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
||||
"Function": HotReload(高阶功能模板函数)
|
||||
},
|
||||
}
|
||||
|
||||
@ -52,7 +58,8 @@ def get_crazy_functionals():
|
||||
function_plugins.update({
|
||||
"[仅供开发调试] 批量总结PDF文档": {
|
||||
"Color": "stop",
|
||||
"Function": 批量总结PDF文档
|
||||
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
||||
"Function": HotReload(批量总结PDF文档)
|
||||
},
|
||||
})
|
||||
|
||||
|
5
main.py
5
main.py
@ -10,7 +10,7 @@ proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = \
|
||||
|
||||
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
||||
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
||||
AUTHENTICATION = None if AUTHENTICATION == [] else AUTHENTICATION
|
||||
if not AUTHENTICATION: AUTHENTICATION = None
|
||||
|
||||
initial_prompt = "Serve me as a writing and programming assistant."
|
||||
title_html = """<h1 align="center">ChatGPT 学术优化</h1>"""
|
||||
@ -105,8 +105,7 @@ def auto_opentab_delay():
|
||||
def open():
|
||||
time.sleep(2)
|
||||
webbrowser.open_new_tab(f'http://localhost:{PORT}')
|
||||
t = threading.Thread(target=open)
|
||||
t.daemon = True; t.start()
|
||||
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
||||
|
||||
auto_opentab_delay()
|
||||
demo.title = "ChatGPT 学术优化"
|
||||
|
@ -1,5 +1,5 @@
|
||||
# chatgpt-academic项目分析报告
|
||||
(Author补充:以下分析均由本项目调用ChatGPT一键生成,如果有不准确的地方全怪GPT)
|
||||
# chatgpt-academic项目自译解报告
|
||||
(Author补充:以下分析均由本项目调用ChatGPT一键生成,如果有不准确的地方,全怪GPT😄)
|
||||
|
||||
## [0/10] 程序摘要: check_proxy.py
|
||||
|
||||
|
13
toolbox.py
13
toolbox.py
@ -1,4 +1,4 @@
|
||||
import markdown, mdtex2html, threading, importlib, traceback
|
||||
import markdown, mdtex2html, threading, importlib, traceback, importlib, inspect
|
||||
from show_math import convert as convert_math
|
||||
from functools import wraps
|
||||
import re
|
||||
@ -89,6 +89,17 @@ def CatchException(f):
|
||||
yield chatbot, history, f'异常 {e}'
|
||||
return decorated
|
||||
|
||||
def HotReload(f):
|
||||
"""
|
||||
装饰器函数,实现函数插件热更新
|
||||
"""
|
||||
@wraps(f)
|
||||
def decorated(*args, **kwargs):
|
||||
fn_name = f.__name__
|
||||
f_hot_reload = getattr(importlib.reload(inspect.getmodule(f)), fn_name)
|
||||
yield from f_hot_reload(*args, **kwargs)
|
||||
return decorated
|
||||
|
||||
def report_execption(chatbot, history, a, b):
|
||||
"""
|
||||
向chatbot中添加错误信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user