优化 agent 定制简历生成速度
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
"""求职助手 - 岗位简历优化 AI 引擎
|
||||
|
||||
针对目标岗位并发优化简历(summary + 经历子表)。
|
||||
针对目标岗位并发优化简历(summary + 经历子表,按单条记录粒度并发)。
|
||||
依赖:LLM 枚举、job_agent/prompts、parse_llm_json
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
|
||||
@@ -16,40 +18,46 @@ from app.tool.json_helper import parse_llm_json
|
||||
|
||||
_summary_chain = (
|
||||
ChatPromptTemplate.from_messages([("system", RESUME_SUMMARY_OPTIMIZE_PROMPT), ("human", "请开始优化。")])
|
||||
| LLM.ZM_GPT_5_4.create(temperature=0.3)
|
||||
| LLM.ZM_GPT_5_4_MINI.create(temperature=0.3)
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
async def optimize_summary(job_title: str, job_description: str, original_summary: str) -> str:
|
||||
"""针对岗位优化个人概述"""
|
||||
t0 = time.monotonic()
|
||||
try:
|
||||
return await _summary_chain.ainvoke({
|
||||
result = await _summary_chain.ainvoke({
|
||||
"job_title": job_title, "job_description": job_description or "",
|
||||
"original_summary": original_summary or "暂无",
|
||||
})
|
||||
log.info(f"岗位简历summary优化完成 ({round(time.monotonic() - t0, 2)}s)")
|
||||
return result
|
||||
except Exception as e:
|
||||
log.warning(f"岗位简历summary优化失败: {e}")
|
||||
log.warning(f"岗位简历summary优化失败: {e} ({round(time.monotonic() - t0, 2)}s)")
|
||||
return original_summary
|
||||
|
||||
|
||||
# ===== 经历优化 =====
|
||||
# ===== 单条经历优化 =====
|
||||
|
||||
_experience_chain = (
|
||||
ChatPromptTemplate.from_messages([("system", RESUME_EXPERIENCE_OPTIMIZE_PROMPT), ("human", "请开始优化。")])
|
||||
| LLM.ZM_GPT_5_4.create(temperature=0.3)
|
||||
| LLM.ZM_GPT_5_4_MINI.create(temperature=0.3)
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
async def optimize_experience(job_title: str, job_description: str, module_data: str) -> list | dict | None:
|
||||
"""针对岗位优化经历模块描述,返回修改后的完整模块数据"""
|
||||
async def optimize_experience_record(job_title: str, job_description: str, record_json: str) -> dict | None:
|
||||
"""针对岗位优化单条经历记录,返回修改后的记录数据"""
|
||||
t0 = time.monotonic()
|
||||
try:
|
||||
raw = await _experience_chain.ainvoke({
|
||||
"job_title": job_title, "job_description": job_description or "",
|
||||
"original_module_data": module_data,
|
||||
"original_module_data": record_json,
|
||||
})
|
||||
return parse_llm_json(raw)
|
||||
result = parse_llm_json(raw)
|
||||
log.info(f"岗位简历经历记录优化完成 ({round(time.monotonic() - t0, 2)}s)")
|
||||
return result
|
||||
except Exception as e:
|
||||
log.warning(f"岗位简历经历优化失败: {e}")
|
||||
log.warning(f"岗位简历经历记录优化失败: {e} ({round(time.monotonic() - t0, 2)}s)")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user