匹配评分 加简历id
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
|
|
||||||
|
from app.core.asserts import Assert
|
||||||
from app.core.auth import func_permission
|
from app.core.auth import func_permission
|
||||||
from app.core.context import RequestContext
|
from app.core.context import RequestContext
|
||||||
from app.core.database import get_db
|
from app.core.database import get_db
|
||||||
@@ -13,11 +14,12 @@ router = APIRouter(prefix="/job-agent", tags=["求职助手agent"])
|
|||||||
|
|
||||||
@router.post("/match-score", summary="岗位匹配度评分")
|
@router.post("/match-score", summary="岗位匹配度评分")
|
||||||
async def match_score(param: MatchScoreParam):
|
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()
|
user_id = RequestContext.user_id.get()
|
||||||
async for session in get_db():
|
async for session in get_db():
|
||||||
service = JobAgentChatService(session)
|
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
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ class OptimizeResumeParam(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class MatchScoreParam(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")
|
job_id: int = Field(..., alias="jobId", description="岗位ID")
|
||||||
|
|||||||
@@ -26,11 +26,15 @@ class JobAgentChatService:
|
|||||||
def __init__(self, session: AsyncSession):
|
def __init__(self, session: AsyncSession):
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
async def score_match(self, user_id: int, customize_resume_id: int, job_id: int) -> int:
|
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 整数"""
|
"""岗位匹配评分:查定制简历或原始简历 + 岗位 → 序列化简历 → 调AI评分,返回 0-100 整数"""
|
||||||
|
if customize_resume_id:
|
||||||
cr = await customize_resume_store.get_by_id(user_id, customize_resume_id)
|
cr = await customize_resume_store.get_by_id(user_id, customize_resume_id)
|
||||||
if cr is None:
|
if cr is None:
|
||||||
raise ValueError("定制简历不存在")
|
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)
|
job = await self._get_job(job_id)
|
||||||
resume_text = self._build_resume_text_from_cr(cr)
|
resume_text = self._build_resume_text_from_cr(cr)
|
||||||
skill_tags = "、".join(job.skill_tags) if job.skill_tags else ""
|
skill_tags = "、".join(job.skill_tags) if job.skill_tags else ""
|
||||||
|
|||||||
Reference in New Issue
Block a user