From 65d711ec2551a2fb6b60511dd36fb7036c3350ec Mon Sep 17 00:00:00 2001 From: zk Date: Fri, 10 Jul 2026 11:26:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=AF=84=E5=88=86=20?= =?UTF-8?q?=E5=8A=A0=E7=AE=80=E5=8E=86id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/job_agent_chat.py | 6 ++++-- app/schemas/job_agent_chat.py | 3 ++- app/services/job_agent_chat_service.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/api/job_agent_chat.py b/app/api/job_agent_chat.py index f7d6541..7cf425a 100644 --- a/app/api/job_agent_chat.py +++ b/app/api/job_agent_chat.py @@ -2,6 +2,7 @@ from fastapi import APIRouter, Depends +from app.core.asserts import Assert from app.core.auth import func_permission from app.core.context import RequestContext from app.core.database import get_db @@ -13,11 +14,12 @@ router = APIRouter(prefix="/job-agent", tags=["求职助手agent"]) @router.post("/match-score", summary="岗位匹配度评分") async def match_score(param: MatchScoreParam): - """根据定制简历和岗位,从技能/学历/经验维度评估匹配度,返回 0-100 分""" + """根据定制简历或原始简历和岗位,从技能/学历/经验维度评估匹配度,返回 0-100 分""" + Assert.is_true(param.customize_resume_id is not None or param.resume_id is not None, "customizeResumeId 和 resumeId 至少传一个") user_id = RequestContext.user_id.get() async for session in get_db(): service = JobAgentChatService(session) - result = await service.score_match(user_id, param.customize_resume_id, param.job_id) + result = await service.score_match(user_id, param.job_id, param.customize_resume_id, param.resume_id) return result diff --git a/app/schemas/job_agent_chat.py b/app/schemas/job_agent_chat.py index 35201a0..ed5ca57 100644 --- a/app/schemas/job_agent_chat.py +++ b/app/schemas/job_agent_chat.py @@ -13,5 +13,6 @@ class OptimizeResumeParam(BaseModel): class MatchScoreParam(BaseModel): - customize_resume_id: int = Field(..., alias="customizeResumeId", description="定制简历ID") + customize_resume_id: int | None = Field(None, alias="customizeResumeId", description="定制简历ID") + resume_id: int | None = Field(None, alias="resumeId", description="简历ID") job_id: int = Field(..., alias="jobId", description="岗位ID") diff --git a/app/services/job_agent_chat_service.py b/app/services/job_agent_chat_service.py index 182fe47..cfbfb6e 100644 --- a/app/services/job_agent_chat_service.py +++ b/app/services/job_agent_chat_service.py @@ -26,11 +26,15 @@ class JobAgentChatService: def __init__(self, session: AsyncSession): self.session = session - async def score_match(self, user_id: int, customize_resume_id: int, job_id: int) -> int: - """岗位匹配评分:查定制简历 + 岗位 → 序列化简历 → 调AI评分,返回 0-100 整数""" - cr = await customize_resume_store.get_by_id(user_id, customize_resume_id) - if cr is None: - raise ValueError("定制简历不存在") + async def score_match(self, user_id: int, job_id: int, customize_resume_id: int | None = None, resume_id: int | None = None) -> int: + """岗位匹配评分:查定制简历或原始简历 + 岗位 → 序列化简历 → 调AI评分,返回 0-100 整数""" + if customize_resume_id: + cr = await customize_resume_store.get_by_id(user_id, customize_resume_id) + if cr is None: + raise ValueError("定制简历不存在") + else: + detail = await load_resume_detail(self.session, resume_id, user_id) + cr = customize_resume_store.build_from_detail(detail) job = await self._get_job(job_id) resume_text = self._build_resume_text_from_cr(cr) skill_tags = "、".join(job.skill_tags) if job.skill_tags else ""