Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -193,20 +193,20 @@ def main():
|
|
193 |
clearBtn2.click(lambda: ("",""), None, [txt, txt2])
|
194 |
# 基础功能区的回调函数注册
|
195 |
for k in functional:
|
196 |
-
if ("Visible" in functional[k]) and (not functional[k]
|
197 |
-
click_handle = functional[k]
|
198 |
cancel_handles.append(click_handle)
|
199 |
# 文件上传区,接收文件后与chatbot的互动
|
200 |
file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt, txt2, checkboxes], [chatbot, txt, txt2])
|
201 |
# 函数插件-固定按钮区
|
202 |
for k in crazy_fns:
|
203 |
if not crazy_fns[k].get("AsButton", True): continue
|
204 |
-
click_handle = crazy_fns[k]
|
205 |
click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot])
|
206 |
cancel_handles.append(click_handle)
|
207 |
# 函数插件-下拉菜单与随变按钮的互动
|
208 |
def on_dropdown_changed(k):
|
209 |
-
variant = crazy_fns[k]
|
210 |
ret = {switchy_bt: gr.update(value=k, variant=variant)}
|
211 |
if crazy_fns[k].get("AdvancedArgs", False): # 是否唤起高级插件参数区
|
212 |
ret.update({plugin_advanced_arg: gr.update(visible=True, label=f"插件[{k}]的高级参数说明:" + crazy_fns[k].get("ArgsReminder", [f"没有提供高级参数功能说明"]))})
|
@@ -220,7 +220,7 @@ def main():
|
|
220 |
# 随变按钮的回调函数注册
|
221 |
def route(k, *args, **kwargs):
|
222 |
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
|
223 |
-
yield from ArgsGeneralWrapper(crazy_fns[k]
|
224 |
click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo)
|
225 |
click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot])
|
226 |
cancel_handles.append(click_handle)
|
@@ -244,7 +244,7 @@ def main():
|
|
244 |
threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start()
|
245 |
|
246 |
auto_opentab_delay()
|
247 |
-
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False, favicon_path="docs/logo.png", blocked_paths=
|
248 |
|
249 |
# 如果需要在二级路径下运行
|
250 |
# CUSTOM_PATH, = get_conf('CUSTOM_PATH')
|
@@ -253,7 +253,7 @@ def main():
|
|
253 |
# run_gradio_in_subpath(demo, auth=AUTHENTICATION, port=PORT, custom_path=CUSTOM_PATH)
|
254 |
# else:
|
255 |
# demo.launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png",
|
256 |
-
# blocked_paths=
|
257 |
|
258 |
if __name__ == "__main__":
|
259 |
main()
|
|
|
193 |
clearBtn2.click(lambda: ("",""), None, [txt, txt2])
|
194 |
# 基础功能区的回调函数注册
|
195 |
for k in functional:
|
196 |
+
if ("Visible" in functional[k]) and (not functional[k]["Visible"]): continue
|
197 |
+
click_handle = functional[k]["Button"].click(fn=ArgsGeneralWrapper(predict), inputs=[*input_combo, gr.State(True), gr.State(k)], outputs=output_combo)
|
198 |
cancel_handles.append(click_handle)
|
199 |
# 文件上传区,接收文件后与chatbot的互动
|
200 |
file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt, txt2, checkboxes], [chatbot, txt, txt2])
|
201 |
# 函数插件-固定按钮区
|
202 |
for k in crazy_fns:
|
203 |
if not crazy_fns[k].get("AsButton", True): continue
|
204 |
+
click_handle = crazy_fns[k]["Button"].click(ArgsGeneralWrapper(crazy_fns[k]["Function"]), [*input_combo, gr.State(PORT)], output_combo)
|
205 |
click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot])
|
206 |
cancel_handles.append(click_handle)
|
207 |
# 函数插件-下拉菜单与随变按钮的互动
|
208 |
def on_dropdown_changed(k):
|
209 |
+
variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
|
210 |
ret = {switchy_bt: gr.update(value=k, variant=variant)}
|
211 |
if crazy_fns[k].get("AdvancedArgs", False): # 是否唤起高级插件参数区
|
212 |
ret.update({plugin_advanced_arg: gr.update(visible=True, label=f"插件[{k}]的高级参数说明:" + crazy_fns[k].get("ArgsReminder", [f"没有提供高级参数功能说明"]))})
|
|
|
220 |
# 随变按钮的回调函数注册
|
221 |
def route(k, *args, **kwargs):
|
222 |
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
|
223 |
+
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs)
|
224 |
click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo)
|
225 |
click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot])
|
226 |
cancel_handles.append(click_handle)
|
|
|
244 |
threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start()
|
245 |
|
246 |
auto_opentab_delay()
|
247 |
+
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False, favicon_path="docs/logo.png", blocked_paths=["config.py","config_private.py","docker-compose.yml","Dockerfile"])
|
248 |
|
249 |
# 如果需要在二级路径下运行
|
250 |
# CUSTOM_PATH, = get_conf('CUSTOM_PATH')
|
|
|
253 |
# run_gradio_in_subpath(demo, auth=AUTHENTICATION, port=PORT, custom_path=CUSTOM_PATH)
|
254 |
# else:
|
255 |
# demo.launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png",
|
256 |
+
# blocked_paths=["config.py","config_private.py","docker-compose.yml","Dockerfile"])
|
257 |
|
258 |
if __name__ == "__main__":
|
259 |
main()
|