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

28 lines
874 B
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 EDUCATION,NO_COMPANY,prompt,user_prompt
from llm_setup import llm_call
logger=logging.getLogger("employment_agent")
async def run_employment_agent(*,resume_text="") -> tuple[str,str]:
text=(resume_text or "").strip()
if not text:
return NO_COMPANY,EDUCATION
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