DreamStream-1 commited on
Commit
5f224c7
·
verified ·
1 Parent(s): a9521a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -19
app.py CHANGED
@@ -7,6 +7,7 @@ import re
7
  import google.generativeai as genai
8
  from sklearn.feature_extraction.text import TfidfVectorizer
9
  from sklearn.metrics.pairwise import cosine_similarity
 
10
  import json
11
 
12
  # Load pre-trained embedding model for basic analysis
@@ -80,11 +81,11 @@ def analyze_with_gemini(resume_text, job_desc):
80
  # Handle parsing errors
81
  return {
82
  "Candidate Name": "Unknown",
83
- "Relevant Skills": "Failed to extract",
84
- "Educational Background": "Failed to extract",
85
- "Leadership Experience (years)": "Failed to extract",
86
- "Management Experience (years)": "Failed to extract",
87
- "Management Skills": "Failed to extract",
88
  "Summary": response.text.strip()
89
  }
90
 
@@ -161,25 +162,20 @@ def process_resumes(job_desc_file, resumes):
161
  "Gemini Analysis": gemini_analysis["Summary"]
162
  })
163
 
164
- # Format results for display
165
- output = "\n\n".join(
166
- f"**{res['Resume']}**\n"
167
- f"Overall Score: {res['Overall Score']}%\n"
168
- f"Similarity (Embed): {res['Similarity (Embed)']}%\n"
169
- f"Match Percentage (TF-IDF): {res['Match Percentage (TF-IDF)']}%\n"
170
- f"Leadership Experience (years): {res['Leadership Experience (years)']} years\n"
171
- f"Management Experience (years): {res['Management Experience (years)']} years\n"
172
- f"Management Skills (combined): {res['Management Skills']}\n"
173
- f"Gemini Analysis:\n{res['Gemini Analysis']}\n"
174
- for res in results
175
- )
176
- return output
177
 
178
  # Gradio Interface
179
  job_desc_input = gr.File(label="Upload Job Description (TXT, PDF, DOCX)", type="filepath")
180
  resumes_input = gr.Files(label="Upload Resumes (TXT, PDF, DOCX)", type="filepath")
181
 
182
- results_output = gr.Textbox(label="Analysis Results", lines=30)
183
 
184
  interface = gr.Interface(
185
  fn=process_resumes,
 
7
  import google.generativeai as genai
8
  from sklearn.feature_extraction.text import TfidfVectorizer
9
  from sklearn.metrics.pairwise import cosine_similarity
10
+ import pandas as pd
11
  import json
12
 
13
  # Load pre-trained embedding model for basic analysis
 
81
  # Handle parsing errors
82
  return {
83
  "Candidate Name": "Unknown",
84
+ "Relevant Skills": "Failed",
85
+ "Educational Background": "Failed",
86
+ "Leadership Experience (years)": "Failed",
87
+ "Management Experience (years)": "Failed",
88
+ "Management Skills": "Failed",
89
  "Summary": response.text.strip()
90
  }
91
 
 
162
  "Gemini Analysis": gemini_analysis["Summary"]
163
  })
164
 
165
+ # Convert results to pandas DataFrame
166
+ df = pd.DataFrame(results)
167
+
168
+ # Save DataFrame to CSV
169
+ csv_file = "/tmp/analysis_results.csv"
170
+ df.to_csv(csv_file, index=False)
171
+
172
+ return csv_file
 
 
 
 
 
173
 
174
  # Gradio Interface
175
  job_desc_input = gr.File(label="Upload Job Description (TXT, PDF, DOCX)", type="filepath")
176
  resumes_input = gr.Files(label="Upload Resumes (TXT, PDF, DOCX)", type="filepath")
177
 
178
+ results_output = gr.File(label="Download Analysis Results (CSV)")
179
 
180
  interface = gr.Interface(
181
  fn=process_resumes,