Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
d7ec937
1
Parent(s):
bbfc7bd
微调界面
Browse files- ChuanhuChatbot.py +27 -29
ChuanhuChatbot.py
CHANGED
@@ -56,6 +56,24 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
56 |
""")
|
57 |
|
58 |
with gr.Row(scale=1).style(equal_height=True):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
with gr.Column():
|
60 |
with gr.Row(min_width=50,scale=1):
|
61 |
gr.HTML(title)
|
@@ -64,13 +82,6 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
64 |
model_select_dropdown = gr.Dropdown(label="选择模型", choices=MODELS, multiselect=False, value=MODELS[0])
|
65 |
systemPromptTxt = gr.Textbox(show_label=True, placeholder=f"在这里输入System Prompt...", label="System prompt", value=initial_prompt).style(container=True)
|
66 |
|
67 |
-
#inputs, top_p, temperature, top_k, repetition_penalty
|
68 |
-
with gr.Accordion("参数", open=True):
|
69 |
-
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.05,
|
70 |
-
interactive=True, label="Top-p (nucleus sampling)",)
|
71 |
-
temperature = gr.Slider(minimum=-0, maximum=5.0, value=1.0,
|
72 |
-
step=0.1, interactive=True, label="Temperature",)
|
73 |
-
|
74 |
|
75 |
with gr.Accordion(label="加载Prompt模板", open=False):
|
76 |
with gr.Column():
|
@@ -79,12 +90,9 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
79 |
templateFileSelectDropdown = gr.Dropdown(label="选择Prompt模板集合文件", choices=get_template_names(plain=True), multiselect=False, value=get_template_names(plain=True)[0])
|
80 |
with gr.Column(scale=1):
|
81 |
templateRefreshBtn = gr.Button("🔄 刷新")
|
82 |
-
templaeFileReadBtn = gr.Button("📂 读入模板")
|
83 |
with gr.Row():
|
84 |
-
with gr.Column(
|
85 |
templateSelectDropdown = gr.Dropdown(label="从Prompt模板中加载", choices=load_template(get_template_names(plain=True)[0], mode=1), multiselect=False, value=load_template(get_template_names(plain=True)[0], mode=1)[0])
|
86 |
-
with gr.Column(scale=1):
|
87 |
-
templateApplyBtn = gr.Button("⬇️ 应用")
|
88 |
with gr.Accordion(label="保存/加载对话历史记录", open=False):
|
89 |
with gr.Column():
|
90 |
with gr.Row():
|
@@ -98,27 +106,17 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
98 |
historyFileSelectDropdown = gr.Dropdown(label="从列表中加载对话", choices=get_history_names(plain=True), multiselect=False, value=get_history_names(plain=True)[0])
|
99 |
with gr.Column(scale=1):
|
100 |
historyRefreshBtn = gr.Button("🔄 刷新")
|
101 |
-
historyReadBtn = gr.Button("📂 读入对话")
|
102 |
|
103 |
use_streaming_checkbox = gr.Checkbox(label="实时传输回答", value=True, visible=enable_streaming_option)
|
104 |
use_websearch_checkbox = gr.Checkbox(label="使用在线搜索", value=False)
|
105 |
|
106 |
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
with gr.Column(scale=5):
|
109 |
-
with gr.Row(scale=1):
|
110 |
-
chatbot = gr.Chatbot().style(height=700) # .style(color_map=("#1D51EE", "#585A5B"))
|
111 |
-
with gr.Row(scale=1):
|
112 |
-
with gr.Column(scale=12):
|
113 |
-
user_input = gr.Textbox(show_label=False, placeholder="在这里输入").style(
|
114 |
-
container=False)
|
115 |
-
with gr.Column(min_width=50, scale=1):
|
116 |
-
submitBtn = gr.Button("🚀", variant="primary")
|
117 |
-
with gr.Row(scale=1):
|
118 |
-
emptyBtn = gr.Button("🧹 新的对话",)
|
119 |
-
retryBtn = gr.Button("🔄 重新生成")
|
120 |
-
delLastBtn = gr.Button("🗑️ 删除最近一条对话")
|
121 |
-
reduceTokenBtn = gr.Button("♻️ 总结对话")
|
122 |
|
123 |
|
124 |
gr.HTML("""
|
@@ -149,13 +147,13 @@ with gr.Blocks(css=customCSS,) as demo:
|
|
149 |
|
150 |
historyRefreshBtn.click(get_history_names, None, [historyFileSelectDropdown])
|
151 |
|
152 |
-
|
153 |
|
154 |
templateRefreshBtn.click(get_template_names, None, [templateFileSelectDropdown])
|
155 |
|
156 |
-
|
157 |
|
158 |
-
|
159 |
|
160 |
logging.info(colorama.Back.GREEN + "\n川虎的温馨提示:访问 http://localhost:7860 查看界面" + colorama.Style.RESET_ALL)
|
161 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
|
|
56 |
""")
|
57 |
|
58 |
with gr.Row(scale=1).style(equal_height=True):
|
59 |
+
|
60 |
+
with gr.Column(scale=5):
|
61 |
+
with gr.Row(scale=1):
|
62 |
+
chatbot = gr.Chatbot().style(height=600) # .style(color_map=("#1D51EE", "#585A5B"))
|
63 |
+
with gr.Row(scale=1):
|
64 |
+
with gr.Column(scale=12):
|
65 |
+
user_input = gr.Textbox(show_label=False, placeholder="在这里输入").style(
|
66 |
+
container=False)
|
67 |
+
with gr.Column(min_width=50, scale=1):
|
68 |
+
submitBtn = gr.Button("🚀", variant="primary")
|
69 |
+
with gr.Row(scale=1):
|
70 |
+
emptyBtn = gr.Button("🧹 新的对话",)
|
71 |
+
retryBtn = gr.Button("🔄 重新生成")
|
72 |
+
delLastBtn = gr.Button("🗑️ 删除最近一条对话")
|
73 |
+
reduceTokenBtn = gr.Button("♻️ 总结对话")
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
with gr.Column():
|
78 |
with gr.Row(min_width=50,scale=1):
|
79 |
gr.HTML(title)
|
|
|
82 |
model_select_dropdown = gr.Dropdown(label="选择模型", choices=MODELS, multiselect=False, value=MODELS[0])
|
83 |
systemPromptTxt = gr.Textbox(show_label=True, placeholder=f"在这里输入System Prompt...", label="System prompt", value=initial_prompt).style(container=True)
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
with gr.Accordion(label="加载Prompt模板", open=False):
|
87 |
with gr.Column():
|
|
|
90 |
templateFileSelectDropdown = gr.Dropdown(label="选择Prompt模板集合文件", choices=get_template_names(plain=True), multiselect=False, value=get_template_names(plain=True)[0])
|
91 |
with gr.Column(scale=1):
|
92 |
templateRefreshBtn = gr.Button("🔄 刷新")
|
|
|
93 |
with gr.Row():
|
94 |
+
with gr.Column():
|
95 |
templateSelectDropdown = gr.Dropdown(label="从Prompt模板中加载", choices=load_template(get_template_names(plain=True)[0], mode=1), multiselect=False, value=load_template(get_template_names(plain=True)[0], mode=1)[0])
|
|
|
|
|
96 |
with gr.Accordion(label="保存/加载对话历史记录", open=False):
|
97 |
with gr.Column():
|
98 |
with gr.Row():
|
|
|
106 |
historyFileSelectDropdown = gr.Dropdown(label="从列表中加载对话", choices=get_history_names(plain=True), multiselect=False, value=get_history_names(plain=True)[0])
|
107 |
with gr.Column(scale=1):
|
108 |
historyRefreshBtn = gr.Button("🔄 刷新")
|
|
|
109 |
|
110 |
use_streaming_checkbox = gr.Checkbox(label="实时传输回答", value=True, visible=enable_streaming_option)
|
111 |
use_websearch_checkbox = gr.Checkbox(label="使用在线搜索", value=False)
|
112 |
|
113 |
|
114 |
+
with gr.Accordion("参数", open=False):
|
115 |
+
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.05,
|
116 |
+
interactive=True, label="Top-p (nucleus sampling)",)
|
117 |
+
temperature = gr.Slider(minimum=-0, maximum=5.0, value=1.0,
|
118 |
+
step=0.1, interactive=True, label="Temperature",)
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
|
122 |
gr.HTML("""
|
|
|
147 |
|
148 |
historyRefreshBtn.click(get_history_names, None, [historyFileSelectDropdown])
|
149 |
|
150 |
+
historyFileSelectDropdown.change(load_chat_history, [historyFileSelectDropdown, systemPromptTxt, history, chatbot], [saveFileName, systemPromptTxt, history, chatbot], show_progress=True)
|
151 |
|
152 |
templateRefreshBtn.click(get_template_names, None, [templateFileSelectDropdown])
|
153 |
|
154 |
+
templateFileSelectDropdown.change(load_template, [templateFileSelectDropdown], [promptTemplates, templateSelectDropdown], show_progress=True)
|
155 |
|
156 |
+
templateSelectDropdown.change(get_template_content, [promptTemplates, templateSelectDropdown, systemPromptTxt], [systemPromptTxt], show_progress=True)
|
157 |
|
158 |
logging.info(colorama.Back.GREEN + "\n川虎的温馨提示:访问 http://localhost:7860 查看界面" + colorama.Style.RESET_ALL)
|
159 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|