From 5497af1f5675bf411c3d9bc6166a41bcbb212477 Mon Sep 17 00:00:00 2001 From: Gaurav Shukla Date: Mon, 24 Jul 2023 22:48:03 +0530 Subject: [PATCH] [config] Add support for uploading sharding config file in chatbot (#1689) Signed-off-by: Gaurav Shukla --- apps/stable_diffusion/web/ui/stablelm_ui.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/stable_diffusion/web/ui/stablelm_ui.py b/apps/stable_diffusion/web/ui/stablelm_ui.py index 7e89930d4b..2cb490ce77 100644 --- a/apps/stable_diffusion/web/ui/stablelm_ui.py +++ b/apps/stable_diffusion/web/ui/stablelm_ui.py @@ -284,6 +284,13 @@ def llm_chat_api(InputData: dict): } +def view_json_file(file_obj): + content = "" + with open(file_obj.name, "r") as fopen: + content = fopen.read() + return content + + with gr.Blocks(title="Chatbot") as stablelm_chat: with gr.Row(): model_choices = list( @@ -319,6 +326,14 @@ def llm_chat_api(InputData: dict): ], visible=True, ) + with gr.Row(): + with gr.Group(): + config_file = gr.File(label="Upload sharding configuration") + json_view_button = gr.Button("View as JSON") + json_view = gr.JSON() + json_view_button.click( + fn=view_json_file, inputs=[config_file], outputs=[json_view] + ) chatbot = gr.Chatbot(height=500) with gr.Row(): with gr.Column():