Update app/webui/app.py
Browse files- app/webui/app.py +17 -0
app/webui/app.py
CHANGED
|
@@ -114,6 +114,13 @@ def switch(source_lang,source_text,target_lang,output_final):
|
|
| 114 |
else:
|
| 115 |
return gr.update(value=target_lang), gr.update(value=source_text), gr.update(value=source_lang), gr.update(value="")
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
TITLE = """
|
| 118 |
<div style="display: inline-flex;">
|
| 119 |
<div style="margin-left: 6px; font-size:32px; color: #6366f1"><b>Translation Agent</b> WebUI</div>
|
|
@@ -265,14 +272,24 @@ with gr.Blocks(theme="soft", css=CSS, fill_height=True) as demo:
|
|
| 265 |
upload = gr.UploadButton(label="Upload", file_types=["text"])
|
| 266 |
export = gr.DownloadButton(visible=False)
|
| 267 |
clear = gr.ClearButton([source_text, output_init, output_reflect, output_final])
|
|
|
|
| 268 |
|
| 269 |
switchBtn.click(fn=switch, inputs=[source_lang,source_text,target_lang,output_final], outputs=[source_lang,source_text,target_lang,output_final])
|
|
|
|
| 270 |
menuBtn.click(fn=update_menu, inputs=visible, outputs=[visible, menubar], js=JS)
|
| 271 |
endpoint.change(fn=update_model, inputs=[endpoint], outputs=[model])
|
|
|
|
| 272 |
choice.select(fn=enable_sec, inputs=[choice], outputs=[endpoint2, model2, api_key2])
|
| 273 |
endpoint2.change(fn=update_model, inputs=[endpoint2], outputs=[model2])
|
|
|
|
| 274 |
submit.click(fn=huanik, inputs=[endpoint, model, api_key, choice, endpoint2, model2, api_key2, source_lang, target_lang, source_text, country, max_tokens, context_window, num_output, rpm], outputs=[output_init, output_reflect, output_final, output_diff])
|
|
|
|
| 275 |
upload.upload(fn=read_doc, inputs = upload, outputs = source_text)
|
| 276 |
output_final.change(fn=export_txt, inputs=output_final, outputs=[export])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
if __name__ == "__main__":
|
| 278 |
demo.queue(api_open=False).launch(show_api=False, share=False)
|
|
|
|
| 114 |
else:
|
| 115 |
return gr.update(value=target_lang), gr.update(value=source_text), gr.update(value=source_lang), gr.update(value="")
|
| 116 |
|
| 117 |
+
def closeBtnShow():
|
| 118 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 119 |
+
|
| 120 |
+
def closeBtnHide(output_final):
|
| 121 |
+
if output_final:
|
| 122 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 123 |
+
|
| 124 |
TITLE = """
|
| 125 |
<div style="display: inline-flex;">
|
| 126 |
<div style="margin-left: 6px; font-size:32px; color: #6366f1"><b>Translation Agent</b> WebUI</div>
|
|
|
|
| 272 |
upload = gr.UploadButton(label="Upload", file_types=["text"])
|
| 273 |
export = gr.DownloadButton(visible=False)
|
| 274 |
clear = gr.ClearButton([source_text, output_init, output_reflect, output_final])
|
| 275 |
+
close = gr.Button(value="Stop", visible=False)
|
| 276 |
|
| 277 |
switchBtn.click(fn=switch, inputs=[source_lang,source_text,target_lang,output_final], outputs=[source_lang,source_text,target_lang,output_final])
|
| 278 |
+
|
| 279 |
menuBtn.click(fn=update_menu, inputs=visible, outputs=[visible, menubar], js=JS)
|
| 280 |
endpoint.change(fn=update_model, inputs=[endpoint], outputs=[model])
|
| 281 |
+
|
| 282 |
choice.select(fn=enable_sec, inputs=[choice], outputs=[endpoint2, model2, api_key2])
|
| 283 |
endpoint2.change(fn=update_model, inputs=[endpoint2], outputs=[model2])
|
| 284 |
+
|
| 285 |
submit.click(fn=huanik, inputs=[endpoint, model, api_key, choice, endpoint2, model2, api_key2, source_lang, target_lang, source_text, country, max_tokens, context_window, num_output, rpm], outputs=[output_init, output_reflect, output_final, output_diff])
|
| 286 |
+
|
| 287 |
upload.upload(fn=read_doc, inputs = upload, outputs = source_text)
|
| 288 |
output_final.change(fn=export_txt, inputs=output_final, outputs=[export])
|
| 289 |
+
|
| 290 |
+
submit.click(fn=closeBtnShow, outputs=[clear, close])
|
| 291 |
+
output_final.change(fn=closeBtnHide, inputs=output_final, outputs=[clear, close])
|
| 292 |
+
close.click(fn=None, cancels=start_ta)
|
| 293 |
+
|
| 294 |
if __name__ == "__main__":
|
| 295 |
demo.queue(api_open=False).launch(show_api=False, share=False)
|