Spaces:
Sleeping
Sleeping
phucpx
commited on
Commit
·
6479586
1
Parent(s):
c38947c
Add application file
Browse files
app.py
CHANGED
|
@@ -6,30 +6,28 @@ LCG_SERVICE_URL_v1 = "http://bore.testsprep.online:8082/v1/theory_lcg"
|
|
| 6 |
LCG_SERVICE_URL_v2 = "http://bore.testsprep.online:8081/v1/theory_lcg"
|
| 7 |
LCG_SERVICE_URL_v3 = "http://bore.testsprep.online:8083/v1/theory_lcg"
|
| 8 |
|
| 9 |
-
|
| 10 |
MODEL2SERVICE = {
|
| 11 |
'llama-3.1-sft-awq': LCG_SERVICE_URL_v1,
|
| 12 |
'hermes-3-llama3.1-sft-lora': LCG_SERVICE_URL_v2,
|
| 13 |
'qwen2-1.5b-full-sft': LCG_SERVICE_URL_v3
|
| 14 |
}
|
| 15 |
|
| 16 |
-
|
| 17 |
weights_mapping = {
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
}
|
| 34 |
|
| 35 |
template_los = """0. Identify the challenges in Matching sentence endings: More endings than questions, Some endings may be grammatically correct but not connected to the main ideas in the text, Information for possible endings is placed randomly in the passage
|
|
@@ -73,7 +71,9 @@ def get_response_message(config):
|
|
| 73 |
except:
|
| 74 |
return {"message": f"Hiện tại chúng tôi chưa hỗ trợ mô hình {config['model_name']}."}
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
if mode == "Reviewing" and not context.strip():
|
| 78 |
return {"error": "Với chế độ Reviewing, Context không được để trống."}
|
| 79 |
|
|
@@ -94,13 +94,14 @@ def generate_questions(model_name, user_level, num_questions, question_type, lan
|
|
| 94 |
iface = gr.Interface(
|
| 95 |
fn=generate_questions,
|
| 96 |
inputs=[
|
| 97 |
-
gr.Dropdown(list(MODEL2SERVICE.keys()), label="Model Usage"),
|
| 98 |
-
gr.Dropdown(["beginner", "intermediate", "advanced"], label="User Level"),
|
| 99 |
gr.Number(value=5, label="Number of Questions"),
|
| 100 |
gr.Dropdown(["Short answer", "Single choice", "Multiple choice"], label="Question Type"),
|
| 101 |
gr.Dropdown(["English", "Vietnamese"], label="Language"),
|
| 102 |
gr.Dropdown(["English", "Vietnamese"], label="Explanation Language"),
|
| 103 |
-
gr.Textbox(lines=5, placeholder="Enter context here...",
|
|
|
|
| 104 |
gr.Textbox(lines=5, value=template_los, label="Learning Outcomes"),
|
| 105 |
gr.Dropdown(["Reviewing", "Practicing"], label="Mode")
|
| 106 |
],
|
|
|
|
| 6 |
LCG_SERVICE_URL_v2 = "http://bore.testsprep.online:8081/v1/theory_lcg"
|
| 7 |
LCG_SERVICE_URL_v3 = "http://bore.testsprep.online:8083/v1/theory_lcg"
|
| 8 |
|
|
|
|
| 9 |
MODEL2SERVICE = {
|
| 10 |
'llama-3.1-sft-awq': LCG_SERVICE_URL_v1,
|
| 11 |
'hermes-3-llama3.1-sft-lora': LCG_SERVICE_URL_v2,
|
| 12 |
'qwen2-1.5b-full-sft': LCG_SERVICE_URL_v3
|
| 13 |
}
|
| 14 |
|
|
|
|
| 15 |
weights_mapping = {
|
| 16 |
+
'beginner': {
|
| 17 |
+
'easy': 0.6,
|
| 18 |
+
'medium': 0.2,
|
| 19 |
+
'hard': 0.2
|
| 20 |
+
},
|
| 21 |
+
'intermediate': {
|
| 22 |
+
'easy': 0.2,
|
| 23 |
+
'medium': 0.6,
|
| 24 |
+
'hard': 0.2
|
| 25 |
+
},
|
| 26 |
+
'advanced': {
|
| 27 |
+
'easy': 0.2,
|
| 28 |
+
'medium': 0.2,
|
| 29 |
+
'hard': 0.6
|
| 30 |
+
}
|
| 31 |
}
|
| 32 |
|
| 33 |
template_los = """0. Identify the challenges in Matching sentence endings: More endings than questions, Some endings may be grammatically correct but not connected to the main ideas in the text, Information for possible endings is placed randomly in the passage
|
|
|
|
| 71 |
except:
|
| 72 |
return {"message": f"Hiện tại chúng tôi chưa hỗ trợ mô hình {config['model_name']}."}
|
| 73 |
|
| 74 |
+
|
| 75 |
+
def generate_questions(model_name, user_level, num_questions, question_type, language, explanation_language, context,
|
| 76 |
+
learning_outcomes, mode):
|
| 77 |
if mode == "Reviewing" and not context.strip():
|
| 78 |
return {"error": "Với chế độ Reviewing, Context không được để trống."}
|
| 79 |
|
|
|
|
| 94 |
iface = gr.Interface(
|
| 95 |
fn=generate_questions,
|
| 96 |
inputs=[
|
| 97 |
+
gr.Dropdown(list(MODEL2SERVICE.keys()), label="Model Usage", value=0),
|
| 98 |
+
gr.Dropdown(["beginner", "intermediate", "advanced"], label="User Level", value=0),
|
| 99 |
gr.Number(value=5, label="Number of Questions"),
|
| 100 |
gr.Dropdown(["Short answer", "Single choice", "Multiple choice"], label="Question Type"),
|
| 101 |
gr.Dropdown(["English", "Vietnamese"], label="Language"),
|
| 102 |
gr.Dropdown(["English", "Vietnamese"], label="Explanation Language"),
|
| 103 |
+
gr.Textbox(lines=5, placeholder="Enter context here...",
|
| 104 |
+
label="Context (Lesson content or Reading comprehension passage)"),
|
| 105 |
gr.Textbox(lines=5, value=template_los, label="Learning Outcomes"),
|
| 106 |
gr.Dropdown(["Reviewing", "Practicing"], label="Mode")
|
| 107 |
],
|