pick 部分代码
This commit is contained in:
@ -40,9 +40,9 @@ except:
|
|||||||
print("所有问询记录将自动保存在本地目录./gpt_log/chat_secrets.log, 请注意自我隐私保护哦!")
|
print("所有问询记录将自动保存在本地目录./gpt_log/chat_secrets.log, 请注意自我隐私保护哦!")
|
||||||
|
|
||||||
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址, 避免不小心传github被别人看到
|
# 建议您复制一个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',
|
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)
|
proxy_info = check_proxy(proxies)
|
||||||
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
||||||
@ -415,7 +415,7 @@ def check_proxy_free():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
# 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()
|
check_proxy_free()
|
||||||
ChatBot().main()
|
ChatBot().main()
|
||||||
gr.close_all()
|
gr.close_all()
|
||||||
|
|||||||
@ -8,7 +8,9 @@
|
|||||||
--message-bot-background-color-light: #FFFFFF;
|
--message-bot-background-color-light: #FFFFFF;
|
||||||
--message-bot-background-color-dark: #2C2C2C;
|
--message-bot-background-color-dark: #2C2C2C;
|
||||||
}
|
}
|
||||||
|
mspace {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
#debug_mes {
|
#debug_mes {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
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>'
|
tag = f'<span style="background-color: {color}; font-weight: bold; color: {font}"> {tag} </span>'
|
||||||
return tag
|
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():
|
def ipaddr():
|
||||||
# 获取本地ipx
|
# 获取本地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'):
|
for file_handle in str(file).split('\n'):
|
||||||
if os.path.isfile(file_handle):
|
if os.path.isfile(file_handle):
|
||||||
# temp_file = func_box.copy_temp_file(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))
|
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:',
|
chatbot.append(['Convert the file address to a download link at:',
|
||||||
f'[Local Message] Successful conversion\n\n '
|
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:
|
else:
|
||||||
chatbot.append(['Convert the file address to a download link at:',
|
chatbot.append(['Convert the file address to a download link at:',
|
||||||
f'[Local Message] Conversion failed, file or not exist.'])
|
f'[Local Message] Conversion failed, file or not exist.'])
|
||||||
elif os.path.isdir(file_handle):
|
elif os.path.isdir(file_handle):
|
||||||
for root, dirs, files in os.walk(file_handle):
|
for root, dirs, files in os.walk(file_handle):
|
||||||
for f in files:
|
for f in files:
|
||||||
temp_ = os.path.abspath(os.path.join(root, f))
|
temp_file = os.path.abspath(os.path.join(root, f))
|
||||||
dir_file, file_name = ('/'.join(str(file_handle).split('/')[-2:]), os.path.basename(temp_))
|
dir_file, file_name = ('/'.join(str(file_handle).split('/')[-2:]), os.path.basename(temp_file))
|
||||||
link_href = f'{link["local"]} / file = {temp_}'
|
|
||||||
chatbot.append(['Convert the file address to a download link at:',
|
chatbot.append(['Convert the file address to a download link at:',
|
||||||
f'[Local Message] Successful conversion\n\n '
|
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 == '':
|
elif file_handle == '':
|
||||||
pass
|
pass
|
||||||
return chatbot, ''
|
return chatbot, ''
|
||||||
|
|||||||
Reference in New Issue
Block a user