Spaces:
Running
Running
tiennguyenbnbk
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -60,32 +60,70 @@ def send_request_ielts(input_dict):
|
|
60 |
return response.json()
|
61 |
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
def gen_english(*args):
|
64 |
input_dict = {
|
65 |
-
|
66 |
-
'
|
67 |
-
'
|
68 |
-
'
|
69 |
-
'
|
70 |
-
'
|
71 |
-
'
|
72 |
-
'
|
73 |
-
'
|
74 |
-
'
|
75 |
-
'
|
76 |
}
|
77 |
response = send_request_english(input_dict)
|
78 |
return response["evaluation"].replace("**", '"')
|
79 |
|
80 |
def gen_math(*args):
|
81 |
input_dict = {
|
82 |
-
|
83 |
-
'
|
84 |
-
'
|
85 |
-
'
|
86 |
-
'
|
87 |
-
'
|
88 |
-
|
|
|
|
|
|
|
89 |
response = send_request_math(input_dict)
|
90 |
return response["evaluation"].replace("**", '"')
|
91 |
|
@@ -114,44 +152,48 @@ with gr.Blocks() as demo:
|
|
114 |
with gr.Column():
|
115 |
with gr.Group():
|
116 |
review = [
|
117 |
-
gr.Radio([
|
118 |
]
|
119 |
-
|
120 |
with gr.Group():
|
121 |
review += [
|
122 |
-
gr.Radio([1,2,3,4,5], value=3, label="
|
123 |
-
gr.
|
124 |
-
gr.
|
125 |
]
|
|
|
126 |
with gr.Group():
|
127 |
review += [
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
]
|
131 |
with gr.Column():
|
132 |
with gr.Group():
|
133 |
review += [
|
134 |
-
gr.Radio([1,2,3,4,5], value=3, label="
|
135 |
-
|
136 |
-
gr.Textbox(lines=1, label="Các cấu trúc con chưa ghi nhớ", placeholder="Điền các cấu trúc cách nhau bởi dấu chấm phẩy"),
|
137 |
-
]
|
138 |
with gr.Group():
|
139 |
review += [
|
140 |
-
gr.Radio([1,2,3,4,5], value=3, label="
|
141 |
]
|
142 |
with gr.Group():
|
143 |
review += [
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
], label="Những vấn đề cần cải thiện để buổi học đạt kết quả tốt hơn", show_label=True),
|
149 |
]
|
150 |
with gr.Column():
|
151 |
# debug_output = gr.Textbox(label="Thông tin đánh giá", show_copy_button=True)
|
152 |
-
evaluation = gr.Textbox(label="
|
153 |
|
154 |
-
greet_btn = gr.Button("
|
155 |
|
156 |
greet_btn.click(gen_english, inputs=[*review], outputs=[evaluation])
|
157 |
|
@@ -161,31 +203,37 @@ with gr.Blocks() as demo:
|
|
161 |
with gr.Column():
|
162 |
with gr.Group():
|
163 |
review = [
|
164 |
-
gr.Radio([
|
165 |
]
|
166 |
with gr.Group():
|
167 |
review += [
|
168 |
-
gr.
|
169 |
]
|
170 |
with gr.Group():
|
171 |
review += [
|
172 |
-
gr.Textbox(lines=1, label="Con
|
|
|
|
|
173 |
]
|
174 |
with gr.Column():
|
175 |
with gr.Group():
|
176 |
review += [
|
177 |
-
gr.Radio([1,2,3,4,5], value=3, label="
|
178 |
]
|
179 |
with gr.Group():
|
180 |
review += [
|
181 |
-
gr.Radio([1,2,3,4,5], value=3, label="
|
182 |
]
|
183 |
with gr.Group():
|
184 |
review += [
|
185 |
-
gr.
|
186 |
-
"
|
187 |
-
"
|
188 |
-
"
|
|
|
|
|
|
|
|
|
189 |
], label="Những vấn đề cần cải thiện để buổi học đạt kết quả tốt hơn", show_label=True),
|
190 |
]
|
191 |
with gr.Column():
|
@@ -195,61 +243,61 @@ with gr.Blocks() as demo:
|
|
195 |
greet_btn = gr.Button("Tạo nhận xét")
|
196 |
|
197 |
greet_btn.click(gen_math, inputs=[*review], outputs=[evaluation])
|
198 |
-
|
199 |
-
with gr.Tab("IELTS"):
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
|
250 |
-
|
251 |
|
252 |
-
|
253 |
|
254 |
if __name__ == "__main__":
|
255 |
demo.launch(auth=(os.getenv('username'), os.getenv('password')))
|
|
|
60 |
return response.json()
|
61 |
|
62 |
|
63 |
+
mapping_score_en = {
|
64 |
+
"1 - Poor" : 1,
|
65 |
+
"2 - Average" : 2,
|
66 |
+
"3 - Good" : 3,
|
67 |
+
"4 - Very Good" : 4,
|
68 |
+
"5 - Excellent" : 5,
|
69 |
+
}
|
70 |
+
mapping_score_vi = {
|
71 |
+
"1 - Yếu" : 1,
|
72 |
+
"2 - Trung bình" : 2,
|
73 |
+
"3 - Khá" : 3,
|
74 |
+
"4 - Tốt" : 4,
|
75 |
+
"5 - Tuyệt vời" : 5,
|
76 |
+
}
|
77 |
+
|
78 |
+
mapping_note_en = {
|
79 |
+
"Complete Workbook exercises before class (Do not check if there is no Workbook exercises)": "Cần hoàn thành bài tập trong Workbook",
|
80 |
+
"Pay more attention and don't do your own work in class": "Cần tập trung hơn và không làm việc riêng trong lớp",
|
81 |
+
"Do not turn off the camera frequently": "Không tắt camera trong buổi học",
|
82 |
+
"Need to fix internet quality": "Kiểm tra lại chất lượng mạng internet",
|
83 |
+
"Need to fix camera/mic error": "Sửa lỗi cam, lỗi mic",
|
84 |
+
"Avoid studying in noisy and crowded places": "Tránh ngồi học nơi có nhiều tiếng ồn, nhiều người qua lại",
|
85 |
+
"Be polite to teachers": "Lễ phép với thầy cô",
|
86 |
+
}
|
87 |
+
|
88 |
+
mapping_note_vi = {
|
89 |
+
"Hoàn thành bài tập Workbook (Không tích nếu không có bài tập Workbook)": "Cần hoàn thành bài tập trong Workbook",
|
90 |
+
"Cần tập trung hơn và không làm việc riêng trong lớp": "Cần tập trung hơn và không làm việc riêng trong lớp",
|
91 |
+
"Không tắt cam trong buổi học": "Không tắt camera trong buổi học",
|
92 |
+
"Kiểm tra lại chất lượng mạng internet": "Kiểm tra lại chất lượng mạng internet",
|
93 |
+
"Sửa lỗi cam, lỗi mic": "Sửa lỗi cam, lỗi mic",
|
94 |
+
"Tránh ngồi học nơi có nhiều tiếng ồn, nhiều người qua lại": "Tránh ngồi học nơi có nhiều tiếng ồn, nhiều người qua lại",
|
95 |
+
"Lễ phép với thầy cô": "Lễ phép với thầy cô",
|
96 |
+
}
|
97 |
+
|
98 |
def gen_english(*args):
|
99 |
input_dict = {
|
100 |
+
'title': "Cô" if args[0] == "Female teacher" else "Thầy" if args[0] else None,
|
101 |
+
'reception': mapping_score_en.get(args[1]) if args[1] else None,
|
102 |
+
'participate_activities': mapping_score_en.get(args[2]) if args[2] else None,
|
103 |
+
'remember_apply_vocab_grama': mapping_score_en.get(args[3]) if args[3] else None,
|
104 |
+
'note': [mapping_note_en.get(x) for x in args[4]] if args[4] else "",
|
105 |
+
'pronounce': mapping_score_en.get(args[5]) if args[5] else None,
|
106 |
+
'remember_apply_strategies': mapping_score_en.get(args[6]) if args[6] else None,
|
107 |
+
'vocabulary_need_improve': args[7] if args[7] else "",
|
108 |
+
'grammar_need_improve': args[8] if args[8] else "",
|
109 |
+
'exercise_need_improve': args[9] if args[9] else "",
|
110 |
+
'note_for_skills': args[10] if args[10] else "",
|
111 |
}
|
112 |
response = send_request_english(input_dict)
|
113 |
return response["evaluation"].replace("**", '"')
|
114 |
|
115 |
def gen_math(*args):
|
116 |
input_dict = {
|
117 |
+
'title': "Cô" if args[0] == "Cô giáo" else "Thầy" if args[0] else None,
|
118 |
+
'reception': mapping_score_vi.get(args[1]) if args[1] else None,
|
119 |
+
'exercise_format_understanding': args[2] if args[2] else "",
|
120 |
+
'exercise_format_not_understanding': args[3] if args[3] else "",
|
121 |
+
'more_evaluations': args[4] if args[4] else "",
|
122 |
+
'participate_activities': mapping_score_vi.get(args[5]) if args[5] else None,
|
123 |
+
'problem_solving_and_presentation': mapping_score_vi.get(args[6]) if args[6] else None,
|
124 |
+
'note': [mapping_note_vi.get(x) for x in args[7]] if args[7] else "",
|
125 |
+
}
|
126 |
+
print(input_dict)
|
127 |
response = send_request_math(input_dict)
|
128 |
return response["evaluation"].replace("**", '"')
|
129 |
|
|
|
152 |
with gr.Column():
|
153 |
with gr.Group():
|
154 |
review = [
|
155 |
+
gr.Radio(["Female teacher", "Male teacher"], value="Female teacher", label="I am a", show_label=True),
|
156 |
]
|
|
|
157 |
with gr.Group():
|
158 |
review += [
|
159 |
+
gr.Radio(["1 - Poor","2 - Average","3 - Good","4 - Very Good","5 - Excellent"], value="3 - Good", label="Learning ability", show_label=True),
|
160 |
+
gr.Radio(["1 - Poor","2 - Average","3 - Good","4 - Very Good","5 - Excellent"], value="3 - Good", label="Participation in class activities", show_label=True),
|
161 |
+
gr.Radio(["1 - Poor","2 - Average","3 - Good","4 - Very Good","5 - Excellent"], value="3 - Good", label="Ability to remember and apply learned vocabulary/ grammar structures", show_label=True),
|
162 |
]
|
163 |
+
|
164 |
with gr.Group():
|
165 |
review += [
|
166 |
+
gr.CheckboxGroup([
|
167 |
+
"Complete Workbook exercises before class (Do not check if there is no Workbook exercises)",
|
168 |
+
"Pay more attention and don't do your own work in class",
|
169 |
+
"Do not turn off the camera frequently",
|
170 |
+
"Need to fix internet quality",
|
171 |
+
"Need to fix camera/mic error",
|
172 |
+
"Avoid studying in noisy and crowded places",
|
173 |
+
"Be polite to teachers",
|
174 |
+
], label="Things to improve for better learning outcomes", show_label=True),
|
175 |
]
|
176 |
with gr.Column():
|
177 |
with gr.Group():
|
178 |
review += [
|
179 |
+
gr.Radio(["1 - Poor","2 - Average","3 - Good","4 - Very Good","5 - Excellent"], value="3 - Good", label="Pronunciation when using English to communicate", show_label=True),
|
180 |
+
]
|
|
|
|
|
181 |
with gr.Group():
|
182 |
review += [
|
183 |
+
gr.Radio(["1 - Poor","2 - Average","3 - Good","4 - Very Good","5 - Excellent"], value="3 - Good", label="Ability to remember and apply strategies to different types of questions (optional)", show_label=True),
|
184 |
]
|
185 |
with gr.Group():
|
186 |
review += [
|
187 |
+
gr.Textbox(lines=1, label="Words that need further practice", placeholder="Separate words by semicolons ;"),
|
188 |
+
gr.Textbox(lines=1, label="Structures/Grammar point that need further practice", placeholder="Separate structures by semicolons ;"),
|
189 |
+
gr.Textbox(lines=1, label="Type of exercises that need further practice (optional)", placeholder="Exercises..."),
|
190 |
+
gr.Textbox(lines=3, label="Other notes on listening, speaking, reading and writing skills (optional)", placeholder="Note..."),
|
|
|
191 |
]
|
192 |
with gr.Column():
|
193 |
# debug_output = gr.Textbox(label="Thông tin đánh giá", show_copy_button=True)
|
194 |
+
evaluation = gr.Textbox(label="Evaluation", show_copy_button=True)
|
195 |
|
196 |
+
greet_btn = gr.Button("Generate evaluation")
|
197 |
|
198 |
greet_btn.click(gen_english, inputs=[*review], outputs=[evaluation])
|
199 |
|
|
|
203 |
with gr.Column():
|
204 |
with gr.Group():
|
205 |
review = [
|
206 |
+
gr.Radio(["Cô giáo", "Thầy giáo"], value="Cô giáo", label="Bạn là", show_label=True),
|
207 |
]
|
208 |
with gr.Group():
|
209 |
review += [
|
210 |
+
gr.Radio(["1 - Yếu","2 - Trung bình","3 - Khá","4 - Tốt","5 - Tuyệt vời"], value="3 - Khá", label="Khả năng tiếp thu", show_label=True),
|
211 |
]
|
212 |
with gr.Group():
|
213 |
review += [
|
214 |
+
gr.Textbox(lines=1, label="Con hiểu phương pháp và cách trình bày về dạng bài", placeholder="Dạng bài..."),
|
215 |
+
gr.Textbox(lines=1, label="Con cần luyện tập thêm về dạng bài", placeholder="Dạng bài..."),
|
216 |
+
gr.Textbox(lines=1, label="Nhận xét thêm (nếu có)", placeholder="Nhận xét..."),
|
217 |
]
|
218 |
with gr.Column():
|
219 |
with gr.Group():
|
220 |
review += [
|
221 |
+
gr.Radio(["1 - Yếu","2 - Trung bình","3 - Khá","4 - Tốt","5 - Tuyệt vời"], value="3 - Khá", label="Tham gia vào các hoạt động trong lớp", show_label=True),
|
222 |
]
|
223 |
with gr.Group():
|
224 |
review += [
|
225 |
+
gr.Radio(["1 - Yếu","2 - Trung bình","3 - Khá","4 - Tốt","5 - Tuyệt vời"], value="3 - Khá", label="Giải quyết vấn đề & trình bày", show_label=True),
|
226 |
]
|
227 |
with gr.Group():
|
228 |
review += [
|
229 |
+
gr.CheckboxGroup([
|
230 |
+
"Hoàn thành bài tập Workbook (Không tích nếu không có bài tập Workbook)",
|
231 |
+
"Cần tập trung hơn và không làm việc riêng trong lớp",
|
232 |
+
"Không tắt cam trong buổi học",
|
233 |
+
"Kiểm tra lại chất lượng mạng internet",
|
234 |
+
"Sửa lỗi cam, lỗi mic",
|
235 |
+
"Tránh ngồi học nơi có nhiều tiếng ồn, nhiều người qua lại",
|
236 |
+
"Lễ phép với thầy cô",
|
237 |
], label="Những vấn đề cần cải thiện để buổi học đạt kết quả tốt hơn", show_label=True),
|
238 |
]
|
239 |
with gr.Column():
|
|
|
243 |
greet_btn = gr.Button("Tạo nhận xét")
|
244 |
|
245 |
greet_btn.click(gen_math, inputs=[*review], outputs=[evaluation])
|
246 |
+
|
247 |
+
# with gr.Tab("IELTS"):
|
248 |
+
# with gr.Row():
|
249 |
+
# # --- Nhóm các thành phần nhập liệu ---
|
250 |
+
# with gr.Column():
|
251 |
+
# with gr.Group():
|
252 |
+
# review = [
|
253 |
+
# gr.Radio([1,2,3,4,5], value=3, label="Mức độ tập trung của HV trong buổi học", show_label=True),
|
254 |
+
# ]
|
255 |
|
256 |
+
# with gr.Group():
|
257 |
+
# review += [
|
258 |
+
# gr.Radio([1,2,3,4,5], value=3, label="Mức độ tham gia của HV vào các hoạt động trong lớp", show_label=True),
|
259 |
+
# ]
|
260 |
+
# with gr.Group():
|
261 |
+
# review += [
|
262 |
+
# gr.Textbox(lines=1, label="Dạng bài HV cần luyện tập thêm (nếu có)", placeholder="GV điền các điểm mà HV cần cải thiện"),
|
263 |
+
# gr.Textbox(lines=1, label="Điểm ngữ pháp HV cần luyện tập thêm (nếu có)", placeholder="GV điền các điểm mà HV cần cải thiện"),
|
264 |
+
# gr.Textbox(lines=1, label="Cấu trúc câu HV cần luyện tập thêm (nếu có)", placeholder="GV điền các điểm mà HV cần cải thiện"),
|
265 |
+
# gr.Textbox(lines=1, label="Từ vựng HV cần luyện tập thêm (nếu có)", placeholder="GV điền các điểm mà HV cần cải thiện"),
|
266 |
+
# ]
|
267 |
|
268 |
+
# with gr.Column():
|
269 |
+
# with gr.Group():
|
270 |
+
# review += [
|
271 |
+
# gr.Radio([1,2,3,4,5], value=3, label="Khả năng ghi nhớ và áp dụng các từ vựng/ cấu trúc ngữ pháp đã học", show_label=True),
|
272 |
+
# ]
|
273 |
+
# with gr.Group():
|
274 |
+
# review += [
|
275 |
+
# gr.Radio([1,2,3,4,5], value=3, label="Khả năng ghi nhớ và áp dụng các chiến thuật cho các dạng bài khác nhau", show_label=True),
|
276 |
|
277 |
+
# ]
|
278 |
+
# with gr.Group():
|
279 |
+
# review += [
|
280 |
+
# gr.Radio([1,2,3,4,5], value=3, label="Khả năng phát âm khi sử dụng tiếng Anh để trả lời các câu hỏi của GV", show_label=True),
|
281 |
+
# ]
|
282 |
|
283 |
|
284 |
+
# with gr.Group():
|
285 |
+
# review += [
|
286 |
+
# gr.CheckboxGroup([
|
287 |
+
# "Học sinh thiếu tập trung, hay làm việc riêng trong lớp",
|
288 |
+
# "Mạng của học sinh kém ảnh hưởng tới chất lượng buổi học",
|
289 |
+
# "Học sinh thiếu lễ phép với thầy cô",
|
290 |
+
# "Học sinh còn rụt rè, chưa tích cực phát biểu xây dựng bài"
|
291 |
+
# ], label="Những vấn đề cần cải thiện để buổi học đạt kết quả tốt hơn", show_label=True),
|
292 |
+
# ]
|
293 |
|
294 |
+
# with gr.Column():
|
295 |
+
# # debug_output = gr.Textbox(label="Thông tin đánh giá", show_copy_button=True)
|
296 |
+
# evaluation = gr.Textbox(label="Nhận xét", show_copy_button=True)
|
297 |
|
298 |
+
# greet_btn = gr.Button("Tạo nhận xét")
|
299 |
|
300 |
+
# greet_btn.click(gen_ielts, inputs=[*review], outputs=[evaluation])
|
301 |
|
302 |
if __name__ == "__main__":
|
303 |
demo.launch(auth=(os.getenv('username'), os.getenv('password')))
|