ZainabFatimaa commited on
Commit
efdcce5
Β·
verified Β·
1 Parent(s): d1a1c63

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +97 -54
src/app.py CHANGED
@@ -570,6 +570,19 @@ def main():
570
  # Initialize analyzer
571
  try:
572
  analyzer = ResumeAnalyzer()
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  except Exception as e:
574
  st.error(f"Error initializing analyzer: {str(e)}")
575
  return
@@ -584,6 +597,8 @@ def main():
584
  st.session_state.chat_history = []
585
  if "resume_context" not in st.session_state:
586
  st.session_state.resume_context = ""
 
 
587
 
588
  # File upload section
589
  st.header("πŸ“ Upload Your Resume")
@@ -624,9 +639,9 @@ def main():
624
  ats_score = analyzer.calculate_ats_score(text, sections)
625
 
626
  # Create tabs for different analyses
627
- tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs([
628
  "πŸ“Š Overview", "🎯 Skills Analysis", "πŸ“ Section Breakdown",
629
- "πŸ” ATS Analysis", "πŸ“‹ Report & Suggestions", "πŸ€– AI Assistant"
630
  ])
631
 
632
  with tab1:
@@ -699,6 +714,27 @@ def main():
699
  title='Technical Skills Found')
700
  fig.update_xaxis(tickangle=45)
701
  st.plotly_chart(fig, use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
  else:
703
  st.warning("No soft skills detected")
704
  st.info("πŸ’‘ Consider highlighting soft skills like leadership, communication, teamwork")
@@ -873,63 +909,70 @@ def main():
873
  except Exception as e:
874
  st.error(f"Error generating PDF: {str(e)}")
875
 
876
- with tab6:
877
- st.header("πŸ€– AI Assistant Chat")
878
-
 
 
 
 
 
 
879
  if not os.getenv('OPENROUTER_API_KEY'):
880
  st.error("Claude API key not configured. Please set OPENROUTER_API_KEY environment variable.")
881
- return
882
-
883
- # Display chat history
884
- for chat in st.session_state.chat_history:
885
- with st.chat_message(chat["role"]):
886
- st.markdown(chat["content"])
887
-
888
- # Chat input
889
- if prompt := st.chat_input("Ask me anything about your resume..."):
890
- # Add user message to chat history
891
- st.session_state.chat_history.append({"role": "user", "content": prompt})
892
 
893
- # Display user message
894
- with st.chat_message("user"):
895
- st.markdown(prompt)
896
 
897
- # Generate AI response
898
- with st.chat_message("assistant"):
899
- with st.spinner("Thinking..."):
900
- response = analyzer.chatbot.generate_response(
901
- prompt,
902
- st.session_state.resume_context
903
- )
904
- st.markdown(response)
 
 
905
 
906
- # Add assistant response to chat history
907
- st.session_state.chat_history.append({"role": "assistant", "content": response})
908
-
909
- # Suggested questions
910
- st.subheader("πŸ’‘ Suggested Questions")
911
- col1, col2 = st.columns(2)
912
-
913
- with col1:
914
- if st.button("How can I improve my resume?"):
915
- st.session_state.chat_history.append({
916
- "role": "user",
917
- "content": "How can I improve my resume?"
918
- })
919
- st.experimental_rerun()
920
-
921
- with col2:
922
- if st.button("What skills should I add?"):
923
- st.session_state.chat_history.append({
924
- "role": "user",
925
- "content": f"What skills should I add for a {selected_role} position?"
926
- })
927
- st.experimental_rerun()
928
-
929
- # Clear chat button
930
- if st.button("πŸ—‘οΈ Clear Chat History"):
931
- st.session_state.chat_history = []
932
- st.experimental_rerun()
 
 
 
933
 
934
  except Exception as e:
935
  st.error(f"Error during analysis: {str(e)}")
 
570
  # Initialize analyzer
571
  try:
572
  analyzer = ResumeAnalyzer()
573
+ # Add ML/AI Engineer to job keywords
574
+ analyzer.job_keywords["Machine Learning Engineer"] = [
575
+ "python", "tensorflow", "pytorch", "scikit-learn", "pandas", "numpy", "machine learning",
576
+ "deep learning", "neural networks", "computer vision", "nlp", "data science", "algorithms",
577
+ "statistics", "linear algebra", "calculus", "regression", "classification", "clustering",
578
+ "feature engineering", "model deployment", "mlops", "docker", "kubernetes", "aws", "gcp"
579
+ ]
580
+ analyzer.job_keywords["AI Engineer"] = [
581
+ "artificial intelligence", "machine learning", "deep learning", "neural networks", "python",
582
+ "tensorflow", "pytorch", "computer vision", "nlp", "natural language processing", "opencv",
583
+ "transformers", "bert", "gpt", "reinforcement learning", "generative ai", "llm", "chatbot",
584
+ "model optimization", "ai ethics", "edge ai", "quantization", "onnx", "tensorrt"
585
+ ]
586
  except Exception as e:
587
  st.error(f"Error initializing analyzer: {str(e)}")
588
  return
 
597
  st.session_state.chat_history = []
598
  if "resume_context" not in st.session_state:
599
  st.session_state.resume_context = ""
600
+ if "show_chat" not in st.session_state:
601
+ st.session_state.show_chat = False
602
 
603
  # File upload section
604
  st.header("πŸ“ Upload Your Resume")
 
639
  ats_score = analyzer.calculate_ats_score(text, sections)
640
 
641
  # Create tabs for different analyses
642
+ tab1, tab2, tab3, tab4, tab5 = st.tabs([
643
  "πŸ“Š Overview", "🎯 Skills Analysis", "πŸ“ Section Breakdown",
644
+ "πŸ” ATS Analysis", "πŸ“‹ Report & Suggestions"
645
  ])
646
 
647
  with tab1:
 
714
  title='Technical Skills Found')
715
  fig.update_xaxis(tickangle=45)
716
  st.plotly_chart(fig, use_container_width=True)
717
+ else:
718
+ st.warning("No technical skills detected")
719
+ st.info("πŸ’‘ Consider adding technical skills relevant to your field")
720
+
721
+ with col2:
722
+ st.subheader("🀝 Soft Skills")
723
+ if soft_skills:
724
+ skills_text = " β€’ ".join(soft_skills)
725
+ st.success(f"Found {len(soft_skills)} soft skills:")
726
+ st.write(skills_text)
727
+
728
+ if len(soft_skills) > 3:
729
+ soft_df = pd.DataFrame({
730
+ 'Skill': soft_skills[:8],
731
+ 'Count': [1] * len(soft_skills[:8])
732
+ })
733
+ fig = px.bar(soft_df, x='Skill', y='Count',
734
+ title='Soft Skills Found',
735
+ color='Skill')
736
+ fig.update_xaxis(tickangle=45)
737
+ st.plotly_chart(fig, use_container_width=True)
738
  else:
739
  st.warning("No soft skills detected")
740
  st.info("πŸ’‘ Consider highlighting soft skills like leadership, communication, teamwork")
 
909
  except Exception as e:
910
  st.error(f"Error generating PDF: {str(e)}")
911
 
912
+ # AI Assistant Chat Section (Outside of tabs)
913
+ st.markdown("---")
914
+ st.header("πŸ€– AI Assistant Chat")
915
+
916
+ # Toggle chat visibility
917
+ if st.button("πŸ’¬ Toggle AI Assistant Chat"):
918
+ st.session_state.show_chat = not st.session_state.show_chat
919
+
920
+ if st.session_state.show_chat:
921
  if not os.getenv('OPENROUTER_API_KEY'):
922
  st.error("Claude API key not configured. Please set OPENROUTER_API_KEY environment variable.")
923
+ else:
924
+ # Display chat history
925
+ chat_container = st.container()
926
+ with chat_container:
927
+ for chat in st.session_state.chat_history:
928
+ with st.chat_message(chat["role"]):
929
+ st.markdown(chat["content"])
 
 
 
 
930
 
931
+ # Suggested questions
932
+ st.subheader("πŸ’‘ Suggested Questions")
933
+ col1, col2, col3 = st.columns(3)
934
 
935
+ with col1:
936
+ if st.button("How can I improve my resume?"):
937
+ prompt = "How can I improve my resume?"
938
+ st.session_state.chat_history.append({"role": "user", "content": prompt})
939
+
940
+ with st.spinner("Thinking..."):
941
+ response = analyzer.chatbot.generate_response(prompt, st.session_state.resume_context)
942
+
943
+ st.session_state.chat_history.append({"role": "assistant", "content": response})
944
+ st.rerun()
945
 
946
+ with col2:
947
+ if st.button("What skills should I add?"):
948
+ prompt = f"What skills should I add for a {selected_role} position?"
949
+ st.session_state.chat_history.append({"role": "user", "content": prompt})
950
+
951
+ with st.spinner("Thinking..."):
952
+ response = analyzer.chatbot.generate_response(prompt, st.session_state.resume_context)
953
+
954
+ st.session_state.chat_history.append({"role": "assistant", "content": response})
955
+ st.rerun()
956
+
957
+ with col3:
958
+ if st.button("πŸ—‘οΈ Clear Chat History"):
959
+ st.session_state.chat_history = []
960
+ st.rerun()
961
+
962
+ # Chat input (outside of tabs)
963
+ if prompt := st.chat_input("Ask me anything about your resume..."):
964
+ # Add user message to chat history
965
+ st.session_state.chat_history.append({"role": "user", "content": prompt})
966
+
967
+ # Generate AI response
968
+ with st.spinner("Thinking..."):
969
+ response = analyzer.chatbot.generate_response(prompt, st.session_state.resume_context)
970
+
971
+ # Add assistant response to chat history
972
+ st.session_state.chat_history.append({"role": "assistant", "content": response})
973
+
974
+ # Rerun to show new messages
975
+ st.rerun()
976
 
977
  except Exception as e:
978
  st.error(f"Error during analysis: {str(e)}")