Spaces:
Sleeping
Sleeping
abnerzhang
commited on
Commit
•
56f90a7
1
Parent(s):
3e5ef0f
Update app.py
Browse files
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
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
return "
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
iface = gr.Interface(
|
16 |
-
fn=
|
17 |
-
inputs=
|
18 |
-
|
|
|
|
|
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 |
+
|