Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -225,7 +225,9 @@ def gen_txt(editor):
|
|
| 225 |
gr.update(visible=False),
|
| 226 |
gr.update(visible=False),
|
| 227 |
gr.update(visible=False),
|
| 228 |
-
gr.update(interactive=True)
|
|
|
|
|
|
|
| 229 |
]
|
| 230 |
|
| 231 |
def gen_txt_with_prompt(editor, prompt):
|
|
@@ -236,7 +238,9 @@ def gen_txt_with_prompt(editor, prompt):
|
|
| 236 |
gr.update(visible=False),
|
| 237 |
gr.update(visible=False),
|
| 238 |
gr.update(visible=False),
|
| 239 |
-
gr.update(interactive=True)
|
|
|
|
|
|
|
| 240 |
]
|
| 241 |
|
| 242 |
def chat_gen(editor, chat_txt, chatbot, ppm, regen=False):
|
|
@@ -319,7 +323,10 @@ def gen_alt(editor, num_enabled_alts, alt_btn1, alt_btn2, alt_btn3):
|
|
| 319 |
gr.update(value=gen_txt if num_enabled_alts == 1 else alt_btn2),
|
| 320 |
gr.update(visible=True if num_enabled_alts >=2 else False),
|
| 321 |
gr.update(value=gen_txt if num_enabled_alts == 2 else alt_btn3),
|
| 322 |
-
" "
|
|
|
|
|
|
|
|
|
|
| 323 |
]
|
| 324 |
|
| 325 |
def fill_with_gen(alt_txt, editor):
|
|
@@ -395,10 +402,10 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 395 |
replace_sel_btn = gr.Button("replace selection", elem_classes=['control-label-font', 'control-button'])
|
| 396 |
replace_type = gr.Dropdown(choices=['word', 'sentense', 'phrase', 'paragraph'], value='sentense', interactive=True, elem_classes=['no-label'])
|
| 397 |
|
| 398 |
-
with gr.Row():
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
|
| 403 |
with gr.Tab("Chatting"):
|
| 404 |
chatbot = gr.Chatbot([], elem_classes=['no-label-chatbot'])
|
|
@@ -423,23 +430,33 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 423 |
)
|
| 424 |
|
| 425 |
gen_btn.click(
|
| 426 |
-
lambda: (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
inputs=None,
|
| 428 |
-
outputs=[gen_btn, gen_alt_btn]
|
| 429 |
).then(
|
| 430 |
fn=gen_txt,
|
| 431 |
inputs=[editor],
|
| 432 |
-
outputs=[editor, num_enabled_alts, gen_alt_btn, first_alt, second_alt, third_alt, gen_btn]
|
| 433 |
)
|
| 434 |
|
| 435 |
gen_alt_btn.click(
|
| 436 |
-
lambda:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
inputs=None,
|
| 438 |
-
outputs=[gen_alt_btn]
|
| 439 |
).then(
|
| 440 |
fn=gen_alt,
|
| 441 |
inputs=[editor, num_enabled_alts, alt_btn1, alt_btn2, alt_btn3],
|
| 442 |
-
outputs=[num_enabled_alts, gen_alt_btn, first_alt, alt_btn1, second_alt, alt_btn2, third_alt, alt_btn3, progress_bar],
|
| 443 |
)
|
| 444 |
|
| 445 |
alt_btn1.click(
|
|
@@ -467,7 +484,7 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 467 |
replace_sel_btn.click(
|
| 468 |
fn=replace_sel,
|
| 469 |
inputs=[editor, replace_type, selected_text, sel_index_from, sel_index_to],
|
| 470 |
-
outputs=[editor, selected_text, sel_index_from, sel_index_to
|
| 471 |
show_progress='minimal'
|
| 472 |
)
|
| 473 |
|
|
|
|
| 225 |
gr.update(visible=False),
|
| 226 |
gr.update(visible=False),
|
| 227 |
gr.update(visible=False),
|
| 228 |
+
gr.update(interactive=True),
|
| 229 |
+
gr.update(interactive=True),
|
| 230 |
+
gr.update(interactive=True),
|
| 231 |
]
|
| 232 |
|
| 233 |
def gen_txt_with_prompt(editor, prompt):
|
|
|
|
| 238 |
gr.update(visible=False),
|
| 239 |
gr.update(visible=False),
|
| 240 |
gr.update(visible=False),
|
| 241 |
+
gr.update(interactive=True),
|
| 242 |
+
gr.update(interactive=True),
|
| 243 |
+
gr.update(interactive=True),
|
| 244 |
]
|
| 245 |
|
| 246 |
def chat_gen(editor, chat_txt, chatbot, ppm, regen=False):
|
|
|
|
| 323 |
gr.update(value=gen_txt if num_enabled_alts == 1 else alt_btn2),
|
| 324 |
gr.update(visible=True if num_enabled_alts >=2 else False),
|
| 325 |
gr.update(value=gen_txt if num_enabled_alts == 2 else alt_btn3),
|
| 326 |
+
" ",
|
| 327 |
+
gr.update(interactive=True),
|
| 328 |
+
gr.update(interactive=True),
|
| 329 |
+
gr.update(interactive=True),
|
| 330 |
]
|
| 331 |
|
| 332 |
def fill_with_gen(alt_txt, editor):
|
|
|
|
| 402 |
replace_sel_btn = gr.Button("replace selection", elem_classes=['control-label-font', 'control-button'])
|
| 403 |
replace_type = gr.Dropdown(choices=['word', 'sentense', 'phrase', 'paragraph'], value='sentense', interactive=True, elem_classes=['no-label'])
|
| 404 |
|
| 405 |
+
# with gr.Row():
|
| 406 |
+
# with gr.Column(elem_classes=['no-gap']):
|
| 407 |
+
# rewrite_sel_btn = gr.Button("rewrite selection", elem_classes=['control-label-font', 'control-button'])
|
| 408 |
+
# rewrite_prompt = gr.Textbox(placeholder="Rewrite the text: ", elem_classes=['no-label'])
|
| 409 |
|
| 410 |
with gr.Tab("Chatting"):
|
| 411 |
chatbot = gr.Chatbot([], elem_classes=['no-label-chatbot'])
|
|
|
|
| 430 |
)
|
| 431 |
|
| 432 |
gen_btn.click(
|
| 433 |
+
lambda: (
|
| 434 |
+
gr.update(interactive=False),
|
| 435 |
+
gr.update(interactive=False),
|
| 436 |
+
gr.update(interactive=False),
|
| 437 |
+
gr.update(interactive=False),
|
| 438 |
+
),
|
| 439 |
inputs=None,
|
| 440 |
+
outputs=[gen_btn, gen_alt_btn, gen_with_prompt_btn, replace_sel_btn]
|
| 441 |
).then(
|
| 442 |
fn=gen_txt,
|
| 443 |
inputs=[editor],
|
| 444 |
+
outputs=[editor, num_enabled_alts, gen_alt_btn, first_alt, second_alt, third_alt, gen_btn, gen_with_prompt_btn, replace_sel_btn]
|
| 445 |
)
|
| 446 |
|
| 447 |
gen_alt_btn.click(
|
| 448 |
+
lambda: (
|
| 449 |
+
gr.update(interactive=False),
|
| 450 |
+
gr.update(interactive=False),
|
| 451 |
+
gr.update(interactive=False),
|
| 452 |
+
gr.update(interactive=False),
|
| 453 |
+
),
|
| 454 |
inputs=None,
|
| 455 |
+
outputs=[gen_btn, gen_alt_btn, gen_with_prompt_btn, replace_sel_btn]
|
| 456 |
).then(
|
| 457 |
fn=gen_alt,
|
| 458 |
inputs=[editor, num_enabled_alts, alt_btn1, alt_btn2, alt_btn3],
|
| 459 |
+
outputs=[num_enabled_alts, gen_alt_btn, first_alt, alt_btn1, second_alt, alt_btn2, third_alt, alt_btn3, progress_bar, gen_btn, gen_with_prompt_btn, replace_sel_btn],
|
| 460 |
)
|
| 461 |
|
| 462 |
alt_btn1.click(
|
|
|
|
| 484 |
replace_sel_btn.click(
|
| 485 |
fn=replace_sel,
|
| 486 |
inputs=[editor, replace_type, selected_text, sel_index_from, sel_index_to],
|
| 487 |
+
outputs=[editor, selected_text, sel_index_from, sel_index_to],
|
| 488 |
show_progress='minimal'
|
| 489 |
)
|
| 490 |
|