pick 部分代码
This commit is contained in:
@ -40,9 +40,9 @@ except:
|
||||
print("所有问询记录将自动保存在本地目录./gpt_log/chat_secrets.log, 请注意自我隐私保护哦!")
|
||||
|
||||
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址, 避免不小心传github被别人看到
|
||||
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, LAYOUT, API_KEY, AVAIL_LLM_MODELS = \
|
||||
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, LAYOUT, API_KEY, AVAIL_LLM_MODELS, LOCAL_PORT= \
|
||||
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'LAYOUT',
|
||||
'API_KEY', 'AVAIL_LLM_MODELS')
|
||||
'API_KEY', 'AVAIL_LLM_MODELS', 'LOCAL_PORT')
|
||||
|
||||
proxy_info = check_proxy(proxies)
|
||||
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
||||
@ -415,7 +415,7 @@ def check_proxy_free():
|
||||
|
||||
if __name__ == '__main__':
|
||||
# PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
||||
PORT = 7891 if WEB_PORT <= 0 else WEB_PORT
|
||||
PORT = LOCAL_PORT if WEB_PORT <= 0 else WEB_PORT
|
||||
check_proxy_free()
|
||||
ChatBot().main()
|
||||
gr.close_all()
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
--message-bot-background-color-light: #FFFFFF;
|
||||
--message-bot-background-color-dark: #2C2C2C;
|
||||
}
|
||||
|
||||
mspace {
|
||||
display: block;
|
||||
}
|
||||
#debug_mes {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
|
||||
13
func_box.py
13
func_box.py
@ -131,6 +131,19 @@ def html_tag_color(tag, color=None, font='black'):
|
||||
tag = f'<span style="background-color: {color}; font-weight: bold; color: {font}"> {tag} </span>'
|
||||
return tag
|
||||
|
||||
def html_a_blank(__href, name=''):
|
||||
if not name:
|
||||
dir_name = __href
|
||||
a = f'<a href="{__href}" target="_blank" class="svelte-xrr240">{name}</a>'
|
||||
return a
|
||||
|
||||
def html_download_blank(__href, file_name='temp', dir_name=''):
|
||||
if os.path.exists(__href):
|
||||
__href = f'/file={__href}'
|
||||
if not dir_name:
|
||||
dir_name = file_name
|
||||
a = f'<a href="{__href}" target="_blank" download="{dir_name}" class="svelte-xrr240">{file_name}</a>'
|
||||
return a
|
||||
|
||||
def ipaddr():
|
||||
# 获取本地ipx
|
||||
|
||||
10
toolbox.py
10
toolbox.py
@ -519,6 +519,7 @@ def get_user_download(chatbot, link, file):
|
||||
"""
|
||||
将短路径转换为下载链接
|
||||
"""
|
||||
file = file.rstrip()
|
||||
for file_handle in str(file).split('\n'):
|
||||
if os.path.isfile(file_handle):
|
||||
# temp_file = func_box.copy_temp_file(file_handle) 无法使用外部的临时目录
|
||||
@ -527,19 +528,18 @@ def get_user_download(chatbot, link, file):
|
||||
dir_file, file_name = ('/'.join(str(file_handle).split('/')[-2:]), os.path.basename(file_handle))
|
||||
chatbot.append(['Convert the file address to a download link at:',
|
||||
f'[Local Message] Successful conversion\n\n '
|
||||
f'<a href="{link["local"]}/file={temp_file}" target="_blank" download="{dir_file}" class="svelte-xrr240">{file_name}</a>'])
|
||||
f'{func_box.html_download_blank(__href=temp_file, dir_name=file_name, file_name=file_name)}'])
|
||||
else:
|
||||
chatbot.append(['Convert the file address to a download link at:',
|
||||
f'[Local Message] Conversion failed, file or not exist.'])
|
||||
elif os.path.isdir(file_handle):
|
||||
for root, dirs, files in os.walk(file_handle):
|
||||
for f in files:
|
||||
temp_ = os.path.abspath(os.path.join(root, f))
|
||||
dir_file, file_name = ('/'.join(str(file_handle).split('/')[-2:]), os.path.basename(temp_))
|
||||
link_href = f'{link["local"]} / file = {temp_}'
|
||||
temp_file = os.path.abspath(os.path.join(root, f))
|
||||
dir_file, file_name = ('/'.join(str(file_handle).split('/')[-2:]), os.path.basename(temp_file))
|
||||
chatbot.append(['Convert the file address to a download link at:',
|
||||
f'[Local Message] Successful conversion\n\n '
|
||||
f'{func_box.html_a_blank(__href=link_href, dir_name=dir_file, file_name=file_name)}'])
|
||||
f'{func_box.html_download_blank(__href=temp_file, dir_name=file_name, file_name=file_name)}'])
|
||||
elif file_handle == '':
|
||||
pass
|
||||
return chatbot, ''
|
||||
|
||||
Reference in New Issue
Block a user