Spaces:
Runtime error
Runtime error
import io | |
from docx import Document | |
import gradio as gr | |
def read_docx(file_bytes): | |
file_like_object = io.BytesIO(file_bytes) | |
document = Document(file_like_object) | |
doc_text = [paragraph.text for paragraph in document.paragraphs] | |
return '\n'.join(doc_text).lower() | |
def analyze_cv(cv_file, desired_role, expected_salary): | |
salary_ranges = { | |
"desarrollador": (30000, 60000), | |
"diseñador": (25000, 50000), | |
"gerente": (40000, 80000) | |
} | |
cv_content = read_docx(cv_file) | |
desired_role = desired_role.lower() | |
if desired_role in cv_content: | |
salary_range = salary_ranges.get(desired_role, (0, 0)) | |
try: | |
expected_salary = int(expected_salary) | |
if salary_range[0] <= expected_salary <= salary_range[1]: | |
result = "El candidato es elegible para la posición." | |
else: | |
result = "El candidato no es elegible debido a las expectativas salariales." | |
except ValueError: | |
result = "Por favor, ingrese un valor numérico válido para la expectativa salarial." | |
else: | |
result = "El candidato no es elegible debido a la falta de experiencia relevante." | |
return result | |
iface = gr.Interface( | |
fn=analyze_cv, | |
inputs=[ | |
gr.File(label="Sube un CV", type="binary"), | |
gr.Textbox(label="Nombre del rol o posición a cubrir", placeholder="Ejemplo: Desarrollador BI"), | |
gr.Textbox(label="Expectativa salarial", placeholder="Ejemplo: 50000"), | |
], | |
outputs=gr.Textbox(label="Resultado de la elegibilidad"), | |
title="Análisis automático de CV", | |
css=""" | |
.gr-file { | |
border-color: #007BFF; | |
} | |
.gr-button { | |
background-color: #007BFF; | |
color: white; | |
} | |
.gr-output-text { | |
font-size: 16px; | |
} | |
""" | |
) |