Spaces:
Sleeping
Sleeping
隐藏、显示功能区
Browse files
main.py
CHANGED
@@ -57,12 +57,12 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
|
57 |
with gr.Row():
|
58 |
from check_proxy import check_proxy
|
59 |
statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行。当前模型: {LLM_MODEL} \n {check_proxy(proxies)}")
|
60 |
-
with gr.Accordion("基础功能区", open=True):
|
61 |
with gr.Row():
|
62 |
for k in functional:
|
63 |
variant = functional[k]["Color"] if "Color" in functional[k] else "secondary"
|
64 |
functional[k]["Button"] = gr.Button(k, variant=variant)
|
65 |
-
with gr.Accordion("函数插件区", open=True):
|
66 |
with gr.Row():
|
67 |
gr.Markdown("注意:以下“红颜色”标识的函数插件需从input区读取路径作为参数.")
|
68 |
with gr.Row():
|
@@ -76,19 +76,18 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
|
76 |
system_prompt = gr.Textbox(show_label=True, placeholder=f"System Prompt", label="System prompt", value=initial_prompt)
|
77 |
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
|
78 |
temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",)
|
79 |
-
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区"
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
|
84 |
def what_is_this(a):
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
92 |
|
93 |
predict_args = dict(fn=predict, inputs=[txt, top_p, temperature, chatbot, history, system_prompt], outputs=[chatbot, history, statusDisplay], show_progress=True)
|
94 |
empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt]) # 用于在提交后清空输入栏
|
|
|
57 |
with gr.Row():
|
58 |
from check_proxy import check_proxy
|
59 |
statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行。当前模型: {LLM_MODEL} \n {check_proxy(proxies)}")
|
60 |
+
with gr.Accordion("基础功能区", open=True) as area_basic_fn:
|
61 |
with gr.Row():
|
62 |
for k in functional:
|
63 |
variant = functional[k]["Color"] if "Color" in functional[k] else "secondary"
|
64 |
functional[k]["Button"] = gr.Button(k, variant=variant)
|
65 |
+
with gr.Accordion("函数插件区", open=True) as area_crazy_fn:
|
66 |
with gr.Row():
|
67 |
gr.Markdown("注意:以下“红颜色”标识的函数插件需从input区读取路径作为参数.")
|
68 |
with gr.Row():
|
|
|
76 |
system_prompt = gr.Textbox(show_label=True, placeholder=f"System Prompt", label="System prompt", value=initial_prompt)
|
77 |
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
|
78 |
temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",)
|
79 |
+
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区"],
|
80 |
+
value=["基础功能区", "函数插件区"], label="显示哪些功能区")
|
|
|
|
|
81 |
|
82 |
def what_is_this(a):
|
83 |
+
ret = {}
|
84 |
+
# if area_basic_fn.visible != ("基础功能区" in a):
|
85 |
+
ret.update({area_basic_fn: gr.update(visible=("基础功能区" in a))})
|
86 |
+
# if area_crazy_fn.visible != ("函数插件区" in a):
|
87 |
+
ret.update({area_crazy_fn: gr.update(visible=("函数插件区" in a))})
|
88 |
+
return ret
|
89 |
+
|
90 |
+
checkboxes.select(what_is_this, [checkboxes], [area_basic_fn, area_crazy_fn] )
|
91 |
|
92 |
predict_args = dict(fn=predict, inputs=[txt, top_p, temperature, chatbot, history, system_prompt], outputs=[chatbot, history, statusDisplay], show_progress=True)
|
93 |
empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt]) # 用于在提交后清空输入栏
|