steve7909 commited on
Commit
7354ac3
·
1 Parent(s): 94d7060

added English difficulty level option

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -24,12 +24,19 @@ def debug_print(*args, **kwargs):
24
  if DEBUG_MODE:
25
  print(*args, **kwargs)
26
 
27
- def generate_questions(input_topic, num_questions):
28
  """
29
  Generates EFL questions based on the input topic
30
  """
31
 
32
- prompt=f"Generate {num_questions} simple questions in English only for an EFL (English as a Foreign Language) student based on the following topic: {input_topic}"
 
 
 
 
 
 
 
33
 
34
  response = client.chat.completions.create(
35
 
@@ -49,10 +56,12 @@ with gr.Blocks() as app:
49
  with gr.Column():
50
  gr.Markdown("### EFL Question Generator")
51
  input_text = gr.Textbox(label="Topic", lines=1, placeholder="Type or paste your topic here...", value="Hobbies")
52
- num_questions_dropdown = gr.Dropdown(label="Number of Questions", choices=[5, 10, 15, 20], value=5)
 
 
53
  output_questions = gr.Textbox(label="Generated Questions", lines=5)
54
  generate_btn = gr.Button("Generate Questions")
55
- generate_btn.click(fn=generate_questions, inputs=[input_text, num_questions_dropdown], outputs=output_questions)
56
 
57
  app.launch()
58
 
 
24
  if DEBUG_MODE:
25
  print(*args, **kwargs)
26
 
27
+ def generate_questions(input_topic, num_questions, difficulty_level):
28
  """
29
  Generates EFL questions based on the input topic
30
  """
31
 
32
+ # Adjusting the prompt based on the chosen difficulty level
33
+ difficulty_instruction = {
34
+ "Easy": "using very simple English",
35
+ "Medium": "using moderately simple English",
36
+ "Hard": "that challenge comprehension and critical thinking"
37
+ }
38
+
39
+ prompt=f"Generate {num_questions} questions {difficulty_instruction[difficulty_level]} for an EFL (English as a Foreign Language) student based on the following topic: {input_topic}"
40
 
41
  response = client.chat.completions.create(
42
 
 
56
  with gr.Column():
57
  gr.Markdown("### EFL Question Generator")
58
  input_text = gr.Textbox(label="Topic", lines=1, placeholder="Type or paste your topic here...", value="Hobbies")
59
+ with gr.Row():
60
+ num_questions_dropdown = gr.Dropdown(label="Number of Questions", choices=[5, 10, 15, 20], value=5)
61
+ difficulty_dropdown = gr.Dropdown(label="Difficulty Level", choices=["Easy", "Medium", "Hard"], value="Easy")
62
  output_questions = gr.Textbox(label="Generated Questions", lines=5)
63
  generate_btn = gr.Button("Generate Questions")
64
+ generate_btn.click(fn=generate_questions, inputs=[input_text, num_questions_dropdown, difficulty_dropdown], outputs=output_questions)
65
 
66
  app.launch()
67