Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import os
|
| 3 |
from cv_analyzer import analyze_cv
|
| 4 |
from cv_quality import CV
|
| 5 |
from get_supabase import Supabase
|
|
@@ -15,23 +14,18 @@ supabase_client = Supabase().init_supabase_client()
|
|
| 15 |
BUCKET_NAME = "CVs UX"
|
| 16 |
SUPABASE_PROJECT_ID = "abjtqzgnrtsikkqgnqeg"
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
# Upload file to Supabase storage
|
| 23 |
-
file_path = f"{uploaded_file.name}"
|
| 24 |
-
|
| 25 |
-
with uploaded_file as f:
|
| 26 |
-
supabase_client.storage.from_(BUCKET_NAME).upload(
|
| 27 |
-
file=f,
|
| 28 |
-
path=file_path,
|
| 29 |
-
file_options={"cache-control": "3600", "upsert": "true"}
|
| 30 |
-
)
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
|
| 34 |
-
file_url = f"https://{SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/{BUCKET_NAME}/{
|
| 35 |
|
| 36 |
# Create CV object with the file URL
|
| 37 |
cv = CV(file_url)
|
|
@@ -41,23 +35,19 @@ if uploaded_file is not None:
|
|
| 41 |
st.error(result["error"])
|
| 42 |
else:
|
| 43 |
# Display results
|
| 44 |
-
# Personal Information
|
| 45 |
st.header("Personal Information")
|
| 46 |
personal_info = result["personal_info"]
|
| 47 |
st.json(personal_info)
|
| 48 |
st.write(f"Personal Information Score: {personal_info['personal_info_score']}")
|
| 49 |
|
| 50 |
-
# Detected Sections
|
| 51 |
st.header("Detected Sections")
|
| 52 |
st.write(result["detected_sections"])
|
| 53 |
st.write(f"Section Detection Score: {result['section_detection_score']}")
|
| 54 |
|
| 55 |
-
# Spelling and Grammar
|
| 56 |
st.header("Spelling and Grammar")
|
| 57 |
st.write(f"Error Percentage: {result['spelling_grammar_error_percentage']:.2f}%")
|
| 58 |
st.write(f"Spelling and Grammar Score: {result['spelling_grammar_score']}")
|
| 59 |
|
| 60 |
-
# Content Quality Analysis
|
| 61 |
st.header("Content Quality Analysis")
|
| 62 |
for section, evaluation in result['content_analysis'].items():
|
| 63 |
st.subheader(section.capitalize())
|
|
@@ -65,7 +55,6 @@ if uploaded_file is not None:
|
|
| 65 |
|
| 66 |
st.write(f"Overall Content Quality Score: {result['overall_score']:.2f} / 10")
|
| 67 |
|
| 68 |
-
# Total Score
|
| 69 |
st.header("Total CV Score")
|
| 70 |
total_score = (
|
| 71 |
personal_info['personal_info_score'] +
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from cv_analyzer import analyze_cv
|
| 3 |
from cv_quality import CV
|
| 4 |
from get_supabase import Supabase
|
|
|
|
| 14 |
BUCKET_NAME = "CVs UX"
|
| 15 |
SUPABASE_PROJECT_ID = "abjtqzgnrtsikkqgnqeg"
|
| 16 |
|
| 17 |
+
# Get list of files from the Supabase bucket
|
| 18 |
+
files = supabase_client.storage.from_(BUCKET_NAME).list()
|
| 19 |
+
file_names = [file['name'] for file in files]
|
| 20 |
|
| 21 |
+
# Create a dropdown to select the file
|
| 22 |
+
selected_file = st.selectbox("Select a CV to analyze", file_names)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
if selected_file:
|
| 25 |
+
with st.spinner('Analyzing CV...'):
|
| 26 |
+
# Construct the public URL of the selected file
|
| 27 |
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
|
| 28 |
+
file_url = f"https://{SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/{BUCKET_NAME}/{selected_file}?t={timestamp}"
|
| 29 |
|
| 30 |
# Create CV object with the file URL
|
| 31 |
cv = CV(file_url)
|
|
|
|
| 35 |
st.error(result["error"])
|
| 36 |
else:
|
| 37 |
# Display results
|
|
|
|
| 38 |
st.header("Personal Information")
|
| 39 |
personal_info = result["personal_info"]
|
| 40 |
st.json(personal_info)
|
| 41 |
st.write(f"Personal Information Score: {personal_info['personal_info_score']}")
|
| 42 |
|
|
|
|
| 43 |
st.header("Detected Sections")
|
| 44 |
st.write(result["detected_sections"])
|
| 45 |
st.write(f"Section Detection Score: {result['section_detection_score']}")
|
| 46 |
|
|
|
|
| 47 |
st.header("Spelling and Grammar")
|
| 48 |
st.write(f"Error Percentage: {result['spelling_grammar_error_percentage']:.2f}%")
|
| 49 |
st.write(f"Spelling and Grammar Score: {result['spelling_grammar_score']}")
|
| 50 |
|
|
|
|
| 51 |
st.header("Content Quality Analysis")
|
| 52 |
for section, evaluation in result['content_analysis'].items():
|
| 53 |
st.subheader(section.capitalize())
|
|
|
|
| 55 |
|
| 56 |
st.write(f"Overall Content Quality Score: {result['overall_score']:.2f} / 10")
|
| 57 |
|
|
|
|
| 58 |
st.header("Total CV Score")
|
| 59 |
total_score = (
|
| 60 |
personal_info['personal_info_score'] +
|