HR-ATS-Portal/backend/employment_agent/execute_agent.py

36 lines
1.1 KiB
Python

"""Employment extraction entrypoint — llm_setup.llm_call only.
Pure module: no FastAPI imports and no HTTPException.
Called from inbox.tasks.match_inbox_message; no HTTP surface.
"""
from __future__ import annotations
import logging
from employment_agent.decorators import parse_employment_response
from employment_agent.prompt import CURRENT_TITLE,EDUCATION,NO_COMPANY,prompt,user_prompt
from llm_setup import llm_call
logger=logging.getLogger("employment_agent")
async def run_employment_agent(*,resume_text=""):
text=(resume_text or "").strip()
if not text:
return {
"current_employment":NO_COMPANY,
"education":EDUCATION,
"current_title":CURRENT_TITLE,
"linkedin_url":None,
"phone":None,
"skills":[],
"years_experience":None,
}
try:
data=await llm_call(prompt(),user_prompt(text),json_mode=True)
return parse_employment_response(data,text)
except Exception as e:
logger.exception("employment llm_call failed")
raise RuntimeError(str(e)) from e