Scope monitoring TG by department
This commit is contained in:
@@ -315,20 +315,21 @@ def analyze(text: str | None) -> dict[str, Any]:
|
||||
async def analyze_with_llm(
|
||||
text: str | None,
|
||||
vertical: str = "real_estate",
|
||||
department_id: str | None = None,
|
||||
section_slug: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Regex extraction + local LLM lead classification, routed by vertical.
|
||||
|
||||
`section_slug` lets the classifier pick a section-specific system prompt
|
||||
(e.g. Dubai-focused for `real_estate:dubai`) with fallback to the
|
||||
vertical-default prompt. The LLM verdict goes under `lead` for RE and
|
||||
under `hr_lead` for HR. Falls back to regex-only if Ollama is unavailable.
|
||||
`department_id` + `section_slug` let the classifier pick a department and
|
||||
section-specific system prompt with fallback to the department vertical
|
||||
prompt. The LLM verdict goes under `lead` for RE and
|
||||
under `hr_lead` for HR. Falls back to regex-only if the LLM is unavailable.
|
||||
"""
|
||||
base = analyze(text)
|
||||
# Lazy import to avoid hard dep on httpx in environments where LLM is off.
|
||||
from parser_bot.llm import classify
|
||||
|
||||
verdict = await classify(text, vertical, section_slug) # type: ignore[arg-type]
|
||||
verdict = await classify(text, vertical, department_id, section_slug) # type: ignore[arg-type]
|
||||
if verdict is not None:
|
||||
base["hr_lead" if vertical == "hr" else "lead"] = verdict
|
||||
return base
|
||||
|
||||
Reference in New Issue
Block a user