Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -133,10 +133,6 @@ STYLES = """
|
|
| 133 |
text-align: justify !important;
|
| 134 |
}
|
| 135 |
|
| 136 |
-
.wrap {
|
| 137 |
-
display: contents !important;
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
.white-text {
|
| 141 |
color: #000 !important;
|
| 142 |
}
|
|
@@ -228,7 +224,8 @@ def gen_txt(editor):
|
|
| 228 |
gr.update(interactive=True),
|
| 229 |
gr.update(visible=False),
|
| 230 |
gr.update(visible=False),
|
| 231 |
-
gr.update(visible=False)
|
|
|
|
| 232 |
]
|
| 233 |
|
| 234 |
def gen_txt_with_prompt(editor, prompt):
|
|
@@ -238,7 +235,8 @@ def gen_txt_with_prompt(editor, prompt):
|
|
| 238 |
gr.update(interactive=True),
|
| 239 |
gr.update(visible=False),
|
| 240 |
gr.update(visible=False),
|
| 241 |
-
gr.update(visible=False)
|
|
|
|
| 242 |
]
|
| 243 |
|
| 244 |
def chat_gen(editor, chat_txt, chatbot, ppm, regen=False):
|
|
@@ -321,6 +319,7 @@ def gen_alt(editor, num_enabled_alts, alt_btn1, alt_btn2, alt_btn3):
|
|
| 321 |
gr.update(value=gen_txt if num_enabled_alts == 1 else alt_btn2),
|
| 322 |
gr.update(visible=True if num_enabled_alts >=2 else False),
|
| 323 |
gr.update(value=gen_txt if num_enabled_alts == 2 else alt_btn3),
|
|
|
|
| 324 |
]
|
| 325 |
|
| 326 |
def fill_with_gen(alt_txt, editor):
|
|
@@ -349,6 +348,8 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 349 |
"be changed over time, but [meta-llama/Llama-2-70b-chat-hf](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf) is selected for now.",
|
| 350 |
elem_classes=['center', 'small-big'])
|
| 351 |
|
|
|
|
|
|
|
| 352 |
with gr.Row():
|
| 353 |
with gr.Column(scale=2):
|
| 354 |
editor = gr.Textbox(lines=32, max_lines=32, elem_classes=['no-label', 'small-big-textarea'])
|
|
@@ -367,15 +368,15 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 367 |
with gr.Column():
|
| 368 |
with gr.Row(visible=False) as first_alt:
|
| 369 |
gr.Markdown("↳", scale=1, elem_classes=['wrap'])
|
| 370 |
-
alt_btn1 = gr.Button("Alternative 1", elem_classes=['alt-button'], scale=
|
| 371 |
|
| 372 |
with gr.Row(visible=False) as second_alt:
|
| 373 |
gr.Markdown("↳", scale=1, elem_classes=['wrap'])
|
| 374 |
-
alt_btn2 = gr.Button("Alternative 2", elem_classes=['alt-button'], scale=
|
| 375 |
|
| 376 |
with gr.Row(visible=False) as third_alt:
|
| 377 |
gr.Markdown("↳", scale=1, elem_classes=['wrap'])
|
| 378 |
-
alt_btn3 = gr.Button("Alternative 3", elem_classes=['alt-button'], scale=
|
| 379 |
|
| 380 |
with gr.Row(elem_classes=['group-border']):
|
| 381 |
with gr.Column():
|
|
@@ -422,15 +423,23 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 422 |
)
|
| 423 |
|
| 424 |
gen_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
fn=gen_txt,
|
| 426 |
inputs=[editor],
|
| 427 |
-
outputs=[editor, num_enabled_alts, gen_alt_btn, first_alt, second_alt, third_alt]
|
| 428 |
)
|
| 429 |
|
| 430 |
gen_alt_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
fn=gen_alt,
|
| 432 |
inputs=[editor, num_enabled_alts, alt_btn1, alt_btn2, alt_btn3],
|
| 433 |
-
outputs=[num_enabled_alts, gen_alt_btn, first_alt, alt_btn1, second_alt, alt_btn2, third_alt, alt_btn3],
|
| 434 |
)
|
| 435 |
|
| 436 |
alt_btn1.click(
|
|
@@ -458,7 +467,7 @@ with gr.Blocks(css=STYLES) as demo:
|
|
| 458 |
replace_sel_btn.click(
|
| 459 |
fn=replace_sel,
|
| 460 |
inputs=[editor, replace_type, selected_text, sel_index_from, sel_index_to],
|
| 461 |
-
outputs=[editor, selected_text, sel_index_from, sel_index_to],
|
| 462 |
show_progress='minimal'
|
| 463 |
)
|
| 464 |
|
|
|
|
| 133 |
text-align: justify !important;
|
| 134 |
}
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
.white-text {
|
| 137 |
color: #000 !important;
|
| 138 |
}
|
|
|
|
| 224 |
gr.update(interactive=True),
|
| 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):
|
|
|
|
| 235 |
gr.update(interactive=True),
|
| 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 |
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):
|
|
|
|
| 348 |
"be changed over time, but [meta-llama/Llama-2-70b-chat-hf](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf) is selected for now.",
|
| 349 |
elem_classes=['center', 'small-big'])
|
| 350 |
|
| 351 |
+
progress_bar = gr.Textbox(elem_classes=['no-label'])
|
| 352 |
+
|
| 353 |
with gr.Row():
|
| 354 |
with gr.Column(scale=2):
|
| 355 |
editor = gr.Textbox(lines=32, max_lines=32, elem_classes=['no-label', 'small-big-textarea'])
|
|
|
|
| 368 |
with gr.Column():
|
| 369 |
with gr.Row(visible=False) as first_alt:
|
| 370 |
gr.Markdown("↳", scale=1, elem_classes=['wrap'])
|
| 371 |
+
alt_btn1 = gr.Button("Alternative 1", elem_classes=['alt-button'], scale=8)
|
| 372 |
|
| 373 |
with gr.Row(visible=False) as second_alt:
|
| 374 |
gr.Markdown("↳", scale=1, elem_classes=['wrap'])
|
| 375 |
+
alt_btn2 = gr.Button("Alternative 2", elem_classes=['alt-button'], scale=8)
|
| 376 |
|
| 377 |
with gr.Row(visible=False) as third_alt:
|
| 378 |
gr.Markdown("↳", scale=1, elem_classes=['wrap'])
|
| 379 |
+
alt_btn3 = gr.Button("Alternative 3", elem_classes=['alt-button'], scale=8)
|
| 380 |
|
| 381 |
with gr.Row(elem_classes=['group-border']):
|
| 382 |
with gr.Column():
|
|
|
|
| 423 |
)
|
| 424 |
|
| 425 |
gen_btn.click(
|
| 426 |
+
lambda: (gr.update(interactive=False), gr.update(interactive=False)),
|
| 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: gr.update(interactive=False),
|
| 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 |
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, progress_bar],
|
| 471 |
show_progress='minimal'
|
| 472 |
)
|
| 473 |
|