File size: 4,427 Bytes
cb366d6
 
 
 
 
 
 
 
 
 
 
 
 
 
815bee6
 
 
102e49d
815bee6
 
 
 
 
 
 
 
 
 
 
102e49d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815bee6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
title: TalentLensAI
emoji: πŸƒ
colorFrom: red
colorTo: green
sdk: streamlit
sdk_version: 1.43.1
app_file: app.py
pinned: false
license: apache-2.0
short_description: 'AI - Powered Resume Screening Bot Application '
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

TalentLensAI is an AI-powered resume screening and evaluation tool that leverages Hugging Face models for summarization and scoring. It integrates with Supabase for candidate data storage and utilizes Streamlit for an interactive user interface.

## Features

Resume Summarization: Uses Facebook's BART model (facebook/bart-large-cnn) to generate a concise summary of the resume.

Candidate Scoring: Evaluates resumes using Google's Gemma model (google/gemma-7b) to determine their relevance to the job description.

Database Integration: Stores candidate information, resume summary, and scores in Supabase.

PDF Report Generation: Generates a PDF report summarizing the evaluation results.

Streamlit UI: Provides a user-friendly interface for uploading resumes and reviewing results.

## Deployment Notes

### SpaCy Model Handling
The application uses spaCy for natural language processing. To handle deployment environments where the `en_core_web_sm` model might not be available:

- The spaCy model is automatically downloaded via requirements.txt
- A fallback system (`utils/spacy_loader.py`) provides graceful degradation
- If spaCy is unavailable, the system uses regex-based extraction methods

### Hugging Face Spaces Deployment
For Hugging Face Spaces deployment, the following files are configured:

- `requirements.txt`: Includes direct spaCy model download link
- `packages.txt`: System dependencies for spaCy compilation
- `utils/spacy_loader.py`: Robust model loading with fallbacks
- NumPy version pinned to `<2.0` for compatibility

## Setup Instructions

1. Clone the Repository
```
git clone https://github.com/yourusername/TalentLensAI.git
cd TalentLensAI
```

2. Create a Virtual Environment and Install Dependencies
```
python -m venv myenv
source myenv/bin/activate  # On Windows use `myenv\Scripts\activate`
pip install -r requirements.txt
```

3. Configure Environment Variables

Create a .env file in the root directory and add the following:
```
HUGGINGFACE_API_KEY=your_huggingface_api_key
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_anon_key
```

4. Run the Application
```
streamlit run main.py
```
Updated Functionality

Querying Hugging Face Models

The application now supports querying both gemma-7b and bart-large-cnn models:

def query(payload, model="gemma"):
    if model not in HF_MODELS:
        raise ValueError("Invalid model name. Choose 'gemma' or 'bart'.")
    
    api_url = f"https://api-inference.huggingface.co/models/{HF_MODELS[model]}"
    try:
        response = requests.post(api_url, headers=HF_HEADERS, json=payload)
        if response.status_code == 401:
            print(f"❌ Unauthorized: Check your Hugging Face API key for model '{model}'.")
            return None
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"❌ Error querying Hugging Face model '{model}': {e}")
        return None

Fixed Issues & Improvements

Fixed UnboundLocalError by ensuring response is always initialized before use.

Handled 401 Unauthorized errors by validating the Hugging Face API key at startup.

Enhanced Supabase Integration to prevent null values from violating constraints.

Modularized st.markdown styling for a better Streamlit UI experience.

Database Schema

The candidates table in Supabase is structured as follows:

CREATE TABLE candidates (
    id SERIAL PRIMARY KEY,
    resume_filename TEXT NOT NULL,
    email TEXT NOT NULL,
    name TEXT NOT NULL,
    resume_text TEXT NOT NULL,
    score FLOAT NOT NULL,
    created_at TIMESTAMP DEFAULT NOW(),
    summary TEXT NOT NULL
);

Testing

Unit tests are implemented using pytest. Run tests with:

pytest tests/

Roadmap

βœ… Multi-model support for Hugging Face APIs

βœ… Improved error handling for API failures

πŸ”œ Enhance the resume parsing for better job-specific keyword extraction

πŸ”œ Implement email notifications for shortlisted candidates

Contributors

Gaurav Sharma
Jonathan Nguyen

License

This project is licensed under the MIT License - see the LICENSE file for details.