youngtsai commited on
Commit
27122a0
1 Parent(s): ca3ba83

chinese_full_paragraph_tab = gr.update(visible=False)

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -626,15 +626,19 @@ def init_params(request: gr.Request):
626
  # url = request.url
627
  print("Request URL:", request.url)
628
 
 
629
  chinese_idea_tab = gr.update(visible=True)
 
630
 
631
  # check if origin is from junyiacademy
632
  origin = request.headers.get("origin", "")
633
  if "junyiacademy.org" in origin or "junyiacademy.appspot.com" in origin:
634
- chinese_idea_tab = gr.update(visible=False)
 
 
635
 
636
 
637
- return chinese_idea_tab
638
 
639
 
640
  CSS = """
@@ -1666,7 +1670,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1666
  )
1667
 
1668
  # =====涓枃鍏ㄦ枃鎵规敼=====
1669
- with gr.Tab("涓枃鍏ㄦ枃鎵规敼"):
1670
  with gr.Row(visible=False) as chinese_full_paragraph_params:
1671
  chinese_full_paragraph_sys_content_input = gr.Textbox(label="System Prompt", value="You are a Chinese teacher who is practicing with me to improve my Chinese writing skill.")
1672
  default_user_generate_chinese_full_paragraph_evaluate_prompt = """
@@ -1816,7 +1820,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1816
  demo.load(
1817
  init_params,
1818
  inputs =[],
1819
- outputs = [chinese_idea_tab]
1820
  )
1821
 
1822
  demo.launch()
 
626
  # url = request.url
627
  print("Request URL:", request.url)
628
 
629
+ query_params = dict(request.query_params)
630
  chinese_idea_tab = gr.update(visible=True)
631
+ chinese_full_paragraph_tab = gr.update(visible=True)
632
 
633
  # check if origin is from junyiacademy
634
  origin = request.headers.get("origin", "")
635
  if "junyiacademy.org" in origin or "junyiacademy.appspot.com" in origin:
636
+ if query_params["language"] == "english":
637
+ chinese_idea_tab = gr.update(visible=False)
638
+ chinese_full_paragraph_tab = gr.update(visible=False)
639
 
640
 
641
+ return chinese_idea_tab, chinese_full_paragraph_tab
642
 
643
 
644
  CSS = """
 
1670
  )
1671
 
1672
  # =====涓枃鍏ㄦ枃鎵规敼=====
1673
+ with gr.Tab("涓枃鍏ㄦ枃鎵规敼") as chinese_full_paragraph_tab:
1674
  with gr.Row(visible=False) as chinese_full_paragraph_params:
1675
  chinese_full_paragraph_sys_content_input = gr.Textbox(label="System Prompt", value="You are a Chinese teacher who is practicing with me to improve my Chinese writing skill.")
1676
  default_user_generate_chinese_full_paragraph_evaluate_prompt = """
 
1820
  demo.load(
1821
  init_params,
1822
  inputs =[],
1823
+ outputs = [chinese_idea_tab, chinese_full_paragraph_tab]
1824
  )
1825
 
1826
  demo.launch()