AI提到后端
This commit is contained in:
@@ -158,7 +158,9 @@ class Applicant:
|
||||
self.is_running = False
|
||||
|
||||
self.session_id: int | None = None
|
||||
self.primary_resume_content: str = ""
|
||||
self.primary_resume_id: int | None = None
|
||||
# 本次投递所用条件快照(随每次打分请求上送服务端)
|
||||
self._score_conditions: dict = {}
|
||||
self.stats = {"applied": 0, "skipped": 0, "current": ""}
|
||||
|
||||
# 列表页会话(整个任务期间保持一个标签页)
|
||||
@@ -190,7 +192,7 @@ class Applicant:
|
||||
self.session_id = session["id"]
|
||||
|
||||
primary = self.server.get_primary_resume()
|
||||
self.primary_resume_content = primary["content"] if primary else ""
|
||||
self.primary_resume_id = primary["id"] if primary else None
|
||||
|
||||
self._stop_event.clear()
|
||||
self.is_running = True
|
||||
@@ -241,6 +243,13 @@ class Applicant:
|
||||
def _run(self, keywords, city, salary_min, salary_max,
|
||||
min_score, delay_range):
|
||||
try:
|
||||
# 投递条件快照:随每次 AI 打分请求上送服务端(简历内容由服务端按 id 自取)
|
||||
self._score_conditions = {
|
||||
"keywords": ",".join(keywords),
|
||||
"city": city,
|
||||
"salary_min": salary_min,
|
||||
"salary_max": salary_max,
|
||||
}
|
||||
self.manager.ensure_browser_started()
|
||||
# 整个任务只开一个列表标签页,模拟真人持续浏览
|
||||
self._tab = self.cdp.open_tab(JOBS_PAGE)
|
||||
@@ -463,8 +472,17 @@ class Applicant:
|
||||
card.jd_text = self._fetch_jd(card)
|
||||
|
||||
ai_score, ai_reason = -1, ""
|
||||
if self.ai and self.ai.available() and self.primary_resume_content:
|
||||
result = self.ai.score_job(card.jd_text, self.primary_resume_content, prompt=self.prompt)
|
||||
if self.ai and self.ai.available() and self.primary_resume_id:
|
||||
result = self.ai.score_job(card.job_id, card.jd_text,
|
||||
self.primary_resume_id,
|
||||
conditions=self._score_conditions,
|
||||
prompt=self.prompt)
|
||||
if result.fatal:
|
||||
# 模型级失败(报错/超时/未配置):跳过该岗位,避免盲投
|
||||
logger.warning(f"AI 打分失败,跳过岗位:{card.company} - {card.title}"
|
||||
f" | {result.reason}")
|
||||
self._report_skip(card, result.reason[:255])
|
||||
return 0
|
||||
ai_score, ai_reason = result.score, result.reason
|
||||
logger.info(f"AI 评分 {ai_score}(及格线 {min_score}):"
|
||||
f"{card.company} - {card.title} | {ai_reason}")
|
||||
|
||||
Reference in New Issue
Block a user