abnerzhang commited on
Commit
56f90a7
·
1 Parent(s): 3e5ef0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -4,21 +4,29 @@ def generate_ielts_essay(prompt):
4
  # You may want to customize the max_length and other parameters according to your needs
5
  return "Hello " + prompt + "!!"
6
 
7
- def grade_essay(essay):
8
- # Simple grading function. Replace with a more sophisticated essay grading algorithm.
9
- words = essay.split()
10
- if len(words) > 200:
11
- return "Good"
12
- else:
13
- return "Poor"
 
 
 
 
 
14
 
15
  iface = gr.Interface(
16
- fn={"Generate": generate_ielts_essay, "Grade": grade_essay},
17
- inputs={"Generate": gr.inputs.Textbox(lines=3, placeholder="Enter IELTS writing prompt here..."),
18
- "Grade": gr.inputs.Textbox(lines=10, placeholder="Paste the essay text here...")},
 
 
19
  outputs="text",
20
  title="IELTS Essay Generator and Grader",
21
  description="This tool generates a response to an IELTS writing prompt using AI and provides a simple grading.",
22
  )
23
 
24
  iface.launch()
 
 
4
  # You may want to customize the max_length and other parameters according to your needs
5
  return "Hello " + prompt + "!!"
6
 
7
+ def generate_or_grade(task, text):
8
+ if task == "Generate":
9
+ # Generate an essay
10
+ # output = generator(text, max_length=500)[0]['generated_text']
11
+ return "Hello " + text + "!!"
12
+ elif task == "Grade":
13
+ # Simple grading function. Replace with a more sophisticated essay grading algorithm.
14
+ words = text.split()
15
+ if len(words) > 200:
16
+ return "Good"
17
+ else:
18
+ return "Poor"
19
 
20
  iface = gr.Interface(
21
+ fn=generate_or_grade,
22
+ inputs=[
23
+ gr.inputs.Radio(["Generate", "Grade"], label="Task"),
24
+ gr.inputs.Textbox(lines=10, placeholder="Enter text...")
25
+ ],
26
  outputs="text",
27
  title="IELTS Essay Generator and Grader",
28
  description="This tool generates a response to an IELTS writing prompt using AI and provides a simple grading.",
29
  )
30
 
31
  iface.launch()
32
+