Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,10 +57,18 @@ def get_course_recommendations(stanine, gwa, strand, hobbies):
|
|
| 57 |
return "Sorry, the recommendation system is not available at the moment. Please try again later."
|
| 58 |
|
| 59 |
try:
|
| 60 |
-
# Validate inputs
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
if not (1 <= stanine <= 9):
|
| 65 |
return "β Stanine score must be between 1 and 9"
|
| 66 |
|
|
@@ -70,7 +78,7 @@ def get_course_recommendations(stanine, gwa, strand, hobbies):
|
|
| 70 |
if not strand:
|
| 71 |
return "β Please select a strand"
|
| 72 |
|
| 73 |
-
if not hobbies.strip():
|
| 74 |
return "β Please enter your hobbies/interests"
|
| 75 |
|
| 76 |
# Get recommendations
|
|
@@ -142,26 +150,39 @@ with gr.Blocks(title="PSAU AI Chatbot & Course Recommender", theme=gr.themes.Sof
|
|
| 142 |
"When is the application deadline?",
|
| 143 |
"How much is the tuition fee?",
|
| 144 |
"Do you offer scholarships?",
|
| 145 |
-
"What courses are available?"
|
|
|
|
|
|
|
|
|
|
| 146 |
],
|
| 147 |
cache_examples=True
|
| 148 |
)
|
| 149 |
|
| 150 |
# Course Recommender Tab
|
| 151 |
with gr.Tab("π― Course Recommender"):
|
| 152 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
with gr.Row():
|
| 155 |
with gr.Column():
|
| 156 |
-
stanine_input = gr.
|
| 157 |
-
minimum=1, maximum=9, step=1, value=7,
|
| 158 |
label="Stanine Score (1-9)",
|
| 159 |
-
|
|
|
|
|
|
|
| 160 |
)
|
| 161 |
-
gwa_input = gr.
|
| 162 |
-
minimum=75, maximum=100, step=0.1, value=85.0,
|
| 163 |
label="GWA (75-100)",
|
| 164 |
-
|
|
|
|
|
|
|
| 165 |
)
|
| 166 |
strand_input = gr.Dropdown(
|
| 167 |
choices=["STEM", "ABM", "HUMSS"],
|
|
|
|
| 57 |
return "Sorry, the recommendation system is not available at the moment. Please try again later."
|
| 58 |
|
| 59 |
try:
|
| 60 |
+
# Validate and convert inputs
|
| 61 |
+
try:
|
| 62 |
+
stanine = int(stanine.strip()) if stanine else 0
|
| 63 |
+
except (ValueError, AttributeError):
|
| 64 |
+
return "β Stanine score must be a valid number between 1 and 9"
|
| 65 |
|
| 66 |
+
try:
|
| 67 |
+
gwa = float(gwa.strip()) if gwa else 0
|
| 68 |
+
except (ValueError, AttributeError):
|
| 69 |
+
return "β GWA must be a valid number between 75 and 100"
|
| 70 |
+
|
| 71 |
+
# Validate ranges
|
| 72 |
if not (1 <= stanine <= 9):
|
| 73 |
return "β Stanine score must be between 1 and 9"
|
| 74 |
|
|
|
|
| 78 |
if not strand:
|
| 79 |
return "β Please select a strand"
|
| 80 |
|
| 81 |
+
if not hobbies or not hobbies.strip():
|
| 82 |
return "β Please enter your hobbies/interests"
|
| 83 |
|
| 84 |
# Get recommendations
|
|
|
|
| 150 |
"When is the application deadline?",
|
| 151 |
"How much is the tuition fee?",
|
| 152 |
"Do you offer scholarships?",
|
| 153 |
+
"What courses are available?",
|
| 154 |
+
"What is the minimum GWA requirement?",
|
| 155 |
+
"How can I contact the admissions office?",
|
| 156 |
+
"Is there a dormitory available?"
|
| 157 |
],
|
| 158 |
cache_examples=True
|
| 159 |
)
|
| 160 |
|
| 161 |
# Course Recommender Tab
|
| 162 |
with gr.Tab("π― Course Recommender"):
|
| 163 |
+
gr.Markdown("""
|
| 164 |
+
Get personalized course recommendations based on your academic profile and interests!
|
| 165 |
+
|
| 166 |
+
**Input Guidelines:**
|
| 167 |
+
- **Stanine Score**: Enter a number between 1-9 (from your entrance exam)
|
| 168 |
+
- **GWA**: Enter your General Weighted Average (75-100)
|
| 169 |
+
- **Strand**: Select your senior high school strand
|
| 170 |
+
- **Hobbies**: Describe your interests and hobbies in detail
|
| 171 |
+
""")
|
| 172 |
|
| 173 |
with gr.Row():
|
| 174 |
with gr.Column():
|
| 175 |
+
stanine_input = gr.Textbox(
|
|
|
|
| 176 |
label="Stanine Score (1-9)",
|
| 177 |
+
placeholder="Enter your stanine score (1-9)",
|
| 178 |
+
info="Your stanine score from entrance examination",
|
| 179 |
+
value="7"
|
| 180 |
)
|
| 181 |
+
gwa_input = gr.Textbox(
|
|
|
|
| 182 |
label="GWA (75-100)",
|
| 183 |
+
placeholder="Enter your GWA (75-100)",
|
| 184 |
+
info="Your General Weighted Average",
|
| 185 |
+
value="85.0"
|
| 186 |
)
|
| 187 |
strand_input = gr.Dropdown(
|
| 188 |
choices=["STEM", "ABM", "HUMSS"],
|