youngtsai commited on
Commit
f97a7cb
·
1 Parent(s): d92e8cd
Files changed (1) hide show
  1. app.py +28 -5
app.py CHANGED
@@ -485,6 +485,9 @@ def update_exam_contents(selected_title):
485
  if exam["title"] == selected_title:
486
  return exam["title"], exam["question"], exam["hint"], exam["image_url"]
487
 
 
 
 
488
  # elem_classes=['accordion-prompts']
489
  CSS = """
490
  .accordion-prompts {
@@ -500,7 +503,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
500
  model = gr.Radio(["gpt-4o", "gpt-4-turbo"], label="Model", value="gpt-4o")
501
  max_tokens = gr.Slider(minimum=50, maximum=4000, value=4000, label="Max Tokens")
502
  sys_content_input = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.")
503
- eng_level_input = gr.Radio(["beginner", "intermediate", "advanced"], label="English Level", value="beginner")
 
504
 
505
  # basic inputs 主題與情境
506
  with gr.Group():
@@ -557,9 +561,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
557
  """)
558
  with gr.Row(visible=False) as topic_params:
559
  default_generate_topics_prompt = """
 
 
 
 
 
560
  Give me 10 randon topics,
561
- for a paragraph. Just the topics, no explanation, use simple English language.
562
- Make sure the vocabulary you use is at english level.
563
  output use JSON
564
  EXAMPLE:
565
  "topics":["topic1", "topic2", "topic3", "topic4", "topic5", "topic6", "topic7", "topic8", "topic9", "topic10"]
@@ -567,12 +576,16 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
567
  user_generate_topics_prompt = gr.Textbox(label="Topics Prompt", value=default_generate_topics_prompt, visible=False)
568
  with gr.Row():
569
  with gr.Column():
570
- topic_input = gr.Textbox(label="選擇合適的主題或是自定義:")
571
  with gr.Column():
572
  generate_topics_button = gr.Button("✨ JUTOR 隨機產生 10 個段落主題,再挑選一個來練習吧!", variant="primary")
573
  topic_output = gr.Textbox(label="AI Generated Topic 主題", visible=True, value=[])
574
 
575
  generate_topics_button.click(
 
 
 
 
576
  fn=generate_topics,
577
  inputs=[
578
  model,
@@ -601,11 +614,13 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
601
  with gr.Column():
602
  with gr.Row() as points_params:
603
  default_generate_points_prompt = """
 
 
 
604
  Please provide main points to develop in a paragraph about topic in the context of scenario,
605
  use simple English language and make sure the vocabulary you use is at eng_level.
606
  No more explanation either no developing these points into a simple paragraph.
607
  Output use JSON format
608
-
609
  EXAMPLE:
610
  "points":["point1", "point2", "point3"]
611
  """
@@ -624,6 +639,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
624
  points_output = gr.Textbox(label="AI Generated Points 要點", visible=True, value=[])
625
 
626
  generate_points_button.click(
 
 
 
 
627
  fn=generate_points,
628
  inputs=[
629
  model,
@@ -691,6 +710,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
691
  topic_sentence_output = gr.Textbox(label="AI Generated Topic Sentences 主題句", value=[])
692
 
693
  generate_topic_sentences_button.click(
 
 
 
 
694
  fn=generate_topic_sentences,
695
  inputs=[
696
  model,
 
485
  if exam["title"] == selected_title:
486
  return exam["title"], exam["question"], exam["hint"], exam["image_url"]
487
 
488
+ def show_elements():
489
+ return gr.update(visible=True)
490
+
491
  # elem_classes=['accordion-prompts']
492
  CSS = """
493
  .accordion-prompts {
 
503
  model = gr.Radio(["gpt-4o", "gpt-4-turbo"], label="Model", value="gpt-4o")
504
  max_tokens = gr.Slider(minimum=50, maximum=4000, value=4000, label="Max Tokens")
505
  sys_content_input = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.")
506
+ with gr.Row():
507
+ eng_level_input = gr.Radio([("初學", "beginner"), ("中級","intermediate"), ("進階", "advanced"), ("學測指考","台灣的 學科能力測驗等級")], label="English Level", value="beginner")
508
 
509
  # basic inputs 主題與情境
510
  with gr.Group():
 
561
  """)
562
  with gr.Row(visible=False) as topic_params:
563
  default_generate_topics_prompt = """
564
+ The topic is the main issue that the entire paragraph aims to discuss and elaborate on.
565
+ Determining the topic is crucial for the structure and content of the paragraph.
566
+ For example, if the context is School & Learning, you can decide on an appropriate topic based on your interests, background, and experiences, such as My First Day at School or The Role of the Internet in Learning.
567
+ If the context is Climate Change, related topics could be Global Warming or Extreme Weather Events.
568
+
569
  Give me 10 randon topics,
570
+ for a paragraph. Just the topics, no explanation, use English language base on eng_level.
571
+ Make sure the vocabulary you use is at eng_level.
572
  output use JSON
573
  EXAMPLE:
574
  "topics":["topic1", "topic2", "topic3", "topic4", "topic5", "topic6", "topic7", "topic8", "topic9", "topic10"]
 
576
  user_generate_topics_prompt = gr.Textbox(label="Topics Prompt", value=default_generate_topics_prompt, visible=False)
577
  with gr.Row():
578
  with gr.Column():
579
+ topic_input = gr.Textbox(label="選擇合適的主題或是自定義主題:")
580
  with gr.Column():
581
  generate_topics_button = gr.Button("✨ JUTOR 隨機產生 10 個段落主題,再挑選一個來練習吧!", variant="primary")
582
  topic_output = gr.Textbox(label="AI Generated Topic 主題", visible=True, value=[])
583
 
584
  generate_topics_button.click(
585
+ fn=show_elements,
586
+ inputs=[],
587
+ outputs=[topic_output]
588
+ ).then(
589
  fn=generate_topics,
590
  inputs=[
591
  model,
 
614
  with gr.Column():
615
  with gr.Row() as points_params:
616
  default_generate_points_prompt = """
617
+ Based on the topic and eng_level setting, think about the direction and content of the paragraph, then present it using some related points/keywords.
618
+ For example, the topic: "The Benefits of Learning a Second Language." The direction and content: Learning a second language, such as Japanese, allows you to communicate with Japanese people and understand Japanese culture.
619
+ Therefore, the points/keywords are "Improving communication skills" and "Understanding other cultures." ....
620
  Please provide main points to develop in a paragraph about topic in the context of scenario,
621
  use simple English language and make sure the vocabulary you use is at eng_level.
622
  No more explanation either no developing these points into a simple paragraph.
623
  Output use JSON format
 
624
  EXAMPLE:
625
  "points":["point1", "point2", "point3"]
626
  """
 
639
  points_output = gr.Textbox(label="AI Generated Points 要點", visible=True, value=[])
640
 
641
  generate_points_button.click(
642
+ fn=show_elements,
643
+ inputs=[],
644
+ outputs=[points_output]
645
+ ).then(
646
  fn=generate_points,
647
  inputs=[
648
  model,
 
710
  topic_sentence_output = gr.Textbox(label="AI Generated Topic Sentences 主題句", value=[])
711
 
712
  generate_topic_sentences_button.click(
713
+ fn=show_elements,
714
+ inputs=[],
715
+ outputs=[topic_sentence_output]
716
+ ).then(
717
  fn=generate_topic_sentences,
718
  inputs=[
719
  model,