sandrocalzada commited on
Commit
b0e3d64
1 Parent(s): 0e2ee45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -41
app.py CHANGED
@@ -1,41 +1,62 @@
1
- import gradio as gr
2
- import pandas as pd
3
- import openpyxl
4
-
5
- def upload_excel(file):
6
- try:
7
- df = pd.read_excel(file.name)
8
- return df.to_html(index=False)
9
- except Exception as e:
10
- return f"Error: {str(e)}"
11
-
12
- def process_excel(file):
13
- return "Processing complete! This is a placeholder message."
14
-
15
- def display_output():
16
- return "Displaying output! This is a placeholder message."
17
-
18
- def launch():
19
- with gr.Blocks(css=".upload-button { width: 100%; } .process-button { width: 100%; }") as demo:
20
- gr.Markdown("<h1 style='text-align: center;'>Excel Processor App</h1>")
21
-
22
- with gr.Row():
23
- with gr.Column():
24
- gr.Markdown("## Upload Excel File")
25
- file_input = gr.File(label="")
26
- upload_button = gr.Button("Upload", elem_id="upload-button")
27
- excel_output = gr.HTML(label="Excel Content")
28
-
29
- with gr.Column():
30
- gr.Markdown("## Process and Output")
31
- process_button = gr.Button("Process", elem_id="process-button")
32
- text_output = gr.Textbox(label="Output", interactive=False)
33
-
34
- upload_button.click(upload_excel, inputs=file_input, outputs=excel_output)
35
- process_button.click(process_excel, inputs=file_input, outputs=text_output)
36
- process_button.click(display_output, inputs=None, outputs=text_output)
37
-
38
- demo.launch()
39
-
40
- if __name__ == "__main__":
41
- launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import io
3
+
4
+ def read_docx(file_bytes):
5
+
6
+ file_like_object = io.BytesIO(file_bytes)
7
+ document = Document(file_like_object)
8
+ doc_text = [paragraph.text for paragraph in document.paragraphs]
9
+
10
+
11
+
12
+
13
+
14
+ return '\n'.join(doc_text).lower()
15
+
16
+ def analyze_cv(cv_file, desired_role, expected_salary):
17
+
18
+ salary_ranges = {
19
+ "desarrollador": (30000, 60000),
20
+ "diseñador": (25000, 50000),
21
+ "gerente": (40000, 80000)
22
+ }
23
+
24
+
25
+ cv_content = read_docx(cv_file)
26
+ desired_role = desired_role.lower()
27
+ if desired_role in cv_content:
28
+
29
+
30
+ salary_range = salary_ranges.get(desired_role, (0, 0))
31
+ try:
32
+ expected_salary = int(expected_salary)
33
+ if salary_range[0] <= expected_salary <= salary_range[1]:
34
+ result = "El candidato es elegible para la posición."
35
+ else:
36
+ result = "El candidato no es elegible debido a las expectativas salariales."
37
+ except ValueError:
38
+ result = "Por favor, ingrese un valor numérico válido para la expectativa salarial."
39
+ else:
40
+ result = "El candidato no es elegible debido a la falta de experiencia relevante."
41
+
42
+ return result
43
+
44
+
45
+ iface = gr.Interface(
46
+ fn=analyze_cv,
47
+ inputs=[
48
+ gr.File(label="Sube un CV", type="binary"),
49
+ gr.Textbox(label="Nombre del rol o posición a cubrir", placeholder="Ejemplo: Desarrollador BI"),
50
+ gr.Textbox(label="Expectativa salarial", placeholder="Ejemplo: 50000"),
51
+ ],
52
+ outputs=gr.Textbox(label="Resultado de la elegibilidad"),
53
+ title="Análisis automático de CV",
54
+ .gr-file { border-color: #007BFF; }
55
+ .gr-button { background-color: #007BFF; color: white; }
56
+ .gr-output-text { font-size: 16px; }
57
+ """
58
+
59
+ )
60
+
61
+ # Launch the application with share=True to create a public link
62
+ iface.launch(share=True)