Spaces:
Running
Running
修复备选输入区+文件上传的BUG
Browse files- main.py +1 -1
- toolbox.py +8 -3
main.py
CHANGED
@@ -143,7 +143,7 @@ def main():
|
|
143 |
click_handle = functional[k]["Button"].click(fn=ArgsGeneralWrapper(predict), inputs=[*input_combo, gr.State(True), gr.State(k)], outputs=output_combo)
|
144 |
cancel_handles.append(click_handle)
|
145 |
# 文件上传区,接收文件后与chatbot的互动
|
146 |
-
file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt])
|
147 |
# 函数插件-固定按钮区
|
148 |
for k in crazy_fns:
|
149 |
if not crazy_fns[k].get("AsButton", True): continue
|
|
|
143 |
click_handle = functional[k]["Button"].click(fn=ArgsGeneralWrapper(predict), inputs=[*input_combo, gr.State(True), gr.State(k)], outputs=output_combo)
|
144 |
cancel_handles.append(click_handle)
|
145 |
# 文件上传区,接收文件后与chatbot的互动
|
146 |
+
file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt, txt2, checkboxes], [chatbot, txt, txt2])
|
147 |
# 函数插件-固定按钮区
|
148 |
for k in crazy_fns:
|
149 |
if not crazy_fns[k].get("AsButton", True): continue
|
toolbox.py
CHANGED
@@ -370,7 +370,7 @@ def find_recent_files(directory):
|
|
370 |
return recent_files
|
371 |
|
372 |
|
373 |
-
def on_file_uploaded(files, chatbot, txt):
|
374 |
if len(files) == 0:
|
375 |
return chatbot, txt
|
376 |
import shutil
|
@@ -392,13 +392,18 @@ def on_file_uploaded(files, chatbot, txt):
|
|
392 |
dest_dir=f'private_upload/{time_tag}/{file_origin_name}.extract')
|
393 |
moved_files = [fp for fp in glob.glob(
|
394 |
'private_upload/**/*', recursive=True)]
|
395 |
-
|
|
|
|
|
|
|
|
|
|
|
396 |
moved_files_str = '\t\n\n'.join(moved_files)
|
397 |
chatbot.append(['我上传了文件,请查收',
|
398 |
f'[Local Message] 收到以下文件: \n\n{moved_files_str}' +
|
399 |
f'\n\n调用路径参数已自动修正到: \n\n{txt}' +
|
400 |
f'\n\n现在您点击任意实验功能时,以上文件将被作为输入参数'+err_msg])
|
401 |
-
return chatbot, txt
|
402 |
|
403 |
|
404 |
def on_report_generated(files, chatbot):
|
|
|
370 |
return recent_files
|
371 |
|
372 |
|
373 |
+
def on_file_uploaded(files, chatbot, txt, txt2, checkboxes):
|
374 |
if len(files) == 0:
|
375 |
return chatbot, txt
|
376 |
import shutil
|
|
|
392 |
dest_dir=f'private_upload/{time_tag}/{file_origin_name}.extract')
|
393 |
moved_files = [fp for fp in glob.glob(
|
394 |
'private_upload/**/*', recursive=True)]
|
395 |
+
if "底部输入区" in checkboxes:
|
396 |
+
txt = ""
|
397 |
+
txt2 = f'private_upload/{time_tag}'
|
398 |
+
else:
|
399 |
+
txt = f'private_upload/{time_tag}'
|
400 |
+
txt2 = ""
|
401 |
moved_files_str = '\t\n\n'.join(moved_files)
|
402 |
chatbot.append(['我上传了文件,请查收',
|
403 |
f'[Local Message] 收到以下文件: \n\n{moved_files_str}' +
|
404 |
f'\n\n调用路径参数已自动修正到: \n\n{txt}' +
|
405 |
f'\n\n现在您点击任意实验功能时,以上文件将被作为输入参数'+err_msg])
|
406 |
+
return chatbot, txt, txt2
|
407 |
|
408 |
|
409 |
def on_report_generated(files, chatbot):
|