适配TOP-DOWN布局
This commit is contained in:
2
main.py
2
main.py
@ -58,7 +58,7 @@ def main():
|
||||
with gr_L1():
|
||||
with gr_L2(scale=2, elem_id="gpt-chat"):
|
||||
chatbot = gr.Chatbot(label=f"当前模型:{LLM_MODEL}", elem_id="gpt-chatbot")
|
||||
chatbot.style()
|
||||
if LAYOUT == "TOP-DOWN": chatbot.style(height=CHATBOT_HEIGHT)
|
||||
history = gr.State([])
|
||||
with gr_L2(scale=1, elem_id="gpt-panel"):
|
||||
with gr.Accordion("输入区", open=True, elem_id="input-panel") as area_input_primary:
|
||||
|
||||
22
theme.py
22
theme.py
@ -1,6 +1,6 @@
|
||||
import gradio as gr
|
||||
from toolbox import get_conf
|
||||
CODE_HIGHLIGHT, ADD_WAIFU = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU')
|
||||
CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU', 'LAYOUT')
|
||||
# gradio可用颜色列表
|
||||
# gr.themes.utils.colors.slate (石板色)
|
||||
# gr.themes.utils.colors.gray (灰色)
|
||||
@ -82,12 +82,10 @@ def adjust_theme():
|
||||
button_cancel_text_color_dark="white",
|
||||
)
|
||||
|
||||
# 别忘了layout的区别
|
||||
# Layout = "LEFT-RIGHT"
|
||||
js = """
|
||||
<script>
|
||||
|
||||
function ChatBotHeight() {
|
||||
|
||||
<script>
|
||||
function ChatBotHeight() {
|
||||
function update_height(){
|
||||
var { panel_height_target, chatbot_height, chatbot } = get_elements();
|
||||
if (panel_height_target!=chatbot_height)
|
||||
@ -115,9 +113,9 @@ function ChatBotHeight() {
|
||||
setInterval(function() {
|
||||
update_height_slow()
|
||||
}, 50); // 每100毫秒执行一次
|
||||
}
|
||||
}
|
||||
|
||||
function get_elements() {
|
||||
function get_elements() {
|
||||
const chatbot = document.querySelector('#gpt-chatbot > div.wrap.svelte-18telvq');
|
||||
const panel1 = document.querySelector('#input-panel');
|
||||
const panel2 = document.querySelector('#basic-panel');
|
||||
@ -130,11 +128,13 @@ function get_elements() {
|
||||
var chatbot_height = chatbot.style.height;
|
||||
var chatbot_height = parseInt(chatbot_height);
|
||||
return { panel_height_target, chatbot_height, chatbot };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
"""
|
||||
|
||||
if LAYOUT=="TOP-DOWN":
|
||||
js = ""
|
||||
|
||||
</script>
|
||||
"""
|
||||
# 添加一个萌萌的看板娘
|
||||
if ADD_WAIFU:
|
||||
js += """
|
||||
|
||||
Reference in New Issue
Block a user