Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -280,14 +280,6 @@ def read_uploaded_file(file):
|
|
| 280 |
def init_msg():
|
| 281 |
return "ํ์ผ์ ๋ถ์ํ๊ณ ์์ต๋๋ค..."
|
| 282 |
|
| 283 |
-
file_upload.change(
|
| 284 |
-
init_msg,
|
| 285 |
-
outputs=msg
|
| 286 |
-
).then(
|
| 287 |
-
stream_chat,
|
| 288 |
-
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
|
| 289 |
-
outputs=[msg, chatbot]
|
| 290 |
-
)
|
| 291 |
|
| 292 |
|
| 293 |
@spaces.GPU
|
|
@@ -526,68 +518,67 @@ body {
|
|
| 526 |
}
|
| 527 |
"""
|
| 528 |
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
with
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
)
|
| 539 |
-
|
| 540 |
-
with gr.Row(elem_classes="input-container"):
|
| 541 |
-
with gr.Column(scale=1, min_width=70):
|
| 542 |
-
file_upload = gr.File(
|
| 543 |
-
type="filepath",
|
| 544 |
-
elem_classes="file-upload-icon",
|
| 545 |
-
scale=1,
|
| 546 |
-
container=True,
|
| 547 |
-
interactive=True,
|
| 548 |
-
show_label=False
|
| 549 |
-
)
|
| 550 |
|
| 551 |
-
with gr.
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
with gr.Column(scale=1, min_width=70):
|
| 561 |
-
send = gr.Button(
|
| 562 |
-
"์ ์ก",
|
| 563 |
-
elem_classes="send-button custom-button",
|
| 564 |
-
scale=1
|
| 565 |
-
)
|
| 566 |
-
|
| 567 |
-
with gr.Accordion("๐ฎ ๊ณ ๊ธ ์ค์ ", open=False):
|
| 568 |
-
with gr.Row():
|
| 569 |
-
with gr.Column(scale=1):
|
| 570 |
-
temperature = gr.Slider(
|
| 571 |
-
minimum=0, maximum=1, step=0.1, value=0.8,
|
| 572 |
-
label="์ฐฝ์์ฑ ์์ค ๐จ"
|
| 573 |
-
)
|
| 574 |
-
max_new_tokens = gr.Slider(
|
| 575 |
-
minimum=128, maximum=8000, step=1, value=4000,
|
| 576 |
-
label="์ต๋ ํ ํฐ ์ ๐"
|
| 577 |
-
)
|
| 578 |
-
with gr.Column(scale=1):
|
| 579 |
-
top_p = gr.Slider(
|
| 580 |
-
minimum=0.0, maximum=1.0, step=0.1, value=0.8,
|
| 581 |
-
label="๋ค์์ฑ ์กฐ์ ๐ฏ"
|
| 582 |
)
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
)
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
|
|
|
|
|
|
|
|
|
| 590 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 591 |
|
| 592 |
|
| 593 |
gr.Examples(
|
|
@@ -603,30 +594,30 @@ with demo:
|
|
| 603 |
inputs=msg
|
| 604 |
)
|
| 605 |
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
)
|
| 630 |
|
| 631 |
if __name__ == "__main__":
|
|
|
|
| 632 |
demo.launch()
|
|
|
|
| 280 |
def init_msg():
|
| 281 |
return "ํ์ผ์ ๋ถ์ํ๊ณ ์์ต๋๋ค..."
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
|
| 285 |
@spaces.GPU
|
|
|
|
| 518 |
}
|
| 519 |
"""
|
| 520 |
|
| 521 |
+
def create_demo():
|
| 522 |
+
with gr.Blocks(css=CSS) as demo:
|
| 523 |
+
with gr.Column():
|
| 524 |
+
chatbot = gr.Chatbot(
|
| 525 |
+
value=[],
|
| 526 |
+
height=600,
|
| 527 |
+
label="GiniGEN AI Assistant",
|
| 528 |
+
elem_classes="chat-container"
|
| 529 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
|
| 531 |
+
with gr.Row(elem_classes="input-container"):
|
| 532 |
+
with gr.Column(scale=1, min_width=70):
|
| 533 |
+
file_upload = gr.File(
|
| 534 |
+
type="filepath",
|
| 535 |
+
elem_classes="file-upload-icon",
|
| 536 |
+
scale=1,
|
| 537 |
+
container=True,
|
| 538 |
+
interactive=True,
|
| 539 |
+
show_label=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
)
|
| 541 |
+
|
| 542 |
+
with gr.Column(scale=4):
|
| 543 |
+
msg = gr.Textbox(
|
| 544 |
+
show_label=False,
|
| 545 |
+
placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์... ๐ญ",
|
| 546 |
+
container=False,
|
| 547 |
+
elem_classes="input-textbox",
|
| 548 |
+
scale=1
|
| 549 |
)
|
| 550 |
+
|
| 551 |
+
with gr.Column(scale=1, min_width=70):
|
| 552 |
+
send = gr.Button(
|
| 553 |
+
"์ ์ก",
|
| 554 |
+
elem_classes="send-button custom-button",
|
| 555 |
+
scale=1
|
| 556 |
)
|
| 557 |
+
|
| 558 |
+
with gr.Accordion("๐ฎ ๊ณ ๊ธ ์ค์ ", open=False):
|
| 559 |
+
with gr.Row():
|
| 560 |
+
with gr.Column(scale=1):
|
| 561 |
+
temperature = gr.Slider(
|
| 562 |
+
minimum=0, maximum=1, step=0.1, value=0.8,
|
| 563 |
+
label="์ฐฝ์์ฑ ์์ค ๐จ"
|
| 564 |
+
)
|
| 565 |
+
max_new_tokens = gr.Slider(
|
| 566 |
+
minimum=128, maximum=8000, step=1, value=4000,
|
| 567 |
+
label="์ต๋ ํ ํฐ ์ ๐"
|
| 568 |
+
)
|
| 569 |
+
with gr.Column(scale=1):
|
| 570 |
+
top_p = gr.Slider(
|
| 571 |
+
minimum=0.0, maximum=1.0, step=0.1, value=0.8,
|
| 572 |
+
label="๋ค์์ฑ ์กฐ์ ๐ฏ"
|
| 573 |
+
)
|
| 574 |
+
top_k = gr.Slider(
|
| 575 |
+
minimum=1, maximum=20, step=1, value=20,
|
| 576 |
+
label="์ ํ ๋ฒ์ ๐"
|
| 577 |
+
)
|
| 578 |
+
penalty = gr.Slider(
|
| 579 |
+
minimum=0.0, maximum=2.0, step=0.1, value=1.0,
|
| 580 |
+
label="๋ฐ๋ณต ์ต์ ๐"
|
| 581 |
+
)
|
| 582 |
|
| 583 |
|
| 584 |
gr.Examples(
|
|
|
|
| 594 |
inputs=msg
|
| 595 |
)
|
| 596 |
|
| 597 |
+
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
|
| 598 |
+
msg.submit(
|
| 599 |
+
stream_chat,
|
| 600 |
+
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
|
| 601 |
+
outputs=[msg, chatbot]
|
| 602 |
+
)
|
| 603 |
+
|
| 604 |
+
send.click(
|
| 605 |
+
stream_chat,
|
| 606 |
+
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
|
| 607 |
+
outputs=[msg, chatbot]
|
| 608 |
+
)
|
| 609 |
+
|
| 610 |
+
file_upload.change(
|
| 611 |
+
init_msg,
|
| 612 |
+
outputs=msg
|
| 613 |
+
).then(
|
| 614 |
+
stream_chat,
|
| 615 |
+
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
|
| 616 |
+
outputs=[msg, chatbot]
|
| 617 |
+
)
|
| 618 |
+
|
| 619 |
+
return demo
|
|
|
|
| 620 |
|
| 621 |
if __name__ == "__main__":
|
| 622 |
+
demo = create_demo()
|
| 623 |
demo.launch()
|