openfree commited on
Commit
0de0de4
·
verified ·
1 Parent(s): 1d8b801

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -451,6 +451,12 @@ def deploy_to_vercel(code: str):
451
 
452
  theme = gr.themes.Soft()
453
 
 
 
 
 
 
 
454
  def create_main_interface():
455
  """메인 인터페이스 생성 함수"""
456
 
@@ -514,7 +520,8 @@ def create_main_interface():
514
  input = antd.InputTextarea(
515
  size="large",
516
  allow_clear=True,
517
- placeholder=random.choice(DEMO_LIST)['description']
 
518
  )
519
 
520
  # 버튼 그룹
@@ -564,19 +571,29 @@ def create_main_interface():
564
  inputs=[],
565
  outputs=[history_drawer]
566
  )
 
567
  btn.click(
568
  demo_instance.generation_code,
569
  inputs=[input, setting, history],
570
  outputs=[code_output, history, sandbox, state_tab, code_drawer]
 
 
 
 
571
  )
 
572
 
573
 
574
  clear_btn.click(
575
- demo_instance.clear_history,
576
- inputs=[],
577
- outputs=[history]
 
 
 
578
  )
579
 
 
580
  boost_btn.click(
581
  fn=handle_boost,
582
  inputs=[input],
 
451
 
452
  theme = gr.themes.Soft()
453
 
454
+ def get_random_placeholder():
455
+ return random.choice(DEMO_LIST)['description']
456
+
457
+ def update_placeholder():
458
+ return gr.update(placeholder=get_random_placeholder())
459
+
460
  def create_main_interface():
461
  """메인 인터페이스 생성 함수"""
462
 
 
520
  input = antd.InputTextarea(
521
  size="large",
522
  allow_clear=True,
523
+
524
+ placeholder=get_random_placeholder()
525
  )
526
 
527
  # 버튼 그룹
 
571
  inputs=[],
572
  outputs=[history_drawer]
573
  )
574
+
575
  btn.click(
576
  demo_instance.generation_code,
577
  inputs=[input, setting, history],
578
  outputs=[code_output, history, sandbox, state_tab, code_drawer]
579
+ ).then( # then을 사용하여 연속 동작 추가
580
+ fn=update_placeholder,
581
+ inputs=[],
582
+ outputs=[input]
583
  )
584
+
585
 
586
 
587
  clear_btn.click(
588
+ fn=lambda: (
589
+ demo_instance.clear_history(), # history 초기화
590
+ update_placeholder() # placeholder 업데이트
591
+ ),
592
+ inputs=[],
593
+ outputs=[history, input] # input도 출력에 추가
594
  )
595
 
596
+
597
  boost_btn.click(
598
  fn=handle_boost,
599
  inputs=[input],