Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -5,30 +5,30 @@ import torch
|
|
| 5 |
|
| 6 |
# Theme
|
| 7 |
theme = gr.themes.Soft(
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
)
|
| 12 |
|
| 13 |
custom_css = """
|
| 14 |
:root {
|
| 15 |
-
|
| 16 |
}
|
| 17 |
.dark {
|
| 18 |
-
|
| 19 |
}
|
| 20 |
"""
|
| 21 |
|
| 22 |
# Load research file
|
| 23 |
with open("research.txt", "r", encoding="utf-8") as file:
|
| 24 |
-
|
| 25 |
|
| 26 |
# Preprocess text
|
| 27 |
def preprocess_text(text):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
cleaned_chunks = preprocess_text(research_text)
|
| 34 |
|
|
@@ -36,444 +36,175 @@ cleaned_chunks = preprocess_text(research_text)
|
|
| 36 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 37 |
|
| 38 |
def create_embeddings(text_chunks):
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
chunk_embeddings = create_embeddings(cleaned_chunks)
|
| 43 |
|
| 44 |
# Get top chunks
|
| 45 |
def get_top_chunks(query, chunk_embeddings, text_chunks):
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
# Inference client
|
| 55 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
| 56 |
|
| 57 |
def respond(message, history):
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
def display_image():
|
| 74 |
-
|
| 75 |
|
| 76 |
# Explore Page Info
|
| 77 |
def show_info(topic):
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
|
| 87 |
# Resources Page
|
| 88 |
def resource_block(career):
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
("Probability – Khan Academy", "https://www.khanacademy.org/math/statistics-probability"),
|
| 168 |
-
("Statistical Tools – OpenIntro", "https://www.openintro.org/book/os/")
|
| 169 |
-
],
|
| 170 |
-
"college": {
|
| 171 |
-
"major": "Statistics, Mathematics",
|
| 172 |
-
"classes": [
|
| 173 |
-
"Probability Theory",
|
| 174 |
-
"Statistical Inference",
|
| 175 |
-
"Regression Analysis",
|
| 176 |
-
"Experimental Design",
|
| 177 |
-
"Data Analysis with R"
|
| 178 |
-
]
|
| 179 |
-
}
|
| 180 |
-
},
|
| 181 |
-
"Biomedical Engineer": {
|
| 182 |
-
"links": [
|
| 183 |
-
("Biomedical Research – JHU BME", "https://www.bme.jhu.edu/"),
|
| 184 |
-
("Medical Devices – edX Courses", "https://www.edx.org/learn/biomedical-engineering"),
|
| 185 |
-
("Clinical Trials – NIH", "https://www.nih.gov/")
|
| 186 |
-
],
|
| 187 |
-
"college": {
|
| 188 |
-
"major": "Biomedical Engineering, Bioengineering",
|
| 189 |
-
"classes": [
|
| 190 |
-
"Biomaterials",
|
| 191 |
-
"Human Physiology",
|
| 192 |
-
"Medical Instrumentation",
|
| 193 |
-
"Biomechanics",
|
| 194 |
-
"Tissue Engineering"
|
| 195 |
-
]
|
| 196 |
-
}
|
| 197 |
-
},
|
| 198 |
-
"Mechanical Engineer": {
|
| 199 |
-
"links": [
|
| 200 |
-
("CAD Design – Coursera", "https://www.coursera.org/learn/cad-design"),
|
| 201 |
-
("Thermodynamics – MIT OpenCourseWare", "https://ocw.mit.edu/courses/thermodynamics"),
|
| 202 |
-
("Materials Science Basics – edX", "https://www.edx.org/course/material-science")
|
| 203 |
-
],
|
| 204 |
-
"college": {
|
| 205 |
-
"major": "Mechanical Engineering",
|
| 206 |
-
"classes": [
|
| 207 |
-
"Thermodynamics",
|
| 208 |
-
"Fluid Mechanics",
|
| 209 |
-
"Materials Science",
|
| 210 |
-
"Computer-Aided Design (CAD)",
|
| 211 |
-
"Dynamics and Control"
|
| 212 |
-
]
|
| 213 |
-
}
|
| 214 |
-
},
|
| 215 |
-
"Environmental Scientist": {
|
| 216 |
-
"links": [
|
| 217 |
-
("Environmental Science – Khan Academy", "https://www.khanacademy.org/science/biology/ecology"),
|
| 218 |
-
("GIS Basics – Esri Training", "https://www.esri.com/training/catalog/57630435851d31e02a43f1c5/gis-basics/"),
|
| 219 |
-
("Data Analysis – Coursera", "https://www.coursera.org/learn/data-analysis")
|
| 220 |
-
],
|
| 221 |
-
"college": {
|
| 222 |
-
"major": "Environmental Science, Ecology",
|
| 223 |
-
"classes": [
|
| 224 |
-
"Ecology",
|
| 225 |
-
"Environmental Chemistry",
|
| 226 |
-
"Geographic Information Systems (GIS)",
|
| 227 |
-
"Data Analysis",
|
| 228 |
-
"Environmental Policy"
|
| 229 |
-
]
|
| 230 |
-
}
|
| 231 |
-
},
|
| 232 |
-
"Operations Research Analyst": {
|
| 233 |
-
"links": [
|
| 234 |
-
("Linear Programming – Khan Academy", "https://www.khanacademy.org/computing/computer-science/algorithms"),
|
| 235 |
-
("Optimization – MIT OpenCourseWare", "https://ocw.mit.edu/courses/optimization-methods"),
|
| 236 |
-
("Statistics – Harvard Online", "https://online-learning.harvard.edu/course/statistics-and-r")
|
| 237 |
-
],
|
| 238 |
-
"college": {
|
| 239 |
-
"major": "Operations Research, Applied Mathematics",
|
| 240 |
-
"classes": [
|
| 241 |
-
"Optimization Theory",
|
| 242 |
-
"Linear Programming",
|
| 243 |
-
"Probability",
|
| 244 |
-
"Statistics",
|
| 245 |
-
"Simulation Modeling"
|
| 246 |
-
]
|
| 247 |
-
}
|
| 248 |
-
},
|
| 249 |
-
"Mathematician": {
|
| 250 |
-
"links": [
|
| 251 |
-
("Abstract Algebra – MIT OpenCourseWare", "https://ocw.mit.edu/courses/abstract-algebra"),
|
| 252 |
-
("Calculus – Khan Academy", "https://www.khanacademy.org/math/calculus-1"),
|
| 253 |
-
("Proof Techniques – Coursera", "https://www.coursera.org/learn/proofs")
|
| 254 |
-
],
|
| 255 |
-
"college": {
|
| 256 |
-
"major": "Mathematics",
|
| 257 |
-
"classes": [
|
| 258 |
-
"Algebra",
|
| 259 |
-
"Calculus",
|
| 260 |
-
"Real Analysis",
|
| 261 |
-
"Abstract Algebra",
|
| 262 |
-
"Proof Writing"
|
| 263 |
-
]
|
| 264 |
-
}
|
| 265 |
-
},
|
| 266 |
-
"Chemical Engineer": {
|
| 267 |
-
"links": [
|
| 268 |
-
("Chemical Process Principles – MIT OCW", "https://ocw.mit.edu/courses/chemical-engineering"),
|
| 269 |
-
("Organic Chemistry – Khan Academy", "https://www.khanacademy.org/science/organic-chemistry"),
|
| 270 |
-
("Thermodynamics – Coursera", "https://www.coursera.org/learn/thermodynamics")
|
| 271 |
-
],
|
| 272 |
-
"college": {
|
| 273 |
-
"major": "Chemical Engineering",
|
| 274 |
-
"classes": [
|
| 275 |
-
"Organic Chemistry",
|
| 276 |
-
"Thermodynamics",
|
| 277 |
-
"Process Design",
|
| 278 |
-
"Fluid Mechanics",
|
| 279 |
-
"Chemical Reaction Engineering"
|
| 280 |
-
]
|
| 281 |
-
}
|
| 282 |
-
},
|
| 283 |
-
"Civil Engineer": {
|
| 284 |
-
"links": [
|
| 285 |
-
("Structural Analysis – Coursera", "https://www.coursera.org/learn/structural-analysis"),
|
| 286 |
-
("Construction Management – edX", "https://www.edx.org/course/construction-management"),
|
| 287 |
-
("AutoCAD – LinkedIn Learning", "https://www.linkedin.com/learning/topics/autocad")
|
| 288 |
-
],
|
| 289 |
-
"college": {
|
| 290 |
-
"major": "Civil Engineering",
|
| 291 |
-
"classes": [
|
| 292 |
-
"Structural Analysis",
|
| 293 |
-
"Construction Materials",
|
| 294 |
-
"Soil Mechanics",
|
| 295 |
-
"AutoCAD",
|
| 296 |
-
"Hydraulics"
|
| 297 |
-
]
|
| 298 |
-
}
|
| 299 |
-
},
|
| 300 |
-
"Electrical Engineer": {
|
| 301 |
-
"links": [
|
| 302 |
-
("Circuits and Electronics – MIT OCW", "https://ocw.mit.edu/courses/electrical-engineering-and-computer-science"),
|
| 303 |
-
("Signals and Systems – Coursera", "https://www.coursera.org/learn/signals-systems"),
|
| 304 |
-
("Electromagnetics – Khan Academy", "https://www.khanacademy.org/science/electrical-engineering")
|
| 305 |
-
],
|
| 306 |
-
"college": {
|
| 307 |
-
"major": "Electrical Engineering",
|
| 308 |
-
"classes": [
|
| 309 |
-
"Circuits",
|
| 310 |
-
"Signals and Systems",
|
| 311 |
-
"Electromagnetics",
|
| 312 |
-
"Control Systems",
|
| 313 |
-
"Digital Logic Design"
|
| 314 |
-
]
|
| 315 |
-
}
|
| 316 |
-
},
|
| 317 |
-
"Software Developer": {
|
| 318 |
-
"links": [
|
| 319 |
-
("CS50 – Harvard", "https://cs50.harvard.edu"),
|
| 320 |
-
("Learn to Code – Codecademy", "https://www.codecademy.com/catalog/subject/all"),
|
| 321 |
-
("Algorithms – Coursera", "https://www.coursera.org/learn/algorithms-part1")
|
| 322 |
-
],
|
| 323 |
-
"college": {
|
| 324 |
-
"major": "Computer Science, Software Engineering",
|
| 325 |
-
"classes": [
|
| 326 |
-
"Introduction to Computer Science (CS50)",
|
| 327 |
-
"Data Structures and Algorithms",
|
| 328 |
-
"Operating Systems",
|
| 329 |
-
"Software Engineering",
|
| 330 |
-
"Databases"
|
| 331 |
-
]
|
| 332 |
-
}
|
| 333 |
-
},
|
| 334 |
-
"Pharmacist": {
|
| 335 |
-
"links": [
|
| 336 |
-
("Pharmacology Basics – Coursera", "https://www.coursera.org/learn/pharmacology"),
|
| 337 |
-
("Drug Development – edX", "https://www.edx.org/course/drug-development"),
|
| 338 |
-
("Pharmacy Practice – FutureLearn", "https://www.futurelearn.com/courses/pharmacy-practice")
|
| 339 |
-
],
|
| 340 |
-
"college": {
|
| 341 |
-
"major": "Pharmacy, Pharmaceutical Sciences",
|
| 342 |
-
"classes": [
|
| 343 |
-
"Pharmacology",
|
| 344 |
-
"Medicinal Chemistry",
|
| 345 |
-
"Pharmaceutical Calculations",
|
| 346 |
-
"Pharmaceutics",
|
| 347 |
-
"Clinical Pharmacy"
|
| 348 |
-
]
|
| 349 |
-
}
|
| 350 |
-
},
|
| 351 |
-
"Physicist": {
|
| 352 |
-
"links": [
|
| 353 |
-
("Classical Mechanics – MIT OCW", "https://ocw.mit.edu/courses/physics"),
|
| 354 |
-
("Quantum Mechanics – edX", "https://www.edx.org/course/quantum-mechanics"),
|
| 355 |
-
("Thermodynamics – Khan Academy", "https://www.khanacademy.org/science/physics/thermodynamics")
|
| 356 |
-
],
|
| 357 |
-
"college": {
|
| 358 |
-
"major": "Physics",
|
| 359 |
-
"classes": [
|
| 360 |
-
"Classical Mechanics",
|
| 361 |
-
"Quantum Mechanics",
|
| 362 |
-
"Thermodynamics",
|
| 363 |
-
"Electromagnetism",
|
| 364 |
-
"Mathematical Methods for Physicists"
|
| 365 |
-
]
|
| 366 |
-
}
|
| 367 |
-
},
|
| 368 |
-
"Astronomer": {
|
| 369 |
-
"links": [
|
| 370 |
-
("Introduction to Astronomy – Coursera", "https://www.coursera.org/learn/astronomy"),
|
| 371 |
-
("Astrophysics – edX", "https://www.edx.org/course/astrophysics"),
|
| 372 |
-
("Cosmology – Khan Academy", "https://www.khanacademy.org/science/cosmology-and-astronomy")
|
| 373 |
-
],
|
| 374 |
-
"college": {
|
| 375 |
-
"major": "Astronomy, Astrophysics, Physics",
|
| 376 |
-
"classes": [
|
| 377 |
-
"Introduction to Astronomy",
|
| 378 |
-
"Astrophysics",
|
| 379 |
-
"Cosmology",
|
| 380 |
-
"Observational Astronomy",
|
| 381 |
-
"Data Analysis in Astronomy"
|
| 382 |
-
]
|
| 383 |
-
}
|
| 384 |
-
},
|
| 385 |
-
"Geologist": {
|
| 386 |
-
"links": [
|
| 387 |
-
("Physical Geology – OpenStax", "https://openstax.org/details/books/physical-geology"),
|
| 388 |
-
("Geochemistry – Coursera", "https://www.coursera.org/learn/geochemistry"),
|
| 389 |
-
("GIS Mapping – Esri Training", "https://www.esri.com/training/catalog/57630435851d31e02a43f1c5/gis-basics/")
|
| 390 |
-
],
|
| 391 |
-
"college": {
|
| 392 |
-
"major": "Geology, Earth Science",
|
| 393 |
-
"classes": [
|
| 394 |
-
"Physical Geology",
|
| 395 |
-
"Mineralogy and Petrology",
|
| 396 |
-
"Geochemistry",
|
| 397 |
-
"GIS and Remote Sensing",
|
| 398 |
-
"Structural Geology"
|
| 399 |
-
]
|
| 400 |
-
}
|
| 401 |
-
},
|
| 402 |
-
"Biochemist": {
|
| 403 |
-
"links": [
|
| 404 |
-
("Biochemistry – MIT OCW", "https://ocw.mit.edu/courses/biochemistry"),
|
| 405 |
-
("Molecular Biology – Coursera", "https://www.coursera.org/learn/molecular-biology"),
|
| 406 |
-
("Enzymology – Khan Academy", "https://www.khanacademy.org/science/biology")
|
| 407 |
-
],
|
| 408 |
-
"college": {
|
| 409 |
-
"major": "Biochemistry, Molecular Biology",
|
| 410 |
-
"classes": [
|
| 411 |
-
"General Biochemistry",
|
| 412 |
-
"Molecular Biology",
|
| 413 |
-
"Enzymology",
|
| 414 |
-
"Cell Biology",
|
| 415 |
-
"Genetics"
|
| 416 |
-
]
|
| 417 |
-
}
|
| 418 |
-
}
|
| 419 |
-
}
|
| 420 |
-
|
| 421 |
-
content = resources.get(career)
|
| 422 |
-
if not content:
|
| 423 |
-
return "Select a career to see resources.", ""
|
| 424 |
-
|
| 425 |
-
link_html = "<h4>Skills & Learning Resources</h4><ul>"
|
| 426 |
-
for label, url in content["links"]:
|
| 427 |
-
link_html += f"<li><strong>{label}</strong>: <a href='{url}' target='_blank'>{url}</a></li>"
|
| 428 |
-
link_html += "</ul><br>"
|
| 429 |
-
|
| 430 |
-
college_html = ""
|
| 431 |
-
if "college" in content:
|
| 432 |
-
college = content["college"]
|
| 433 |
-
college_html += "<h4>College & Classes</h4><ul>"
|
| 434 |
-
college_html += f"<li><strong>Majors:</strong> {college['major']}</li>"
|
| 435 |
-
college_html += f"<li><strong>Helpful Classes:</strong> {', '.join(college['classes'])}</li>"
|
| 436 |
-
college_html += "</ul><br>"
|
| 437 |
-
|
| 438 |
-
video_embed = yt_videos.get(career, "")
|
| 439 |
-
return link_html + college_html, video_embed
|
| 440 |
|
| 441 |
# UI Layout
|
| 442 |
with gr.Blocks(theme=theme, css=custom_css) as chatbot:
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
|
| 479 |
chatbot.launch()
|
|
|
|
| 5 |
|
| 6 |
# Theme
|
| 7 |
theme = gr.themes.Soft(
|
| 8 |
+
primary_hue="rose",
|
| 9 |
+
secondary_hue="zinc",
|
| 10 |
+
neutral_hue="pink"
|
| 11 |
)
|
| 12 |
|
| 13 |
custom_css = """
|
| 14 |
:root {
|
| 15 |
+
--background-fill-primary: #FFB6C2 !important;
|
| 16 |
}
|
| 17 |
.dark {
|
| 18 |
+
--background-fill-primary: #FFB6C1 !important;
|
| 19 |
}
|
| 20 |
"""
|
| 21 |
|
| 22 |
# Load research file
|
| 23 |
with open("research.txt", "r", encoding="utf-8") as file:
|
| 24 |
+
research_text = file.read()
|
| 25 |
|
| 26 |
# Preprocess text
|
| 27 |
def preprocess_text(text):
|
| 28 |
+
cleaned_text = text.strip()
|
| 29 |
+
chunks = cleaned_text.split("\n")
|
| 30 |
+
cleaned_chunks = [chunk.strip() for chunk in chunks if chunk.strip() != ""]
|
| 31 |
+
return cleaned_chunks
|
| 32 |
|
| 33 |
cleaned_chunks = preprocess_text(research_text)
|
| 34 |
|
|
|
|
| 36 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 37 |
|
| 38 |
def create_embeddings(text_chunks):
|
| 39 |
+
chunk_embeddings = model.encode(text_chunks, convert_to_tensor=True)
|
| 40 |
+
return chunk_embeddings
|
| 41 |
|
| 42 |
chunk_embeddings = create_embeddings(cleaned_chunks)
|
| 43 |
|
| 44 |
# Get top chunks
|
| 45 |
def get_top_chunks(query, chunk_embeddings, text_chunks):
|
| 46 |
+
query_embedding = model.encode(query, convert_to_tensor=True)
|
| 47 |
+
query_embedding_normalized = query_embedding / query_embedding.norm()
|
| 48 |
+
chunk_embeddings_normalized = chunk_embeddings / chunk_embeddings.norm(dim=1, keepdim=True)
|
| 49 |
+
similarities = torch.matmul(chunk_embeddings_normalized, query_embedding_normalized)
|
| 50 |
+
top_indices = torch.topk(similarities, k=3).indices
|
| 51 |
+
top_chunks = [text_chunks[i] for i in top_indices]
|
| 52 |
+
return top_chunks
|
| 53 |
|
| 54 |
# Inference client
|
| 55 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
| 56 |
|
| 57 |
def respond(message, history):
|
| 58 |
+
top_results = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 59 |
+
str_top_results = '\n'.join(top_results)
|
| 60 |
+
messages = [
|
| 61 |
+
{'role': 'system', 'content': f'You are a chatbot. Complete all your sentences, do not be blunt, and do not cut yourself off. The word limit is 100 words. Start off by giving a career in a complete, kind sentence, and then if prompted by the user provide more information like salary, college course,etc. Base your response on the provided context:\n{str_top_results}'}
|
| 62 |
+
]
|
| 63 |
+
if history:
|
| 64 |
+
messages.extend(history)
|
| 65 |
+
messages.append({'role': 'user', 'content': message})
|
| 66 |
+
response = client.chat_completion(
|
| 67 |
+
messages,
|
| 68 |
+
max_tokens=1000,
|
| 69 |
+
temperature=0.2
|
| 70 |
+
)
|
| 71 |
+
return response['choices'][0]['message']['content'].strip()
|
| 72 |
|
| 73 |
def display_image():
|
| 74 |
+
return "KWKbanner.png"
|
| 75 |
|
| 76 |
# Explore Page Info
|
| 77 |
def show_info(topic):
|
| 78 |
+
responses = {
|
| 79 |
+
"Highest Paying STEM Jobs": "1. AI/Machine Learning Engineer – $171,774\n2. Cloud Solutions Architect – $150,241\n3. Quantitative Analyst (Quant) – $139,949\n4. Data Scientist – $128,115\n5. Actuary – $128,147",
|
| 80 |
+
"Most Flexible STEM Jobs": "1. Software Developer\n2. Cloud Solutions Architect\n3. Data Scientist\n4. Cybersecurity Analyst\n5. Statistician",
|
| 81 |
+
"Most Creative STEM Jobs": "1. Software Developer\n2. AI/Machine Learning Engineer\n3. Biomedical Engineer\n4. Mechanical Engineer\n5. Biochemist",
|
| 82 |
+
"Fastest Growing STEM Jobs": "1. AI/Machine Learning Engineer\n2. Cybersecurity Analyst\n3. Data Scientist\n4. Software Developer\n5. Cloud Solutions Architect",
|
| 83 |
+
"Low-Stress STEM Jobs": "1. Statistician\n2. Mathematician\n3. Operations Research Analyst\n4. Environmental Scientist\n5. Biochemist"
|
| 84 |
+
}
|
| 85 |
+
return responses.get(topic, "Select a category to see the corresponding careers.")
|
| 86 |
|
| 87 |
# Resources Page
|
| 88 |
def resource_block(career):
|
| 89 |
+
yt_videos = {
|
| 90 |
+
"AI/Machine Learning Engineer": '<iframe width="100%" height="315" src="https://www.youtube.com/embed/ukzFI9rgwfU" title="AI Career Advice" frameborder="0" allowfullscreen></iframe>',
|
| 91 |
+
"Data Scientist": '<iframe width="100%" height="315" src="https://www.youtube.com/embed/xC-c7E5PK0Y" title="Day in the Life of Data Scientist" frameborder="0" allowfullscreen></iframe>',
|
| 92 |
+
"Cloud Solutions Architect": '<iframe width="100%" height="315" src="https://www.youtube.com/embed/COgFYt6GxC4" title="Become a Cloud Architect" frameborder="0" allowfullscreen></iframe>'
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
resources = {
|
| 96 |
+
"AI/Machine Learning Engineer": {
|
| 97 |
+
"links": [
|
| 98 |
+
("Neural Networks – DeepLearning.AI", "https://www.deeplearning.ai"),
|
| 99 |
+
("Build ML Models – Fast.ai", "https://www.fast.ai"),
|
| 100 |
+
("Machine Learning – Stanford CS229", "https://cs229.stanford.edu/")
|
| 101 |
+
],
|
| 102 |
+
"college": {
|
| 103 |
+
"major": "Computer Science, Data Science",
|
| 104 |
+
"classes": [
|
| 105 |
+
"CS50: Introduction to Computer Science (Harvard)",
|
| 106 |
+
"Linear Algebra",
|
| 107 |
+
"Probability and Statistics",
|
| 108 |
+
"Machine Learning (Stanford CS229)",
|
| 109 |
+
"Algorithms"
|
| 110 |
+
]
|
| 111 |
+
}
|
| 112 |
+
},
|
| 113 |
+
"Data Scientist": {
|
| 114 |
+
"links": [
|
| 115 |
+
("Python & Pandas – Kaggle Learn", "https://www.kaggle.com/learn"),
|
| 116 |
+
("R Programming – Harvard Data Science", "https://online-learning.harvard.edu/series/data-science"),
|
| 117 |
+
("Project Practice – DataCamp", "https://www.datacamp.com")
|
| 118 |
+
],
|
| 119 |
+
"college": {
|
| 120 |
+
"major": "Data Science, Statistics, Computer Science",
|
| 121 |
+
"classes": [
|
| 122 |
+
"Introduction to Data Science",
|
| 123 |
+
"Statistics and Probability",
|
| 124 |
+
"Data Mining",
|
| 125 |
+
"Machine Learning",
|
| 126 |
+
"Database Systems"
|
| 127 |
+
]
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"Cloud Solutions Architect": {
|
| 131 |
+
"links": [
|
| 132 |
+
("AWS Skills – AWS Training", "https://aws.amazon.com/training/"),
|
| 133 |
+
("Azure Certifications – Microsoft Learn", "https://learn.microsoft.com/en-us/certifications/"),
|
| 134 |
+
("Google Cloud Labs – Google Cloud Boost", "https://cloudskillsboost.google/")
|
| 135 |
+
],
|
| 136 |
+
"college": {
|
| 137 |
+
"major": "Computer Science, Information Technology",
|
| 138 |
+
"classes": [
|
| 139 |
+
"Cloud Computing Fundamentals",
|
| 140 |
+
"Computer Networks",
|
| 141 |
+
"Systems Design",
|
| 142 |
+
"Information Security",
|
| 143 |
+
"Operating Systems"
|
| 144 |
+
]
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
content = resources.get(career)
|
| 150 |
+
if not content:
|
| 151 |
+
return "Select a career to see resources.", ""
|
| 152 |
+
|
| 153 |
+
link_html = "<h4>Skills</h4><ul>"
|
| 154 |
+
for label, url in content["links"]:
|
| 155 |
+
link_html += f"<li><strong>{label}</strong>: <a href='{url}' target='_blank'>{url}</a></li>"
|
| 156 |
+
link_html += "</ul><br><hr><br>"
|
| 157 |
+
|
| 158 |
+
college_html = "<h4>College & Classes</h4><ul>"
|
| 159 |
+
college_html += f"<li><strong>Majors:</strong> {content['college']['major']}</li>"
|
| 160 |
+
college_html += "<li><strong>Helpful Classes:</strong><ul>"
|
| 161 |
+
for cls in content['college']['classes']:
|
| 162 |
+
college_html += f"<li>{cls}</li>"
|
| 163 |
+
college_html += "</ul></li></ul><br><hr><br>"
|
| 164 |
+
|
| 165 |
+
video_embed = yt_videos.get(career, "")
|
| 166 |
+
return link_html + college_html, video_embed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
# UI Layout
|
| 169 |
with gr.Blocks(theme=theme, css=custom_css) as chatbot:
|
| 170 |
+
gr.Image(display_image)
|
| 171 |
+
|
| 172 |
+
with gr.Tab("ChatBot"):
|
| 173 |
+
gr.ChatInterface(
|
| 174 |
+
respond,
|
| 175 |
+
type="messages",
|
| 176 |
+
title="Hi, I'm Path Pilot!",
|
| 177 |
+
textbox=gr.Textbox(placeholder="Share your interests and explore more on your career of choice!"),
|
| 178 |
+
description='This tool provides information on STEM Careers. All information is sourced from [census.gov](https://www.census.gov/).'
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
with gr.Tab("Explore Now"):
|
| 182 |
+
gr.Markdown("### Explore STEM Career Categories")
|
| 183 |
+
dropdown_explore = gr.Dropdown(
|
| 184 |
+
choices=[
|
| 185 |
+
"Highest Paying STEM Jobs",
|
| 186 |
+
"Most Flexible STEM Jobs",
|
| 187 |
+
"Most Creative STEM Jobs",
|
| 188 |
+
"Fastest Growing STEM Jobs",
|
| 189 |
+
"Low-Stress STEM Jobs"
|
| 190 |
+
],
|
| 191 |
+
label="Choose a Category"
|
| 192 |
+
)
|
| 193 |
+
output_explore = gr.Markdown()
|
| 194 |
+
dropdown_explore.change(fn=show_info, inputs=dropdown_explore, outputs=output_explore)
|
| 195 |
+
|
| 196 |
+
with gr.Tab("Resources"):
|
| 197 |
+
gr.Markdown("### Career-Specific Educational Resources")
|
| 198 |
+
dropdown_resources = gr.Dropdown(
|
| 199 |
+
choices=[
|
| 200 |
+
"AI/Machine Learning Engineer",
|
| 201 |
+
"Data Scientist",
|
| 202 |
+
"Cloud Solutions Architect"
|
| 203 |
+
],
|
| 204 |
+
label="Choose a Career"
|
| 205 |
+
)
|
| 206 |
+
output_links = gr.HTML()
|
| 207 |
+
output_video = gr.HTML()
|
| 208 |
+
dropdown_resources.change(fn=resource_block, inputs=dropdown_resources, outputs=[output_links, output_video])
|
| 209 |
|
| 210 |
chatbot.launch()
|