generated from kgod/ai-review-template
feat: start resume sessions in new flow
This commit is contained in:
+28
-43
@@ -213,6 +213,27 @@ def initial_turn() -> dict[str, Any]:
|
||||
)
|
||||
|
||||
|
||||
def new_resume_transition(profile: dict[str, Any]) -> Transition:
|
||||
"""Enter the new-resume flow without presenting an import/manual choice."""
|
||||
updated = deepcopy(profile)
|
||||
updated["resume_source"] = "manual"
|
||||
return Transition(
|
||||
Stage.PHONE_SELECTION,
|
||||
updated,
|
||||
assistant_turn(
|
||||
"请选择手机号来源。",
|
||||
[
|
||||
component(
|
||||
"ResumePhoneSelector",
|
||||
has_account_phone=bool(updated.get("account_phone")),
|
||||
masked_phone=mask_phone(updated.get("account_phone")),
|
||||
default_value=("account" if updated.get("account_phone") else None),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def required_fields(profile: dict[str, Any]) -> list[str]:
|
||||
"""The initial Builder resume only requires verified setup information."""
|
||||
return []
|
||||
@@ -267,56 +288,20 @@ def process_component_event(
|
||||
)
|
||||
_expect(action, "accept_privacy")
|
||||
updated["privacy_accepted"] = True
|
||||
return Transition(
|
||||
Stage.RESUME_SOURCE_SELECT,
|
||||
updated,
|
||||
assistant_turn(
|
||||
"\u8bf7\u9009\u62e9\u5f00\u59cb\u65b9\u5f0f\u3002",
|
||||
[
|
||||
component(
|
||||
"ChoiceChips",
|
||||
eyebrow="\u5f00\u59cb\u521b\u5efa",
|
||||
title="\u9009\u62e9\u521b\u5efa\u65b9\u5f0f",
|
||||
description="\u5bfc\u5165\u4f1a\u5148\u63d0\u53d6\u6587\u6863\u5185\u5bb9\uff0c\u518d\u6620\u5c04\u4e3a\u53ef\u7f16\u8f91\u7684\u7b80\u5386\u7ed3\u6784\u3002",
|
||||
options=[
|
||||
{"value": "import", "label": "\u5bfc\u5165\u5df2\u6709\u7b80\u5386", "description": "\u652f\u6301 PDF \u6216 DOCX"},
|
||||
{"value": "manual", "label": "\u521b\u5efa\u65b0\u7b80\u5386", "description": "\u4ece\u57fa\u7840\u4fe1\u606f\u548c\u7ecf\u5386\u5f00\u59cb\u586b\u5199"},
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
return new_resume_transition(updated)
|
||||
|
||||
if stage == Stage.RESUME_SOURCE_SELECT:
|
||||
_expect(action, "select_choice")
|
||||
source = str(payload.get("value") or "").strip()
|
||||
if source == "import":
|
||||
updated["resume_source"] = "import"
|
||||
return Transition(
|
||||
Stage.RESUME_IMPORT_UPLOAD,
|
||||
updated,
|
||||
assistant_turn("\u8bf7\u9009\u62e9\u9700\u8981\u5bfc\u5165\u7684 PDF \u6216 DOCX \u7b80\u5386\u3002", []),
|
||||
raise FSMError(
|
||||
"resume_import_disabled",
|
||||
"Resume import is no longer available; create a new resume instead",
|
||||
status_code=410,
|
||||
)
|
||||
if source == "manual":
|
||||
updated["resume_source"] = "manual"
|
||||
return Transition(
|
||||
Stage.PHONE_SELECTION,
|
||||
updated,
|
||||
assistant_turn(
|
||||
"\u8bf7\u9009\u62e9\u624b\u673a\u53f7\u6765\u6e90\u3002",
|
||||
[
|
||||
component(
|
||||
"ResumePhoneSelector",
|
||||
has_account_phone=bool(updated.get("account_phone")),
|
||||
masked_phone=mask_phone(updated.get("account_phone")),
|
||||
default_value=(
|
||||
"account" if updated.get("account_phone") else None
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
raise FSMError("invalid_resume_source", "Select import or manual", status_code=422)
|
||||
return new_resume_transition(updated)
|
||||
raise FSMError("invalid_resume_source", "Create a new resume", status_code=422)
|
||||
if stage == Stage.PHONE_SELECTION:
|
||||
if action == "use_other_phone":
|
||||
return Transition(
|
||||
|
||||
Reference in New Issue
Block a user