tiennguyenbnbk commited on
Commit
2676c78
·
verified ·
1 Parent(s): 9d85e64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +141 -93
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
- 'reception': args[0] if args[0] else None,
66
- 'remember_new_vocabulary': args[1] if args[1] else None,
67
- 'vocabulary_student_remember': args[2] if args[2] else "",
68
- 'vocabulary_student_not_remember': args[3] if args[3] else "",
69
- 'remember_new_grammar': args[6] if args[6] else None,
70
- 'grammar_student_remember': args[7] if args[7] else "",
71
- 'grammar_student_not_remember': args[8] if args[8] else "",
72
- 'pronounce': args[4] if args[4] else None,
73
- 'pronounce_error': args[5] if args[5] else "",
74
- 'interaction': args[9] if args[9] else None,
75
- 'note': args[10] if args[10] else "",
76
  }
77
  response = send_request_english(input_dict)
78
  return response["evaluation"].replace("**", '"')
79
 
80
  def gen_math(*args):
81
  input_dict = {
82
- 'reception': args[0] if args[0] else None,
83
- 'exercise_format_understanding': args[1] if args[1] else "",
84
- 'exercise_format_not_understanding': args[2] if args[2] else "",
85
- 'problem_solving_and_presentation': args[3] if args[3] else None,
86
- 'interaction': args[4] if args[4] else None,
87
- 'note': args[5] if args[5] else "",
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([1,2,3,4,5], value=3, label="Khả năng tiếp thu", show_label=True),
118
  ]
119
-
120
  with gr.Group():
121
  review += [
122
- gr.Radio([1,2,3,4,5], value=3, label="Ghi nhớ từ vựng mới", show_label=True),
123
- gr.Textbox(lines=1, label="Các từ vựng con ghi nhớ vận dụng", placeholder="Điền các từ vựng cách nhau bởi dấu chấm phẩy"),
124
- gr.Textbox(lines=1, label="Các từ vựng con chưa ghi nhớ", placeholder="Điền các từ vựng cách nhau bởi dấu chấm phẩy"),
125
  ]
 
126
  with gr.Group():
127
  review += [
128
- gr.Radio([1,2,3,4,5], value=3, label="Phát âm", show_label=True),
129
- gr.Textbox(lines=1, label="Lỗi phát âm con hay mắc khi nói", placeholder="Điền các lỗi phát âm cách nhau bởi dấu chấm phẩy"),
 
 
 
 
 
 
 
130
  ]
131
  with gr.Column():
132
  with gr.Group():
133
  review += [
134
- gr.Radio([1,2,3,4,5], value=3, label="Ghi nhớ cấu trúc mới", show_label=True),
135
- gr.Textbox(lines=1, label="Các cấu trúc con ghi nhớ và vận dụng", placeholder="Điền các cấu trúc cách nhau bởi dấu chấm phẩy"),
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="Khả năng tương tác", show_label=True),
141
  ]
142
  with gr.Group():
143
  review += [
144
- gr.Radio([
145
- "Học sinh thiếu tập trung, hay làm việc riêng trong lớp",
146
- "Mạng của học sinh kém ảnh hưởng tới chất lượng buổi học",
147
- "Học sinh thiếu lễ phép với thầy "
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="Nhận xét", show_copy_button=True)
153
 
154
- greet_btn = gr.Button("Tạo nhận xét")
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([1,2,3,4,5], value=3, label="Khả năng tiếp thu", show_label=True),
165
  ]
166
  with gr.Group():
167
  review += [
168
- gr.Textbox(lines=1, label="Con hiểu phương pháp cách trình bày về dạng bài", placeholder="Điền thông tin"),
169
  ]
170
  with gr.Group():
171
  review += [
172
- gr.Textbox(lines=1, label="Con cần luyện tập thêm về dạng bài", placeholder="Điền thông tin"),
 
 
173
  ]
174
  with gr.Column():
175
  with gr.Group():
176
  review += [
177
- gr.Radio([1,2,3,4,5], value=3, label="Giải quyết vấn đề & trình bày", show_label=True),
178
  ]
179
  with gr.Group():
180
  review += [
181
- gr.Radio([1,2,3,4,5], value=3, label="Khả năng tương tác", show_label=True),
182
  ]
183
  with gr.Group():
184
  review += [
185
- gr.Radio([
186
- "Học sinh thiếu tập trung, hay làm việc riêng trong lớp",
187
- "Mạng của học sinh kém ảnh hưởng tới chất lượng buổi học",
188
- "Học sinh thiếu lễ phép với thầy cô"
 
 
 
 
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
- with gr.Row():
201
- # --- Nhóm các thành phần nhập liệu ---
202
- with gr.Column():
203
- with gr.Group():
204
- review = [
205
- 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),
206
- ]
207
 
208
- with gr.Group():
209
- review += [
210
- 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),
211
- ]
212
- with gr.Group():
213
- review += [
214
- 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"),
215
- 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"),
216
- 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"),
217
- 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"),
218
- ]
219
 
220
- with gr.Column():
221
- with gr.Group():
222
- review += [
223
- 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),
224
- ]
225
- with gr.Group():
226
- review += [
227
- 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),
228
 
229
- ]
230
- with gr.Group():
231
- review += [
232
- 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),
233
- ]
234
 
235
 
236
- with gr.Group():
237
- review += [
238
- gr.CheckboxGroup([
239
- "Học sinh thiếu tập trung, hay làm việc riêng trong lớp",
240
- "Mạng của học sinh kém ảnh hưởng tới chất lượng buổi học",
241
- "Học sinh thiếu lễ phép với thầy cô",
242
- "Học sinh còn rụt rè, chưa tích cực phát biểu xây dựng bài"
243
- ], 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),
244
- ]
245
 
246
- with gr.Column():
247
- # debug_output = gr.Textbox(label="Thông tin đánh giá", show_copy_button=True)
248
- evaluation = gr.Textbox(label="Nhận xét", show_copy_button=True)
249
 
250
- greet_btn = gr.Button("Tạo nhận xét")
251
 
252
- greet_btn.click(gen_ielts, inputs=[*review], outputs=[evaluation])
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 ", 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 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 bài tập Workbook)",
231
+ "Cần tập trung hơn 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')))