Spaces:
Runtime error
Runtime error
Update src/app.py
Browse files- 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
|
| 628 |
"π Overview", "π― Skills Analysis", "π Section Breakdown",
|
| 629 |
-
"π ATS Analysis", "π Report & Suggestions"
|
| 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 |
-
|
| 877 |
-
|
| 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 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 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 |
-
#
|
| 894 |
-
|
| 895 |
-
|
| 896 |
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
|
|
|
|
|
|
| 905 |
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
|
|
|
|
|
|
|
|
|
| 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)}")
|