pranav8tripathi Pragatik771 commited on
Commit
192cf42
Β·
verified Β·
1 Parent(s): 9ba8b63

Update main.py (#11)

Browse files

- Update main.py (1d5a62390b3eec595307ad854efab8ddb39c876e)


Co-authored-by: Kumrawat <Pragatik771@users.noreply.huggingface.co>

Files changed (1) hide show
  1. main.py +85 -84
main.py CHANGED
@@ -1,84 +1,85 @@
1
- """
2
- ResumeIQ - AI Resume Analyzer
3
- Main application entry point
4
- """
5
- import streamlit as st
6
- import os
7
- from dotenv import load_dotenv
8
-
9
- # Import modular components
10
- from ui.session_state import initialize_session_state
11
- from ui.file_upload import render_file_upload
12
- from ui.job_description import render_job_description_input
13
- from ui.results_display import display_results
14
- from ui.interview_scheduling import display_scheduled_interviews
15
- from core.analyzer import analyze_resumes
16
- from db.database import ResumeMatchDB
17
-
18
- # Load environment variables
19
- load_dotenv()
20
-
21
- # Page configuration
22
- st.set_page_config(page_title="AI Resume Analyzer", page_icon="πŸ“‹", layout="wide")
23
- st.title("πŸ“‹ AI Resume Analyzer")
24
-
25
- # Initialize session state
26
- initialize_session_state()
27
-
28
- # LLM Configuration
29
- DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
30
- DEEPSEEK_MODEL = os.getenv("DEEPSEEK_MODEL", "deepseek-chat")
31
- DEEPSEEK_BASE_URL = os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com")
32
-
33
- if not DEEPSEEK_API_KEY:
34
- st.warning("⚠️ DEEPSEEK_API_KEY not configured. Please set it in Hugging Face Space Settings β†’ Repository secrets.")
35
- st.info("πŸ’‘ Add `DEEPSEEK_API_KEY` as a secret in your Space settings to enable AI analysis.")
36
- # Don't stop - let the UI load so users can see the interface
37
-
38
- # Initialize database connection
39
- try:
40
- db = ResumeMatchDB()
41
- except Exception as e:
42
- st.error(f"❌ Database Connection Error: {str(e)}")
43
- db = None
44
-
45
- # File Upload Section
46
- uploaded_files = render_file_upload()
47
-
48
- # Job Description Section
49
- job_descriptions = render_job_description_input()
50
-
51
- # Analysis Status
52
- if uploaded_files or job_descriptions:
53
- with st.expander("πŸ“Š Ready to Analyze", expanded=False):
54
- st.write(f"**Resumes loaded:** {len(uploaded_files) if uploaded_files else 0}")
55
- st.write(f"**Job descriptions:** {len(job_descriptions) if job_descriptions else 0}")
56
- if job_descriptions:
57
- for idx, jd in enumerate(job_descriptions):
58
- st.write(f" - {jd['title']} ({len(jd['content'])} characters)")
59
-
60
- # Analyze Button
61
- if uploaded_files and job_descriptions:
62
- if st.button("πŸ” Analyze Resumes"):
63
- analyze_resumes(
64
- uploaded_files,
65
- job_descriptions,
66
- DEEPSEEK_API_KEY,
67
- DEEPSEEK_MODEL,
68
- DEEPSEEK_BASE_URL
69
- )
70
- elif uploaded_files and not job_descriptions:
71
- st.warning("⚠️ Please enter or upload a job description before analyzing resumes.")
72
- elif not uploaded_files and job_descriptions:
73
- st.warning("⚠️ Please upload resumes before analyzing.")
74
-
75
- # Display Results in Tabs
76
- if st.session_state.results:
77
- st.divider()
78
- tab1, tab2 = st.tabs(["πŸ“Š Analysis Results", "πŸ“… Upcoming Interviews"])
79
-
80
- with tab1:
81
- display_results()
82
-
83
- with tab2:
84
- display_scheduled_interviews()
 
 
1
+ """
2
+ ResumeIQ - AI Resume Analyzer
3
+ Main application entry point
4
+ """
5
+ import streamlit as st
6
+ import os
7
+ from dotenv import load_dotenv
8
+
9
+ # Import modular components
10
+ from ui.session_state import initialize_session_state
11
+ from ui.file_upload import render_file_upload
12
+ from ui.job_description import render_job_description_input
13
+ from ui.results_display import display_results
14
+ from ui.interview_scheduling import display_scheduled_interviews
15
+ from core.analyzer import analyze_resumes
16
+ from db.database import ResumeMatchDB
17
+
18
+ # Load environment variables
19
+ load_dotenv()
20
+
21
+ # Page configuration
22
+ st.set_page_config(page_title="AI Resume Analyzer", page_icon="πŸ“‹", layout="wide")
23
+ st.title("πŸ“‹ AI Resume Analyzer")
24
+
25
+ # Initialize session state
26
+ initialize_session_state()
27
+
28
+ # LLM Configuration
29
+ DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
30
+ DEEPSEEK_MODEL = os.getenv("DEEPSEEK_MODEL", "deepseek-chat")
31
+ DEEPSEEK_BASE_URL = os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com")
32
+
33
+ if not DEEPSEEK_API_KEY:
34
+ st.warning("⚠️ DEEPSEEK_API_KEY not configured. Please set it in Hugging Face Space Settings β†’ Repository secrets.")
35
+ st.info("πŸ’‘ Add `DEEPSEEK_API_KEY` as a secret in your Space settings to enable AI analysis.")
36
+ # Don't stop - let the UI load so users can see the interface
37
+
38
+ # Initialize database connection
39
+ try:
40
+ db = ResumeMatchDB()
41
+ except Exception as e:
42
+ st.error(f"❌ Database Connection Error: {str(e)}")
43
+ db = None
44
+
45
+ # File Upload Section
46
+ uploaded_files = render_file_upload()
47
+
48
+ # Job Description Section
49
+ job_descriptions = render_job_description_input()
50
+
51
+ # Analysis Status
52
+ if uploaded_files or job_descriptions:
53
+ with st.expander("πŸ“Š Ready to Analyze", expanded=False):
54
+ st.write(f"**Resumes loaded:** {len(uploaded_files) if uploaded_files else 0}")
55
+ st.write(f"**Job descriptions:** {len(job_descriptions) if job_descriptions else 0}")
56
+ if job_descriptions:
57
+ for idx, jd in enumerate(job_descriptions):
58
+ st.write(f" - {jd['title']} ({len(jd['content'])} characters)")
59
+
60
+ # Analyze Button
61
+ if uploaded_files and job_descriptions:
62
+ if st.button("πŸ” Analyze Resumes"):
63
+ analyze_resumes(
64
+ uploaded_files,
65
+ job_descriptions,
66
+ DEEPSEEK_API_KEY,
67
+ DEEPSEEK_MODEL,
68
+ DEEPSEEK_BASE_URL
69
+ )
70
+ elif uploaded_files and not job_descriptions:
71
+ st.warning("⚠️ Please enter or upload a job description before analyzing resumes.")
72
+ elif not uploaded_files and job_descriptions:
73
+ st.warning("⚠️ Please upload resumes before analyzing.")
74
+
75
+ # Display Content in Tabs
76
+ st.divider()
77
+ if st.session_state.results:
78
+ tab1, tab2 = st.tabs(["πŸ“Š Analysis Results", "πŸ“… Upcoming Interviews"])
79
+ with tab1:
80
+ display_results()
81
+ with tab2:
82
+ display_scheduled_interviews()
83
+ else:
84
+ # If no results yet, just show upcoming interviews
85
+ display_scheduled_interviews()