seawolf2357 commited on
Commit
1a1e451
·
verified ·
1 Parent(s): 64ad997

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +97 -58
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(open=False, title="Session History", placement="left", width="900px") as session_drawer:
383
- session_list = gr.Dropdown(label="Select Session", choices=[])
384
- session_history = legacy.Chatbot(show_label=False, height=960)
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
- execute_btn.click(
565
- fn=execute_code,
566
- inputs=[input],
567
- outputs=[sandbox, state_tab]
568
- )
569
-
570
- codeBtn.click(lambda: gr.update(open=True),
571
- inputs=[], outputs=[code_drawer])
572
- code_drawer.close(lambda: gr.update(
573
- open=False), inputs=[], outputs=[code_drawer])
574
-
575
- historyBtn.click(history_render, inputs=[history], outputs=[history_drawer, history_output])
576
- history_drawer.close(lambda: gr.update(
577
- open=False), inputs=[], outputs=[history_drawer])
578
-
579
- sessionBtn.click(
580
- lambda: (gr.update(open=True), update_session_list()),
581
- inputs=[],
582
- outputs=[session_drawer, session_list]
583
- )
584
-
585
- session_list.change(
586
- load_session_history,
587
- inputs=[session_list],
588
- outputs=[session_history]
589
- )
590
-
591
- btn.click(
592
- demo_instance.generation_code,
593
- inputs=[input, setting, history],
594
- outputs=[code_output, history, sandbox, state_tab, code_drawer]
595
- )
596
-
597
- clear_btn.click(
598
- demo_instance.clear_history,
599
- inputs=[],
600
- outputs=[history]
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: