steve7909 commited on
Commit
3621609
·
1 Parent(s): 1aa54a1

added option for more questions

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -25,13 +25,12 @@ def debug_print(*args, **kwargs):
25
  if DEBUG_MODE:
26
  print(*args, **kwargs)
27
 
28
- def generate_questions(input_prompt):
29
  """
30
- Generates EFL questions based on the input text using OpenAI's GPT-3.
31
  """
32
-
33
 
34
- prompt=f"Generate 5 simple questions in English for an EFL (English as a Foreign Language) based on the following topic: {input_prompt}"
35
 
36
  response = client.chat.completions.create(
37
 
@@ -51,9 +50,10 @@ with gr.Blocks() as app:
51
  with gr.Column():
52
  gr.Markdown("### EFL Question Generator")
53
  input_text = gr.Textbox(label="Topic", lines=1, placeholder="Type or paste your topic here...", value="China")
 
54
  output_questions = gr.Textbox(label="Generated Questions", lines=5)
55
  generate_btn = gr.Button("Generate Questions")
56
- generate_btn.click(fn=generate_questions, inputs=input_text, outputs=output_questions)
57
 
58
  app.launch()
59
 
 
25
  if DEBUG_MODE:
26
  print(*args, **kwargs)
27
 
28
+ def generate_questions(input_topic, num_questions):
29
  """
30
+ Generates EFL questions based on the input topic
31
  """
 
32
 
33
+ prompt=f"Generate {num_questions} simple questions in English only for an EFL (English as a Foreign Language) based on the following topic: {input_topic}"
34
 
35
  response = client.chat.completions.create(
36
 
 
50
  with gr.Column():
51
  gr.Markdown("### EFL Question Generator")
52
  input_text = gr.Textbox(label="Topic", lines=1, placeholder="Type or paste your topic here...", value="China")
53
+ num_questions_dropdown = gr.Dropdown(label="Number of Questions", choices=[5, 10, 15, 20], value=5)
54
  output_questions = gr.Textbox(label="Generated Questions", lines=5)
55
  generate_btn = gr.Button("Generate Questions")
56
+ generate_btn.click(fn=generate_questions, inputs=[input_text, num_questions_dropdown], outputs=output_questions)
57
 
58
  app.launch()
59