File size: 1,279 Bytes
30b3b49
f3f0a69
 
 
 
 
30b3b49
2600a8c
30b3b49
f3f0a69
30b3b49
f3f0a69
 
 
30b3b49
f3f0a69
 
 
 
 
30b3b49
f3f0a69
 
 
 
 
 
 
 
 
 
 
 
30b3b49
e11a248
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
from database import get_db, Candidate
from resume_parser import extract_text_from_pdf
from ai_model import analyze_resume
from pdf_generator import generate_summary_pdf
from sqlalchemy.orm import Session

st.title("AI-Powered Resume Screening")

uploaded_files = st.file_uploader("Upload Resumes", type=["pdf"], accept_multiple_files=True)

if uploaded_files:
    db: Session = next(get_db())
    candidates = []
    
    for file in uploaded_files:
        resume_text = extract_text_from_pdf(file)
        analysis_result = analyze_resume(resume_text)
        score = int(analysis_result.get("score", 0))
        summary = analysis_result.get("summary", "No summary available")
        
        new_candidate = Candidate(name=file.name, score=score, summary=summary, resume_text=resume_text)
        db.add(new_candidate)
        candidates.append(new_candidate)
    
    db.commit()
    
    # Generate shortlist
    shortlisted = sorted(candidates, key=lambda x: x.score, reverse=True)[:5]
    pdf_path = generate_summary_pdf(shortlisted)
    
    st.success("Top candidates shortlisted!")
    st.download_button("Download Shortlist PDF", open(pdf_path, "rb"), file_name="shortlisted_candidates.pdf")

    # the link expiration time is set to 24 hours