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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -54
app.py CHANGED
@@ -1,55 +1,41 @@
1
  import gradio as gr
2
- from docx import Document
3
- import io
4
-
5
- def read_docx(file_bytes):
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
- return '\n'.join(doc_text).lower()
10
-
11
- def analyze_cv(cv_file, desired_role, expected_salary):
12
- salary_ranges = {
13
- "desarrollador": (30000, 60000),
14
- "diseñador": (25000, 50000),
15
- "gerente": (40000, 80000)
16
- }
17
-
18
- cv_content = read_docx(cv_file)
19
- desired_role = desired_role.lower()
20
- if desired_role in cv_content:
21
- salary_range = salary_ranges.get(desired_role, (0, 0))
22
- try:
23
- expected_salary = int(expected_salary)
24
- if salary_range[0] <= expected_salary <= salary_range[1]:
25
- result = "El candidato es elegible para la posición."
26
- else:
27
- result = "El candidato no es elegible debido a las expectativas salariales."
28
- except ValueError:
29
- result = "Por favor, ingrese un valor numérico válido para la expectativa salarial."
30
- else:
31
- result = "El candidato no es elegible debido a la falta de experiencia relevante."
32
- return result
33
-
34
- iface = gr.Interface(
35
- fn=analyze_cv,
36
- inputs=[
37
- gr.File(label="Sube un CV", type="binary"),
38
- gr.Textbox(label="Nombre del rol o posición a cubrir", placeholder="Ejemplo: Desarrollador BI"),
39
- gr.Textbox(label="Expectativa salarial", placeholder="Ejemplo: 50000"),
40
- ],
41
- outputs=gr.Textbox(label="Resultado de la elegibilidad"),
42
- title="Análisis automático de CV",
43
- description="Esta aplicación analiza un CV para determinar la elegibilidad para un rol específico basado en la experiencia y expectativas salariales. Por favor, proporciona el CV, el rol deseado y la expectativa salarial.",
44
- theme="dark",
45
- css="""
46
- body { font-family: 'Arial'; }
47
- .gr-input-text { border-color: #007BFF; }
48
- .gr-file { border-color: #007BFF; }
49
- .gr-button { background-color: #007BFF; color: white; }
50
- .gr-output-text { font-size: 16px; }
51
- """
52
- )
53
-
54
- # Launch the application with share=True to create a public link
55
- iface.launch(share=True)
 
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()