agent-fallback
This commit is contained in:
@@ -10,11 +10,13 @@ Cascade order (return early on first hit):
|
||||
3. Job-like anchors — first <a> whose href matches /job|/position|/opening|/vacanc.
|
||||
4. Cheap-LLM — classify_job_link() from classify_llm; no-ops gracefully
|
||||
when the LLM is not configured.
|
||||
5. Miss — return (None, "none").
|
||||
5. Browser agent — agent_fallback.find_and_extract(); fused with Stage-2 so
|
||||
the same memoized session covers both stages.
|
||||
6. Miss — return (None, "none").
|
||||
|
||||
Returns (url: str | None, method: str). Never raises — any tier failure logs
|
||||
and falls through. method is one of:
|
||||
"ats:{name}" | "json_ld" | "anchor" | "llm_classify" | "none"
|
||||
"ats:{name}" | "json_ld" | "anchor" | "llm_classify" | "browser_agent" | "none"
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -26,8 +28,10 @@ from urllib.parse import urlsplit
|
||||
import httpx
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from . import agent_fallback as _agent_fallback
|
||||
from .careers import ats as _ats
|
||||
from .careers.classify_llm import classify_job_link, extract_anchors
|
||||
from .config import get_settings
|
||||
from .http import build_client, request_with_retries
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -206,6 +210,20 @@ def extract_open_position(
|
||||
except Exception as exc:
|
||||
logger.warning("extract(%s): llm_classify tier error: %s", careers_url, exc)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Tier 5 — Browser agent (fused; memo-shared with cascade Tier 6)
|
||||
# ------------------------------------------------------------------
|
||||
if get_settings().enable_browser_agent:
|
||||
try:
|
||||
ag = _agent_fallback.find_and_extract(careers_url)
|
||||
if ag and ag.position_url:
|
||||
logger.info(
|
||||
"extract(%s): browser_agent pos=%s", careers_url, ag.position_url
|
||||
)
|
||||
return ag.position_url, "browser_agent"
|
||||
except Exception as exc:
|
||||
logger.warning("extract(%s): browser_agent tier error: %s", careers_url, exc)
|
||||
|
||||
logger.info("extract(%s): all tiers missed", careers_url)
|
||||
return None, "none"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user