优化chatbot 显示效果,重写chatbot的css 代码,让其最大不超过父元素

This commit is contained in:
w_xiaolizu
2023-06-04 23:16:24 +08:00
parent 7b83ba6c47
commit 12c4609712
4 changed files with 19 additions and 13 deletions

View File

@ -40,8 +40,8 @@ except:
print("所有问询记录将自动保存在本地目录./gpt_log/chat_secrets.log, 请注意自我隐私保护哦!")
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址, 避免不小心传github被别人看到
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY, AVAIL_LLM_MODELS = \
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT',
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, LAYOUT, API_KEY, AVAIL_LLM_MODELS = \
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'LAYOUT',
'API_KEY', 'AVAIL_LLM_MODELS')
proxy_info = check_proxy(proxies)
@ -73,7 +73,7 @@ class ChatBot(ChatBotFrame):
def draw_chatbot(self):
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([])
temp_draw = [gr.HTML() for i in range(4)]
with gr.Row():

View File

@ -480,10 +480,10 @@ def thread_write_chat(chatbot):
对话记录写入数据库
"""
private_key = toolbox.get_conf('private_key')[0]
chat_title = chatbot[0][0].split()
i_say = re.sub(r'^<div class="markdown-body"><p>|<\/p><\/div>$', '', chatbot[-1][0])
gpt_result = re.sub(r'^<div class="markdown-body"><p>|<\/p><\/div>$', '', chatbot[-1][1])
chat_title = chatbot[0][1].split()
pattern = re.compile(r'^<div class="markdown-body"><p>|<\/p><\/div>$')
i_say = pattern.sub('', chatbot[-1][0])
gpt_result = pattern.sub('', chatbot[-1][1])
if private_key in chat_title:
SqliteHandle(f'ai_private_{chat_title[-2]}').inset_prompt({i_say: gpt_result})
else:

View File

@ -130,9 +130,15 @@ textarea {
#main_chatbot {
height: 75vh !important;
max-height: 75vh !important;
overflow: auto !important;
/* overflow: auto !important; */
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 {
max-width: 100%;
position: relative;
@ -187,7 +193,7 @@ textarea {
max-width: 95%;
color: #ccd2db !important;
letter-spacing: 0.5px;
font-weight: normal;
font-weight: normal;
/* width: auto !important; */
border-bottom-left-radius: 0 !important;
}

View File

@ -74,14 +74,14 @@ def ArgsGeneralWrapper(f):
private_key = get_conf('private_key')[0]
if private in models:
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:
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:
if chatbot == []:
chatbot.append(['正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索你可以到Settings中选择隐私模式', None])
chatbot.append([None, '正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索你可以到Settings中选择隐私模式'])
else:
chatbot[0] = ['正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索你可以到Settings中选择隐私模式', None]
chatbot[0] = [None, '正常对话模式, 你接来下的对话将会被记录并且可以被所有人检索你可以到Settings中选择隐私模式']
chatbot_with_cookie = ChatBotWithCookies(cookies)
chatbot_with_cookie.write_list(chatbot)
txt_passon = txt