tahirsher commited on
Commit
884344e
1 Parent(s): 3add62e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -59,9 +59,15 @@ if "profile_data" in st.session_state:
59
 
60
  if st.button("Submit Question"):
61
  if question:
62
- answer = run_with_timeout(qa_pipeline, timeout=5, question=question, context=str(jobs_dataset)) # Using jobs dataset as context
63
- if answer:
64
- st.write(f"Answer: {answer['answer']}")
 
 
 
 
 
 
65
  else:
66
  st.warning("Please enter a question.")
67
 
@@ -86,4 +92,3 @@ if "profile_data" in st.session_state:
86
  course_skills = [skill.lower() for skill in course["Skills"]] if course["Skills"] is not None else []
87
  if any(interest in course["Title"].lower() for interest in interests):
88
  st.write(f"- **{course['Title']}** by {course['Organization']}. [Link to course]({course['course_url']})")
89
-
 
59
 
60
  if st.button("Submit Question"):
61
  if question:
62
+ # Filter context based on interests or skills
63
+ relevant_jobs = [job for job in jobs_dataset if any(interest in job["job_title"].lower() for interest in [i.strip().lower() for i in st.session_state.profile_data["interests"].split(",")])]
64
+ context = " ".join([job["job_description"] for job in relevant_jobs if "job_description" in job]) # Creating a context from relevant job descriptions
65
+ if context:
66
+ answer = run_with_timeout(qa_pipeline, timeout=10, question=question, context=context) # Using a longer timeout
67
+ if answer:
68
+ st.write(f"Answer: {answer['answer']}")
69
+ else:
70
+ st.warning("No relevant jobs found to answer your question.")
71
  else:
72
  st.warning("Please enter a question.")
73
 
 
92
  course_skills = [skill.lower() for skill in course["Skills"]] if course["Skills"] is not None else []
93
  if any(interest in course["Title"].lower() for interest in interests):
94
  st.write(f"- **{course['Title']}** by {course['Organization']}. [Link to course]({course['course_url']})")