优化chatbot 显示效果,重写chatbot的css 代码,让其最大不超过父元素
This commit is contained in:
@ -40,8 +40,8 @@ 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, CHATBOT_HEIGHT, LAYOUT, API_KEY, AVAIL_LLM_MODELS = \
|
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, LAYOUT, API_KEY, AVAIL_LLM_MODELS = \
|
||||||
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT',
|
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'LAYOUT',
|
||||||
'API_KEY', 'AVAIL_LLM_MODELS')
|
'API_KEY', 'AVAIL_LLM_MODELS')
|
||||||
|
|
||||||
proxy_info = check_proxy(proxies)
|
proxy_info = check_proxy(proxies)
|
||||||
@ -73,7 +73,7 @@ class ChatBot(ChatBotFrame):
|
|||||||
|
|
||||||
def draw_chatbot(self):
|
def draw_chatbot(self):
|
||||||
self.chatbot = gr.Chatbot(elem_id='main_chatbot', label=f"当前模型:{LLM_MODEL}")
|
self.chatbot = gr.Chatbot(elem_id='main_chatbot', label=f"当前模型:{LLM_MODEL}")
|
||||||
self.chatbot.style(height=CHATBOT_HEIGHT)
|
self.chatbot.style()
|
||||||
self.history = gr.State([])
|
self.history = gr.State([])
|
||||||
temp_draw = [gr.HTML() for i in range(4)]
|
temp_draw = [gr.HTML() for i in range(4)]
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
|
|||||||
@ -480,10 +480,10 @@ def thread_write_chat(chatbot):
|
|||||||
对话记录写入数据库
|
对话记录写入数据库
|
||||||
"""
|
"""
|
||||||
private_key = toolbox.get_conf('private_key')[0]
|
private_key = toolbox.get_conf('private_key')[0]
|
||||||
chat_title = chatbot[0][0].split()
|
chat_title = chatbot[0][1].split()
|
||||||
|
pattern = re.compile(r'^<div class="markdown-body"><p>|<\/p><\/div>$')
|
||||||
i_say = re.sub(r'^<div class="markdown-body"><p>|<\/p><\/div>$', '', chatbot[-1][0])
|
i_say = pattern.sub('', chatbot[-1][0])
|
||||||
gpt_result = re.sub(r'^<div class="markdown-body"><p>|<\/p><\/div>$', '', chatbot[-1][1])
|
gpt_result = pattern.sub('', chatbot[-1][1])
|
||||||
if private_key in chat_title:
|
if private_key in chat_title:
|
||||||
SqliteHandle(f'ai_private_{chat_title[-2]}').inset_prompt({i_say: gpt_result})
|
SqliteHandle(f'ai_private_{chat_title[-2]}').inset_prompt({i_say: gpt_result})
|
||||||
else:
|
else:
|
||||||
|
|||||||
8
theme.py
8
theme.py
@ -130,9 +130,15 @@ textarea {
|
|||||||
#main_chatbot {
|
#main_chatbot {
|
||||||
height: 75vh !important;
|
height: 75vh !important;
|
||||||
max-height: 75vh !important;
|
max-height: 75vh !important;
|
||||||
overflow: auto !important;
|
/* overflow: auto !important; */
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
.wrap.svelte-18telvq.svelte-18telvq {
|
||||||
|
padding: var(--block-padding) !important;
|
||||||
|
height: 100% !important;
|
||||||
|
max-height: 95% !important;
|
||||||
|
overflow-y: auto !important;
|
||||||
|
}
|
||||||
.app.svelte-1mya07g.svelte-1mya07g {
|
.app.svelte-1mya07g.svelte-1mya07g {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@ -74,14 +74,14 @@ def ArgsGeneralWrapper(f):
|
|||||||
private_key = get_conf('private_key')[0]
|
private_key = get_conf('private_key')[0]
|
||||||
if private in models:
|
if private in models:
|
||||||
if chatbot == []:
|
if chatbot == []:
|
||||||
chatbot.append([f'隐私模式, 你的对话记录无法被他人检索 <p style="display:none;">\n{private_key}\n{ipaddr.client.host}\n</p>', None])
|
chatbot.append([None, f'隐私模式, 你的对话记录无法被他人检索 <p style="display:none;">\n{private_key}\n{ipaddr.client.host}\n</p>'])
|
||||||
else:
|
else:
|
||||||
chatbot[0] = [f'隐私模式, 你的对话记录无法被他人检索 <p style="display:none;">\n{private_key}\n{ipaddr.client.host}\n</p>', None]
|
chatbot[0] = [None, f'隐私模式, 你的对话记录无法被他人检索 <p style="display:none;">\n{private_key}\n{ipaddr.client.host}\n</p>']
|
||||||
else:
|
else:
|
||||||
if chatbot == []:
|
if chatbot == []:
|
||||||
chatbot.append(['正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索,你可以到Settings中选择隐私模式', None])
|
chatbot.append([None, '正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索,你可以到Settings中选择隐私模式'])
|
||||||
else:
|
else:
|
||||||
chatbot[0] = ['正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索,你可以到Settings中选择隐私模式', None]
|
chatbot[0] = [None, '正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索,你可以到Settings中选择隐私模式']
|
||||||
chatbot_with_cookie = ChatBotWithCookies(cookies)
|
chatbot_with_cookie = ChatBotWithCookies(cookies)
|
||||||
chatbot_with_cookie.write_list(chatbot)
|
chatbot_with_cookie.write_list(chatbot)
|
||||||
txt_passon = txt
|
txt_passon = txt
|
||||||
|
|||||||
Reference in New Issue
Block a user