Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -370,8 +370,6 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 370 |
|
| 371 |
with ms.Application() as app:
|
| 372 |
with antd.ConfigProvider():
|
| 373 |
-
|
| 374 |
-
|
| 375 |
# Drawer ์ปดํฌ๋ํธ๋ค
|
| 376 |
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
| 377 |
code_output = legacy.Markdown()
|
|
@@ -379,11 +377,30 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 379 |
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
| 380 |
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
| 381 |
|
| 382 |
-
with antd.Drawer(
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
|
| 388 |
# ๋ฉ์ธ ์ปจํ
์ธ ๋ฅผ ์ํ Row
|
| 389 |
with antd.Row(gutter=[32, 12]) as layout:
|
|
@@ -521,15 +538,6 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 521 |
historyBtn = antd.Button("๐ history", type="default")
|
| 522 |
sessionBtn = antd.Button("๐ sessions", type="default")
|
| 523 |
|
| 524 |
-
# ์ธ์
๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
| 525 |
-
sessionBtn.click(
|
| 526 |
-
lambda: (gr.update(open=True), update_session_list()),
|
| 527 |
-
inputs=[],
|
| 528 |
-
outputs=[session_drawer, session_list]
|
| 529 |
-
)
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
|
| 534 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 535 |
with antd.Tabs.Item(key="empty"):
|
|
@@ -558,48 +566,79 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 558 |
print(f"Error executing code: {str(e)}")
|
| 559 |
return None, gr.update(active_key="empty")
|
| 560 |
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
|
| 604 |
if __name__ == "__main__":
|
| 605 |
try:
|
|
|
|
| 370 |
|
| 371 |
with ms.Application() as app:
|
| 372 |
with antd.ConfigProvider():
|
|
|
|
|
|
|
| 373 |
# Drawer ์ปดํฌ๋ํธ๋ค
|
| 374 |
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
| 375 |
code_output = legacy.Markdown()
|
|
|
|
| 377 |
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
| 378 |
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
| 379 |
|
| 380 |
+
with antd.Drawer(
|
| 381 |
+
open=False,
|
| 382 |
+
title="Session History",
|
| 383 |
+
placement="left",
|
| 384 |
+
width="900px",
|
| 385 |
+
className="session-drawer"
|
| 386 |
+
) as session_drawer:
|
| 387 |
+
with antd.Flex(vertical=True, gap="middle"):
|
| 388 |
+
gr.Markdown("### Previous Sessions")
|
| 389 |
+
session_list = gr.Dropdown(
|
| 390 |
+
label="Select a session to view history",
|
| 391 |
+
choices=[],
|
| 392 |
+
className="session-list"
|
| 393 |
+
)
|
| 394 |
+
session_history = legacy.Chatbot(
|
| 395 |
+
show_label=False,
|
| 396 |
+
height=960,
|
| 397 |
+
elem_classes="session-chatbot"
|
| 398 |
+
)
|
| 399 |
+
close_btn = antd.Button(
|
| 400 |
+
"Close",
|
| 401 |
+
type="default",
|
| 402 |
+
className="close-btn"
|
| 403 |
+
)
|
| 404 |
|
| 405 |
# ๋ฉ์ธ ์ปจํ
์ธ ๋ฅผ ์ํ Row
|
| 406 |
with antd.Row(gutter=[32, 12]) as layout:
|
|
|
|
| 538 |
historyBtn = antd.Button("๐ history", type="default")
|
| 539 |
sessionBtn = antd.Button("๐ sessions", type="default")
|
| 540 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
|
| 542 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 543 |
with antd.Tabs.Item(key="empty"):
|
|
|
|
| 566 |
print(f"Error executing code: {str(e)}")
|
| 567 |
return None, gr.update(active_key="empty")
|
| 568 |
|
| 569 |
+
def show_session_history():
|
| 570 |
+
return (
|
| 571 |
+
gr.update(open=True), # session_drawer
|
| 572 |
+
update_session_list(), # session_list
|
| 573 |
+
[] # session_history ์ด๊ธฐํ
|
| 574 |
+
)
|
| 575 |
+
|
| 576 |
+
def close_session_drawer():
|
| 577 |
+
return (
|
| 578 |
+
gr.update(open=False), # session_drawer
|
| 579 |
+
gr.update(choices=[]), # session_list
|
| 580 |
+
[] # session_history ์ด๊ธฐํ
|
| 581 |
+
)
|
| 582 |
+
|
| 583 |
+
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
| 584 |
+
execute_btn.click(
|
| 585 |
+
fn=execute_code,
|
| 586 |
+
inputs=[input],
|
| 587 |
+
outputs=[sandbox, state_tab]
|
| 588 |
+
)
|
| 589 |
+
|
| 590 |
+
codeBtn.click(
|
| 591 |
+
lambda: gr.update(open=True),
|
| 592 |
+
inputs=[],
|
| 593 |
+
outputs=[code_drawer]
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
code_drawer.close(
|
| 597 |
+
lambda: gr.update(open=False),
|
| 598 |
+
inputs=[],
|
| 599 |
+
outputs=[code_drawer]
|
| 600 |
+
)
|
| 601 |
+
|
| 602 |
+
historyBtn.click(
|
| 603 |
+
history_render,
|
| 604 |
+
inputs=[history],
|
| 605 |
+
outputs=[history_drawer, history_output]
|
| 606 |
+
)
|
| 607 |
+
|
| 608 |
+
history_drawer.close(
|
| 609 |
+
lambda: gr.update(open=False),
|
| 610 |
+
inputs=[],
|
| 611 |
+
outputs=[history_drawer]
|
| 612 |
+
)
|
| 613 |
+
|
| 614 |
+
# ์ธ์
๊ด๋ จ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
| 615 |
+
sessionBtn.click(
|
| 616 |
+
show_session_history,
|
| 617 |
+
outputs=[session_drawer, session_list, session_history]
|
| 618 |
+
)
|
| 619 |
+
|
| 620 |
+
close_btn.click(
|
| 621 |
+
close_session_drawer,
|
| 622 |
+
outputs=[session_drawer, session_list, session_history]
|
| 623 |
+
)
|
| 624 |
+
|
| 625 |
+
session_list.change(
|
| 626 |
+
load_session_history,
|
| 627 |
+
inputs=[session_list],
|
| 628 |
+
outputs=[session_history]
|
| 629 |
+
)
|
| 630 |
+
|
| 631 |
+
btn.click(
|
| 632 |
+
demo_instance.generation_code,
|
| 633 |
+
inputs=[input, setting, history],
|
| 634 |
+
outputs=[code_output, history, sandbox, state_tab, code_drawer]
|
| 635 |
+
)
|
| 636 |
+
|
| 637 |
+
clear_btn.click(
|
| 638 |
+
demo_instance.clear_history,
|
| 639 |
+
inputs=[],
|
| 640 |
+
outputs=[history]
|
| 641 |
+
)
|
| 642 |
|
| 643 |
if __name__ == "__main__":
|
| 644 |
try:
|