Spaces:
Sleeping
Sleeping
Keldos commited on
调整 UI (status_display) (#183)
Browse files* 给status_display加了css,
现在它位于右上角且不会高度乱跳, 样式为灰色等宽, 靠右下对齐
* 微调了标题和description的css
* 删去了直接用<div>的注释
- ChuanhuChatbot.py +4 -15
- presets.py +14 -5
ChuanhuChatbot.py
CHANGED
|
@@ -43,7 +43,7 @@ else:
|
|
| 43 |
|
| 44 |
gr.Chatbot.postprocess = postprocess
|
| 45 |
|
| 46 |
-
with gr.Blocks(css=customCSS
|
| 47 |
history = gr.State([])
|
| 48 |
token_count = gr.State([])
|
| 49 |
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
|
@@ -51,13 +51,11 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
| 51 |
FALSECONSTANT = gr.State(False)
|
| 52 |
topic = gr.State("未命名对话历史记录")
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
gr.HTML(title)
|
| 58 |
|
| 59 |
with gr.Row(scale=1).style(equal_height=True):
|
| 60 |
-
|
| 61 |
with gr.Column(scale=5):
|
| 62 |
with gr.Row(scale=1):
|
| 63 |
chatbot = gr.Chatbot().style(height=600) # .style(color_map=("#1D51EE", "#585A5B"))
|
|
@@ -73,11 +71,8 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
| 73 |
delLastBtn = gr.Button("🗑️ 删除一条对话")
|
| 74 |
reduceTokenBtn = gr.Button("♻️ 总结对话")
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
with gr.Column():
|
| 79 |
with gr.Column(min_width=50,scale=1):
|
| 80 |
-
status_display = gr.Markdown("status: ready")
|
| 81 |
with gr.Tab(label="ChatGPT"):
|
| 82 |
keyTxt = gr.Textbox(show_label=True, placeholder=f"OpenAI API-key...",value=my_api_key, type="password", visible=not HIDE_MY_KEY, label="API-Key")
|
| 83 |
model_select_dropdown = gr.Dropdown(label="选择模型", choices=MODELS, multiselect=False, value=MODELS[0])
|
|
@@ -117,14 +112,8 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
| 117 |
with gr.Column(scale=1):
|
| 118 |
historyRefreshBtn = gr.Button("🔄 刷新")
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
gr.HTML("""
|
| 123 |
-
<div style="text-align: center; margin-top: 20px; margin-bottom: 20px;">
|
| 124 |
-
""")
|
| 125 |
gr.Markdown(description)
|
| 126 |
|
| 127 |
-
|
| 128 |
user_input.submit(predict, [keyTxt, systemPromptTxt, history, user_input, chatbot, token_count, top_p, temperature, use_streaming_checkbox, model_select_dropdown, use_websearch_checkbox], [chatbot, history, status_display, token_count], show_progress=True)
|
| 129 |
user_input.submit(reset_textbox, [], [user_input])
|
| 130 |
|
|
|
|
| 43 |
|
| 44 |
gr.Chatbot.postprocess = postprocess
|
| 45 |
|
| 46 |
+
with gr.Blocks(css=customCSS) as demo:
|
| 47 |
history = gr.State([])
|
| 48 |
token_count = gr.State([])
|
| 49 |
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
|
|
|
| 51 |
FALSECONSTANT = gr.State(False)
|
| 52 |
topic = gr.State("未命名对话历史记录")
|
| 53 |
|
| 54 |
+
with gr.Row():
|
| 55 |
+
gr.HTML(title)
|
| 56 |
+
status_display = gr.Markdown("status: ready", elem_id="status_display")
|
|
|
|
| 57 |
|
| 58 |
with gr.Row(scale=1).style(equal_height=True):
|
|
|
|
| 59 |
with gr.Column(scale=5):
|
| 60 |
with gr.Row(scale=1):
|
| 61 |
chatbot = gr.Chatbot().style(height=600) # .style(color_map=("#1D51EE", "#585A5B"))
|
|
|
|
| 71 |
delLastBtn = gr.Button("🗑️ 删除一条对话")
|
| 72 |
reduceTokenBtn = gr.Button("♻️ 总结对话")
|
| 73 |
|
|
|
|
|
|
|
| 74 |
with gr.Column():
|
| 75 |
with gr.Column(min_width=50,scale=1):
|
|
|
|
| 76 |
with gr.Tab(label="ChatGPT"):
|
| 77 |
keyTxt = gr.Textbox(show_label=True, placeholder=f"OpenAI API-key...",value=my_api_key, type="password", visible=not HIDE_MY_KEY, label="API-Key")
|
| 78 |
model_select_dropdown = gr.Dropdown(label="选择模型", choices=MODELS, multiselect=False, value=MODELS[0])
|
|
|
|
| 112 |
with gr.Column(scale=1):
|
| 113 |
historyRefreshBtn = gr.Button("🔄 刷新")
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
gr.Markdown(description)
|
| 116 |
|
|
|
|
| 117 |
user_input.submit(predict, [keyTxt, systemPromptTxt, history, user_input, chatbot, token_count, top_p, temperature, use_streaming_checkbox, model_select_dropdown, use_websearch_checkbox], [chatbot, history, status_display, token_count], show_progress=True)
|
| 118 |
user_input.submit(reset_textbox, [], [user_input])
|
| 119 |
|
presets.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# -*- coding:utf-8 -*-
|
| 2 |
-
title = """<h1 align="left">川虎ChatGPT 🚀</h1>"""
|
| 3 |
-
description = """<div align=center>
|
| 4 |
|
| 5 |
由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) 和 [明昭MZhao](https://space.bilibili.com/24807452)开发
|
| 6 |
|
|
@@ -10,6 +10,17 @@ description = """<div align=center>
|
|
| 10 |
</div>
|
| 11 |
"""
|
| 12 |
customCSS = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
code {
|
| 14 |
display: inline;
|
| 15 |
white-space: break-spaces;
|
|
@@ -30,11 +41,9 @@ pre code {
|
|
| 30 |
box-shadow: inset 0px 8px 16px hsla(0, 0%, 0%, .2)
|
| 31 |
}
|
| 32 |
|
| 33 |
-
*{
|
| 34 |
transition: all 0.6s;
|
| 35 |
}
|
| 36 |
-
|
| 37 |
-
|
| 38 |
"""
|
| 39 |
|
| 40 |
summarize_prompt = "你是谁?我们刚才聊了什么?" # 总结对话时的 prompt
|
|
|
|
| 1 |
# -*- coding:utf-8 -*-
|
| 2 |
+
title = """<h1 align="left" style="min-width:200px; margin-top:0;">川虎ChatGPT 🚀</h1>"""
|
| 3 |
+
description = """<div align="center" style="margin-top:20px">
|
| 4 |
|
| 5 |
由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) 和 [明昭MZhao](https://space.bilibili.com/24807452)开发
|
| 6 |
|
|
|
|
| 10 |
</div>
|
| 11 |
"""
|
| 12 |
customCSS = """
|
| 13 |
+
#status_display {
|
| 14 |
+
display: flex;
|
| 15 |
+
min-height: 2.5em;
|
| 16 |
+
align-items: flex-end;
|
| 17 |
+
justify-content: flex-end;
|
| 18 |
+
}
|
| 19 |
+
#status_display p {
|
| 20 |
+
font-size: .85em;
|
| 21 |
+
font-family: monospace;
|
| 22 |
+
color: var(--text-color-subdued) !important;
|
| 23 |
+
}
|
| 24 |
code {
|
| 25 |
display: inline;
|
| 26 |
white-space: break-spaces;
|
|
|
|
| 41 |
box-shadow: inset 0px 8px 16px hsla(0, 0%, 0%, .2)
|
| 42 |
}
|
| 43 |
|
| 44 |
+
* {
|
| 45 |
transition: all 0.6s;
|
| 46 |
}
|
|
|
|
|
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
summarize_prompt = "你是谁?我们刚才聊了什么?" # 总结对话时的 prompt
|