Spaces:
Configuration error
Configuration error
Commit
Β·
cb97851
1
Parent(s):
fb60fa8
Refactored input processing
Browse files- functions/gradio.py +119 -0
- resumate.py +3 -59
functions/gradio.py
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
gradio.py
|
3 |
+
|
4 |
+
Functions for handling Gradio UI interactions and processing user inputs.
|
5 |
+
"""
|
6 |
+
|
7 |
+
import logging
|
8 |
+
from functions.linkedin_resume import extract_text_from_linkedin_pdf
|
9 |
+
from functions.github import get_github_repositories
|
10 |
+
|
11 |
+
# Set up logging
|
12 |
+
logging.basicConfig(level=logging.INFO)
|
13 |
+
logger = logging.getLogger(__name__)
|
14 |
+
|
15 |
+
|
16 |
+
def process_inputs(linkedin_pdf, github_url, job_post_text):
|
17 |
+
"""
|
18 |
+
Process the input files and URLs from the Gradio interface.
|
19 |
+
|
20 |
+
Args:
|
21 |
+
linkedin_pdf: Uploaded LinkedIn resume export PDF file
|
22 |
+
github_url (str): GitHub profile URL
|
23 |
+
job_post_text (str): Job post text content
|
24 |
+
|
25 |
+
Returns:
|
26 |
+
str: Formatted output with file and URL information
|
27 |
+
"""
|
28 |
+
result = ""
|
29 |
+
logger.info("Processing user inputs from Gradio interface")
|
30 |
+
|
31 |
+
# Process LinkedIn PDF file
|
32 |
+
if linkedin_pdf is not None:
|
33 |
+
result += "β
LinkedIn Resume PDF uploaded\n"
|
34 |
+
logger.info(f"Processing LinkedIn PDF: {linkedin_pdf.name}")
|
35 |
+
|
36 |
+
# Extract and structure text from the PDF
|
37 |
+
extraction_result = extract_text_from_linkedin_pdf(linkedin_pdf.name)
|
38 |
+
|
39 |
+
if extraction_result["status"] == "success":
|
40 |
+
result += " β
Text extraction successful\n\n"
|
41 |
+
logger.info("LinkedIn PDF text extraction successful")
|
42 |
+
|
43 |
+
elif extraction_result["status"] == "warning":
|
44 |
+
result += f" β οΈ Text extraction: {extraction_result['message']}\n\n"
|
45 |
+
logger.warning(f"LinkedIn PDF extraction warning: {extraction_result['message']}")
|
46 |
+
else:
|
47 |
+
result += f" β Text extraction failed: {extraction_result['message']}\n\n"
|
48 |
+
logger.error(f"LinkedIn PDF extraction failed: {extraction_result['message']}")
|
49 |
+
else:
|
50 |
+
result += "β No LinkedIn resume PDF file uploaded\n\n"
|
51 |
+
logger.info("No LinkedIn PDF file provided")
|
52 |
+
|
53 |
+
# Process GitHub profile
|
54 |
+
if github_url and github_url.strip():
|
55 |
+
result += "β
GitHub Profile URL provided\n"
|
56 |
+
logger.info(f"Processing GitHub URL: {github_url}")
|
57 |
+
|
58 |
+
# Retrieve repositories from GitHub
|
59 |
+
github_result = get_github_repositories(github_url)
|
60 |
+
|
61 |
+
if github_result["status"] == "success":
|
62 |
+
result += " β
GitHub list download successful\n\n"
|
63 |
+
logger.info(f"GitHub repositories retrieved successfully for {github_result['metadata']['username']}")
|
64 |
+
|
65 |
+
else:
|
66 |
+
result += f" β GitHub extraction failed: {github_result['message']}\n\n"
|
67 |
+
logger.error(f"GitHub extraction failed: {github_result['message']}")
|
68 |
+
else:
|
69 |
+
result += "β No GitHub profile URL provided\n\n"
|
70 |
+
logger.info("No GitHub URL provided")
|
71 |
+
|
72 |
+
# Process job post text
|
73 |
+
if job_post_text and job_post_text.strip():
|
74 |
+
result += "β
Job post text provided\n"
|
75 |
+
logger.info(f"Job post text provided ({len(job_post_text)} characters)")
|
76 |
+
else:
|
77 |
+
result += "β Job post not provided\n"
|
78 |
+
logger.info("No job post text provided")
|
79 |
+
|
80 |
+
logger.info("Input processing completed")
|
81 |
+
return result
|
82 |
+
|
83 |
+
|
84 |
+
def get_processed_data(linkedin_pdf, github_url, job_post_text):
|
85 |
+
"""
|
86 |
+
Get structured data from all inputs for further processing.
|
87 |
+
|
88 |
+
Args:
|
89 |
+
linkedin_pdf: Uploaded LinkedIn resume export PDF file
|
90 |
+
github_url (str): GitHub profile URL
|
91 |
+
job_post_text (str): Job post text content
|
92 |
+
|
93 |
+
Returns:
|
94 |
+
dict: Structured data containing all processed information
|
95 |
+
"""
|
96 |
+
processed_data = {
|
97 |
+
"linkedin": None,
|
98 |
+
"github": None,
|
99 |
+
"job_post": job_post_text.strip() if job_post_text else None,
|
100 |
+
"errors": []
|
101 |
+
}
|
102 |
+
|
103 |
+
# Process LinkedIn PDF
|
104 |
+
if linkedin_pdf is not None:
|
105 |
+
extraction_result = extract_text_from_linkedin_pdf(linkedin_pdf.name)
|
106 |
+
if extraction_result["status"] == "success":
|
107 |
+
processed_data["linkedin"] = extraction_result
|
108 |
+
else:
|
109 |
+
processed_data["errors"].append(f"LinkedIn: {extraction_result['message']}")
|
110 |
+
|
111 |
+
# Process GitHub profile
|
112 |
+
if github_url and github_url.strip():
|
113 |
+
github_result = get_github_repositories(github_url)
|
114 |
+
if github_result["status"] == "success":
|
115 |
+
processed_data["github"] = github_result
|
116 |
+
else:
|
117 |
+
processed_data["errors"].append(f"GitHub: {github_result['message']}")
|
118 |
+
|
119 |
+
return processed_data
|
resumate.py
CHANGED
@@ -6,72 +6,16 @@ A simple Gradio UI for collecting user profile and job post information.
|
|
6 |
This app provides inputs for:
|
7 |
- LinkedIn resume export PDF file upload
|
8 |
- GitHub profile URL
|
9 |
-
- LinkedIn job post
|
10 |
|
11 |
-
Upon submission, the input values are displayed in the output box.
|
12 |
|
13 |
To run:
|
14 |
python resumate.py
|
15 |
"""
|
16 |
|
17 |
import gradio as gr
|
18 |
-
from functions.
|
19 |
-
from functions.github import get_github_repositories
|
20 |
-
|
21 |
-
|
22 |
-
def process_inputs(linkedin_pdf, github_url, job_post_text):
|
23 |
-
"""
|
24 |
-
Process the input files and URLs.
|
25 |
-
|
26 |
-
Args:
|
27 |
-
linkedin_pdf: Uploaded LinkedIn resume export PDF file
|
28 |
-
github_url (str): GitHub profile URL
|
29 |
-
job_post_url (str): LinkedIn job post URL
|
30 |
-
|
31 |
-
Returns:
|
32 |
-
str: Formatted output with file and URL information
|
33 |
-
"""
|
34 |
-
result = ""
|
35 |
-
|
36 |
-
# Process LinkedIn PDF file
|
37 |
-
if linkedin_pdf is not None:
|
38 |
-
result += "β
LinkedIn Resume PDF uploaded\n"
|
39 |
-
|
40 |
-
# Extract and structure text from the PDF
|
41 |
-
extraction_result = extract_text_from_linkedin_pdf(linkedin_pdf.name)
|
42 |
-
|
43 |
-
if extraction_result["status"] == "success":
|
44 |
-
result += " β
Text extraction successful\n\n"
|
45 |
-
|
46 |
-
elif extraction_result["status"] == "warning":
|
47 |
-
result += f" β οΈ Text extraction: {extraction_result['message']}\n\n"
|
48 |
-
else:
|
49 |
-
result += f" β Text extraction failed: {extraction_result['message']}\n\n"
|
50 |
-
else:
|
51 |
-
result += "β No LinkedIn resume PDF file uploaded\n\n"
|
52 |
-
|
53 |
-
# Process GitHub profile
|
54 |
-
if github_url and github_url.strip():
|
55 |
-
result += "β
GitHub Profile URL provided\n"
|
56 |
-
|
57 |
-
# Retrieve repositories from GitHub
|
58 |
-
github_result = get_github_repositories(github_url)
|
59 |
-
|
60 |
-
if github_result["status"] == "success":
|
61 |
-
result += " β
GitHub list download successful\n\n"
|
62 |
-
|
63 |
-
else:
|
64 |
-
result += f" β GitHub extraction failed: {github_result['message']}\n\n"
|
65 |
-
else:
|
66 |
-
result += "β No GitHub profile URL provided\n\n"
|
67 |
-
|
68 |
-
# Process other inputs
|
69 |
-
if job_post_text:
|
70 |
-
result += "β
Job post text provided\n"
|
71 |
-
else:
|
72 |
-
result += f"β Job post not provided\n"
|
73 |
-
|
74 |
-
return result
|
75 |
|
76 |
|
77 |
with gr.Blocks() as demo:
|
|
|
6 |
This app provides inputs for:
|
7 |
- LinkedIn resume export PDF file upload
|
8 |
- GitHub profile URL
|
9 |
+
- LinkedIn job post text
|
10 |
|
11 |
+
Upon submission, the input values are processed and displayed in the output box.
|
12 |
|
13 |
To run:
|
14 |
python resumate.py
|
15 |
"""
|
16 |
|
17 |
import gradio as gr
|
18 |
+
from functions.gradio import process_inputs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
with gr.Blocks() as demo:
|