Files
resume-agent/backend/app/builder_conversation/save.py
T
hypandClaude ae2d9b128d feat: builder 简历生成 + 轻度优化 + 简历导入交付副本
自内部仓库剥离深度优化与 RAG 知识库后的交付版本:
- Builder 对话式简历生成(FSM + 意图路由 LLM 兜底增强)
- 条目级轻度优化:事实覆盖门禁 + STAR/bullet 修复链,功能/简介/成果与技术栈同级保护
- 简历导入:DOCX/PDF 解析、结构归一、手机号脱敏
- PostgreSQL 运行时 + Alembic 迁移链

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-05 11:08:30 +08:00

31 lines
1.2 KiB
Python

"""Persist Builder entries into the resume document."""
from __future__ import annotations
from typing import Any
from ..fsm import FSMError
from ..resume_document_core import find_entry, new_id, normalize_document
from .constants import SECTION_HEADINGS
def save_entry(resume_content: dict[str, Any], section_kind: str, entry: dict[str, Any], *, entry_id: str | None) -> dict[str, Any]:
content = normalize_document(resume_content)
if entry_id:
found = find_entry(content, entry_id)
if found is None:
raise FSMError("builder_entry_not_found", "The selected resume entry no longer exists", status_code=409)
_, existing = found
entry["id"] = existing["id"]
existing.clear()
existing.update(entry)
return content
sections = content.setdefault("sections", [])
section = next((item for item in sections if item.get("kind") == section_kind), None)
if section is None:
section = {"id": new_id("sec"), "kind": section_kind, "heading": SECTION_HEADINGS.get(section_kind, section_kind), "items": []}
sections.append(section)
entry["id"] = entry.get("id") or new_id("entry")
section.setdefault("items", []).append(entry)
return content