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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +90 -0
app.py CHANGED
@@ -40,6 +40,25 @@ def send_request_math(input_dict):
40
 
41
  return response.json()
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  def gen_english(*args):
45
  input_dict = {
@@ -69,6 +88,22 @@ def gen_math(*args):
69
  }
70
  response = send_request_math(input_dict)
71
  return response["evaluation"].replace("**", '"')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
 
74
  with gr.Blocks() as demo:
@@ -160,6 +195,61 @@ with gr.Blocks() as demo:
160
  greet_btn = gr.Button("Tạo nhận xét")
161
 
162
  greet_btn.click(gen_math, inputs=[*review], outputs=[evaluation])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
 
 
164
  if __name__ == "__main__":
165
  demo.launch(auth=(os.getenv('username'), os.getenv('password')))
 
40
 
41
  return response.json()
42
 
43
+ def send_request_ielts(input_dict):
44
+
45
+ headers = {
46
+ 'accept': 'application/json',
47
+ 'access-key': os.getenv('access_key'),
48
+ 'Content-Type': 'application/json',
49
+ }
50
+
51
+ json_data = input_dict
52
+ print(json_data)
53
+
54
+ response = requests.post(
55
+ 'https://dev-tutor-chatbot.vuihoc.vn/api/generate_evaluation_ielts',
56
+ headers=headers,
57
+ json=json_data,
58
+ )
59
+
60
+ return response.json()
61
+
62
 
63
  def gen_english(*args):
64
  input_dict = {
 
88
  }
89
  response = send_request_math(input_dict)
90
  return response["evaluation"].replace("**", '"')
91
+
92
+ def gen_ielts(*args):
93
+ input_dict = {
94
+ 'concentration': args[0] if args[0] else None,
95
+ 'participation': args[1] if args[1] else None,
96
+ 'exercise_need_improve': args[2] if args[2] else "",
97
+ 'grammar_need_improve': args[3] if args[3] else "",
98
+ 'structure_need_improve': args[4] if args[4] else "",
99
+ 'vocabulary_need_improve': args[5] if args[5] else "",
100
+ 'remember_apply_vocab_grammar': args[6] if args[6] else None,
101
+ 'remember_apply_strategies': args[7] if args[7] else None,
102
+ 'pronounce': args[8] if args[8] else None,
103
+ 'note': args[9] if args[9] else "",
104
+ }
105
+ response = send_request_ielts(input_dict)
106
+ return response["evaluation"].replace("**", '"')
107
 
108
 
109
  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')))