Spaces:
Configuration error
Configuration error
Added default job call loading for development
Browse files- functions/gradio.py +21 -6
- functions/job_call.py +49 -2
functions/gradio.py
CHANGED
|
@@ -9,7 +9,7 @@ import shutil
|
|
| 9 |
from pathlib import Path
|
| 10 |
from functions.linkedin_resume import extract_text_from_linkedin_pdf, check_default_linkedin_pdf
|
| 11 |
from functions.github import get_github_repositories
|
| 12 |
-
from functions.job_call import summarize_job_call
|
| 13 |
from functions.writer_agent import write_resume
|
| 14 |
from configuration import DEFAULT_GITHUB_PROFILE
|
| 15 |
|
|
@@ -144,15 +144,23 @@ def process_inputs(linkedin_pdf, github_url, job_post_text, user_instructions):
|
|
| 144 |
if job_post_text and job_post_text.strip():
|
| 145 |
result += "✅ Job post text provided\n"
|
| 146 |
logger.info("Job post text provided (%d characters)", len(job_post_text))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
|
|
|
| 150 |
result += " ✅ Job post summary generated\n"
|
| 151 |
logger.info("Job post summary generated (%d characters)", len(summary))
|
| 152 |
-
|
| 153 |
else:
|
| 154 |
-
result += "❌ Job post
|
| 155 |
-
logger.
|
| 156 |
|
| 157 |
# Process user instructions
|
| 158 |
if user_instructions and user_instructions.strip():
|
|
@@ -200,6 +208,13 @@ def get_processed_data(linkedin_pdf, github_url, job_post_text, instructions):
|
|
| 200 |
job_post_text = job_post_text.strip() if job_post_text and job_post_text.strip() else None
|
| 201 |
instructions = instructions.strip() if instructions and instructions.strip() else None
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
processed_data = {
|
| 204 |
"linkedin": None,
|
| 205 |
"github": None,
|
|
|
|
| 9 |
from pathlib import Path
|
| 10 |
from functions.linkedin_resume import extract_text_from_linkedin_pdf, check_default_linkedin_pdf
|
| 11 |
from functions.github import get_github_repositories
|
| 12 |
+
from functions.job_call import load_default_job_call, summarize_job_call
|
| 13 |
from functions.writer_agent import write_resume
|
| 14 |
from configuration import DEFAULT_GITHUB_PROFILE
|
| 15 |
|
|
|
|
| 144 |
if job_post_text and job_post_text.strip():
|
| 145 |
result += "✅ Job post text provided\n"
|
| 146 |
logger.info("Job post text provided (%d characters)", len(job_post_text))
|
| 147 |
+
job_text_to_use = job_post_text.strip()
|
| 148 |
+
else:
|
| 149 |
+
result += "ℹ️ No job post provided, attempting to use default\n"
|
| 150 |
+
logger.info("No job post text provided, trying default")
|
| 151 |
+
job_text_to_use = None
|
| 152 |
+
|
| 153 |
+
# Generate job summary (will use default if job_text_to_use is None)
|
| 154 |
+
summary = summarize_job_call(job_text_to_use)
|
| 155 |
|
| 156 |
+
if summary:
|
| 157 |
+
if not job_text_to_use:
|
| 158 |
+
result += "✅ Using default job post\n"
|
| 159 |
result += " ✅ Job post summary generated\n"
|
| 160 |
logger.info("Job post summary generated (%d characters)", len(summary))
|
|
|
|
| 161 |
else:
|
| 162 |
+
result += " ❌ Job post summary generation failed\n"
|
| 163 |
+
logger.warning("Job post summary generation failed")
|
| 164 |
|
| 165 |
# Process user instructions
|
| 166 |
if user_instructions and user_instructions.strip():
|
|
|
|
| 208 |
job_post_text = job_post_text.strip() if job_post_text and job_post_text.strip() else None
|
| 209 |
instructions = instructions.strip() if instructions and instructions.strip() else None
|
| 210 |
|
| 211 |
+
# If no job post text provided, try to get default
|
| 212 |
+
if not job_post_text:
|
| 213 |
+
default_job = load_default_job_call()
|
| 214 |
+
|
| 215 |
+
if default_job:
|
| 216 |
+
job_post_text = default_job
|
| 217 |
+
|
| 218 |
processed_data = {
|
| 219 |
"linkedin": None,
|
| 220 |
"github": None,
|
functions/job_call.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import logging
|
|
|
|
| 5 |
from openai import OpenAI
|
| 6 |
from configuration import JOB_CALL_EXTRACTION_PROMPT
|
| 7 |
|
|
@@ -12,8 +13,54 @@ logging.basicConfig(level=logging.INFO)
|
|
| 12 |
logger = logging.getLogger(__name__)
|
| 13 |
|
| 14 |
|
| 15 |
-
def
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
client = OpenAI(api_key=os.environ['MODAL_API_KEY'])
|
| 19 |
|
|
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import logging
|
| 5 |
+
from pathlib import Path
|
| 6 |
from openai import OpenAI
|
| 7 |
from configuration import JOB_CALL_EXTRACTION_PROMPT
|
| 8 |
|
|
|
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
|
| 15 |
|
| 16 |
+
def load_default_job_call() -> str:
|
| 17 |
+
"""
|
| 18 |
+
Load default job call text from data/sample_job.txt if it exists.
|
| 19 |
+
|
| 20 |
+
Returns:
|
| 21 |
+
str: The default job call text, or empty string if file doesn't exist
|
| 22 |
+
"""
|
| 23 |
+
try:
|
| 24 |
+
# Get the project root directory (parent of functions directory)
|
| 25 |
+
project_root = Path(__file__).parent.parent
|
| 26 |
+
default_job_path = project_root / "data" / "sample_job.txt"
|
| 27 |
+
|
| 28 |
+
if default_job_path.exists():
|
| 29 |
+
with open(default_job_path, 'r', encoding='utf-8') as f:
|
| 30 |
+
job_text = f.read().strip()
|
| 31 |
+
|
| 32 |
+
logger.info("Loaded default job call from: %s (%d characters)",
|
| 33 |
+
default_job_path, len(job_text))
|
| 34 |
+
return job_text
|
| 35 |
+
else:
|
| 36 |
+
logger.info("No default job call file found at: %s", default_job_path)
|
| 37 |
+
return ""
|
| 38 |
+
|
| 39 |
+
except Exception as e:
|
| 40 |
+
logger.warning("Failed to load default job call: %s", str(e))
|
| 41 |
+
return ""
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def summarize_job_call(job_call: str = None) -> str:
|
| 45 |
+
'''Extracts and summarizes key information from job call.
|
| 46 |
+
|
| 47 |
+
Args:
|
| 48 |
+
job_call (str, optional): Job call text to summarize. If None or empty,
|
| 49 |
+
attempts to load default from data/sample_job.txt
|
| 50 |
+
|
| 51 |
+
Returns:
|
| 52 |
+
str: Summarized job call information, or None if no job call available
|
| 53 |
+
'''
|
| 54 |
+
|
| 55 |
+
# Use provided job call or load default
|
| 56 |
+
if not job_call or not job_call.strip():
|
| 57 |
+
job_call = load_default_job_call()
|
| 58 |
+
|
| 59 |
+
if not job_call:
|
| 60 |
+
logger.warning("No job call text provided and no default available")
|
| 61 |
+
return None
|
| 62 |
+
|
| 63 |
+
logger.info("Summarizing job call (%d characters)", len(job_call))
|
| 64 |
|
| 65 |
client = OpenAI(api_key=os.environ['MODAL_API_KEY'])
|
| 66 |
|