rushankg commited on
Commit
da3cb05
Β·
verified Β·
1 Parent(s): 0d26b2d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +123 -0
app.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import tempfile
4
+ from pathlib import Path
5
+ import time
6
+ from typing import List, Dict
7
+ import pandas as pd
8
+
9
+ # Initialize Streamlit app
10
+ st.set_page_config(
11
+ page_title="IntraTalent Resume Processor",
12
+ page_icon="πŸ“„",
13
+ layout="wide"
14
+ )
15
+
16
+ def save_uploaded_file(uploaded_file) -> str:
17
+ """Save uploaded file to temporary directory and return path."""
18
+ try:
19
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.pdf') as tmp_file:
20
+ tmp_file.write(uploaded_file.getvalue())
21
+ return tmp_file.name
22
+ except Exception as e:
23
+ st.error(f"Error saving file: {e}")
24
+ return None
25
+
26
+ def process_resumes(uploaded_files: List[st.UploadedFile]) -> Dict:
27
+ """Process multiple resumes and return results."""
28
+ results = {}
29
+ progress_bar = st.progress(0)
30
+
31
+ for idx, file in enumerate(uploaded_files):
32
+ if file.type != "application/pdf":
33
+ st.warning(f"Skipping {file.name}: Not a PDF file")
34
+ continue
35
+
36
+ temp_path = save_uploaded_file(file)
37
+ if temp_path:
38
+ try:
39
+ name, projects = parse_resume(temp_path)
40
+ results[file.name] = {
41
+ "name": name,
42
+ "projects": projects
43
+ }
44
+ # Update progress
45
+ progress_bar.progress((idx + 1) / len(uploaded_files))
46
+ except Exception as e:
47
+ st.error(f"Error processing {file.name}: {e}")
48
+ finally:
49
+ # Clean up temporary file
50
+ os.unlink(temp_path)
51
+
52
+ return results
53
+
54
+ def display_results(results: Dict):
55
+ """Display processed resume results in an organized manner."""
56
+ if not results:
57
+ return
58
+
59
+ st.subheader("Processed Resumes")
60
+
61
+ for filename, data in results.items():
62
+ with st.expander(f"πŸ“„ {data['name']} ({filename})"):
63
+ if data['projects']:
64
+ df = pd.DataFrame(data['projects'])
65
+ st.dataframe(
66
+ df,
67
+ column_config={
68
+ "name": "Project Name",
69
+ "description": "Description"
70
+ },
71
+ hide_index=True
72
+ )
73
+ else:
74
+ st.info("No projects found in this resume")
75
+
76
+ def main():
77
+ st.title("IntraTalent Resume Processor")
78
+
79
+ # File uploader section
80
+ st.header("Upload Resumes")
81
+ uploaded_files = st.file_uploader(
82
+ "Upload up to 10 resumes (PDF only)",
83
+ type=['pdf'],
84
+ accept_multiple_files=True,
85
+ key="resume_uploader"
86
+ )
87
+
88
+ # Validate number of files
89
+ if len(uploaded_files) > 10:
90
+ st.error("Maximum 10 files allowed. Please remove some files.")
91
+ return
92
+
93
+ # Process button
94
+ if uploaded_files and st.button("Process Resumes"):
95
+ with st.spinner("Processing resumes..."):
96
+ results = process_resumes(uploaded_files)
97
+ st.session_state['processed_results'] = results
98
+ display_results(results)
99
+
100
+ # Query section
101
+ st.header("Search Projects")
102
+ query = st.text_area(
103
+ "Enter your project requirements",
104
+ placeholder="Example: Looking for team members with experience in machine learning and computer vision...",
105
+ height=100
106
+ )
107
+
108
+ if query and st.button("Search"):
109
+ if 'processed_results' not in st.session_state:
110
+ st.warning("Please process some resumes first!")
111
+ return
112
+
113
+ with st.spinner("Searching for matches..."):
114
+ # Here you would implement the embedding and similarity search
115
+ # Using the code from your original script
116
+ st.success("Search completed!")
117
+ # Display results in a nice format
118
+ st.subheader("Top Matches")
119
+ # Placeholder for search results
120
+ st.info("Feature coming soon: Will display matching projects and candidates based on similarity search")
121
+
122
+ if __name__ == "__main__":
123
+ main()