Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
401c21c
1
Parent(s):
6223547
feat: 在文件 ID 为空是不允许点击训练按钮
Browse files- ChuanhuChatbot.py +6 -5
ChuanhuChatbot.py
CHANGED
@@ -188,18 +188,18 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
188 |
downloadFile = gr.File(interactive=True)
|
189 |
|
190 |
with gr.Tab(label=i18n("训练")):
|
191 |
-
with gr.
|
192 |
dataset_preview_json = gr.JSON(label=i18n("数据集预览"), readonly=True)
|
193 |
dataset_selection = gr.Files(label = i18n("选择数据集"), file_types=[".xlsx", ".jsonl"], file_count="single")
|
194 |
-
upload_to_openai_btn = gr.Button(i18n("上传到OpenAI"), interactive=False)
|
195 |
|
196 |
-
with gr.
|
197 |
openai_ft_file_id = gr.Textbox(label=i18n("文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
|
198 |
openai_ft_suffix = gr.Textbox(label=i18n("模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
199 |
openai_train_epoch_slider = gr.Slider(label=i18n("训练轮数"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
200 |
-
openai_start_train_btn = gr.Button(i18n("开始训练"), variant="primary")
|
201 |
|
202 |
-
with gr.
|
203 |
openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n("未开始训练"))
|
204 |
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
205 |
openai_cancel_all_jobs_btn = gr.Button(i18n("取消所有任务"))
|
@@ -497,6 +497,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
497 |
dataset_selection.upload(handle_dataset_selection, dataset_selection, [dataset_preview_json, upload_to_openai_btn, status_display])
|
498 |
dataset_selection.clear(handle_dataset_clear, [], [dataset_preview_json, upload_to_openai_btn])
|
499 |
upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [openai_ft_file_id, status_display], show_progress=True)
|
|
|
500 |
openai_start_train_btn.click(start_training, [openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
|
501 |
openai_status_refresh_btn.click(get_training_status, [], [openai_train_status, add_to_models_btn])
|
502 |
add_to_models_btn.click(add_to_models, [], [model_select_dropdown, status_display], show_progress=True)
|
|
|
188 |
downloadFile = gr.File(interactive=True)
|
189 |
|
190 |
with gr.Tab(label=i18n("训练")):
|
191 |
+
with gr.Tab(label=i18n("准备数据集")):
|
192 |
dataset_preview_json = gr.JSON(label=i18n("数据集预览"), readonly=True)
|
193 |
dataset_selection = gr.Files(label = i18n("选择数据集"), file_types=[".xlsx", ".jsonl"], file_count="single")
|
194 |
+
upload_to_openai_btn = gr.Button(i18n("上传到OpenAI"), variant="primary", interactive=False)
|
195 |
|
196 |
+
with gr.Tab(label=i18n("训练")):
|
197 |
openai_ft_file_id = gr.Textbox(label=i18n("文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
|
198 |
openai_ft_suffix = gr.Textbox(label=i18n("模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
199 |
openai_train_epoch_slider = gr.Slider(label=i18n("训练轮数"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
200 |
+
openai_start_train_btn = gr.Button(i18n("开始训练"), variant="primary", interactive=False)
|
201 |
|
202 |
+
with gr.Tab(label=i18n("状态")):
|
203 |
openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n("未开始训练"))
|
204 |
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
205 |
openai_cancel_all_jobs_btn = gr.Button(i18n("取消所有任务"))
|
|
|
497 |
dataset_selection.upload(handle_dataset_selection, dataset_selection, [dataset_preview_json, upload_to_openai_btn, status_display])
|
498 |
dataset_selection.clear(handle_dataset_clear, [], [dataset_preview_json, upload_to_openai_btn])
|
499 |
upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [openai_ft_file_id, status_display], show_progress=True)
|
500 |
+
openai_ft_file_id.change(lambda x: gr.update(interactive=True) if len(x) > 0 else gr.update(interactive=False), [openai_ft_file_id], [openai_start_train_btn])
|
501 |
openai_start_train_btn.click(start_training, [openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
|
502 |
openai_status_refresh_btn.click(get_training_status, [], [openai_train_status, add_to_models_btn])
|
503 |
add_to_models_btn.click(add_to_models, [], [model_select_dropdown, status_display], show_progress=True)
|