Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ user_profile = {
|
|
| 12 |
"dream_day": None,
|
| 13 |
"forward_direction_choice": None,
|
| 14 |
|
| 15 |
-
#
|
| 16 |
"recommended_directions": [], # 3个大方向
|
| 17 |
"selected_direction": None, # 学生最终选定的大方向
|
| 18 |
"recommended_jobs": [], # 3个具体职业
|
|
@@ -48,33 +48,64 @@ backward_index = 0
|
|
| 48 |
forward_done = False
|
| 49 |
backward_done = False
|
| 50 |
forward_recommendation_given = False
|
| 51 |
-
|
| 52 |
recommendation_round = 0
|
| 53 |
forward_deep_dive_done = False
|
| 54 |
roadmap_offered = False
|
| 55 |
roadmap_done = False
|
| 56 |
|
| 57 |
-
# 新增:控制大方向→具体职业的流程
|
| 58 |
direction_chosen = False # 是否已经选定大方向
|
| 59 |
jobs_recommended = False # 是否已给出3个具体职业
|
| 60 |
job_chosen = False # 是否选定了具体职业
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
# ============================ 模型设置 ============================
|
| 63 |
model_default = "gpt-4o"
|
| 64 |
token_default = 2000
|
| 65 |
temp_default = 0.7
|
| 66 |
top_p_default = 0.95
|
| 67 |
|
| 68 |
-
# ~~~~~~~~~~~~~~~~~~~~~~~
|
| 69 |
-
def
|
| 70 |
"""
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
2. 工作环境
|
| 74 |
-
3. 晋升难度
|
| 75 |
-
4. 关键技能和考证
|
| 76 |
-
5. 日常工作节奏
|
| 77 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
prompt = f"""
|
| 79 |
你是一位专业的职业规划顾问。
|
| 80 |
学生最终选择的具体职业: {selected_career}
|
|
@@ -116,8 +147,8 @@ def do_selected_career_detail(selected_career, bg_info, wv, ps, dd):
|
|
| 116 |
|
| 117 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 路线图生成函数 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 118 |
def do_time_roadmap():
|
| 119 |
-
|
| 120 |
-
|
| 121 |
bg_info = user_profile["bg_info"] or "未知专业"
|
| 122 |
wv = user_profile["work_value"] or "暂无"
|
| 123 |
ps = user_profile["personality_summary"] or "暂无"
|
|
@@ -163,9 +194,6 @@ def do_time_roadmap():
|
|
| 163 |
|
| 164 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 给定大方向后,再给3个具体职业 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 165 |
def recommend_3jobs_for_direction(direction, bg_info, wv, ps, dd):
|
| 166 |
-
"""
|
| 167 |
-
当学生选定了某个大方向后,AI再推荐3个该方向下的具体职业
|
| 168 |
-
"""
|
| 169 |
prompt = f"""
|
| 170 |
你是一位专业的职业规划顾问。
|
| 171 |
学生选定的大方向:{direction}
|
|
@@ -219,7 +247,6 @@ def recommend_3jobs_for_direction(direction, bg_info, wv, ps, dd):
|
|
| 219 |
|
| 220 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 深度分析函数(可做备用) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 221 |
def do_deep_analysis():
|
| 222 |
-
# 保留原有,若后续需要也可用
|
| 223 |
direction = user_profile["forward_direction_choice"] or "尚未选择"
|
| 224 |
bg_info = user_profile["bg_info"] or "未知背景"
|
| 225 |
wv = user_profile["work_value"] or "无"
|
|
@@ -371,6 +398,9 @@ def predict(message, history):
|
|
| 371 |
|
| 372 |
global direction_chosen, jobs_recommended, job_chosen
|
| 373 |
|
|
|
|
|
|
|
|
|
|
| 374 |
# ======================== 初始化 =========================
|
| 375 |
if not history:
|
| 376 |
current_q_index = 0
|
|
@@ -394,6 +424,10 @@ def predict(message, history):
|
|
| 394 |
jobs_recommended = False
|
| 395 |
job_chosen = False
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
# ======================== 先处理基础问题 =========================
|
| 398 |
if 0 < current_q_index <= len(questions):
|
| 399 |
key = questions[current_q_index - 1][0]
|
|
@@ -421,7 +455,6 @@ def predict(message, history):
|
|
| 421 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 422 |
if mode == "是":
|
| 423 |
if in_backward_flow and not backward_done:
|
| 424 |
-
# 录入回答
|
| 425 |
if backward_index > 0 and backward_index <= len(backward_additional_questions):
|
| 426 |
prev_key = backward_additional_questions[backward_index - 1][0]
|
| 427 |
user_profile[prev_key] = message.strip()
|
|
@@ -433,7 +466,6 @@ def predict(message, history):
|
|
| 433 |
else:
|
| 434 |
backward_done = True
|
| 435 |
|
| 436 |
-
# backward_done 表示可以给最终回复
|
| 437 |
if backward_done:
|
| 438 |
try:
|
| 439 |
api_key = os.environ.get("API_TOKEN")
|
|
@@ -461,7 +493,7 @@ def predict(message, history):
|
|
| 461 |
# Forward模式处理
|
| 462 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 463 |
else:
|
| 464 |
-
#
|
| 465 |
if in_forward_flow and not forward_done and not direction_chosen and not jobs_recommended and not job_chosen and not roadmap_done:
|
| 466 |
if forward_index > 0 and forward_index <= len(forward_additional_questions):
|
| 467 |
prev_key = forward_additional_questions[forward_index - 1][0]
|
|
@@ -472,7 +504,6 @@ def predict(message, history):
|
|
| 472 |
forward_index += 1
|
| 473 |
return prompt_text
|
| 474 |
|
| 475 |
-
# 已完成4个问题,准备推荐3大方向
|
| 476 |
elif not forward_recommendation_given:
|
| 477 |
forward_recommendation_given = True
|
| 478 |
return recommend_3directions()
|
|
@@ -483,11 +514,9 @@ def predict(message, history):
|
|
| 483 |
if choice in ["1","2","3"]:
|
| 484 |
idx = int(choice) - 1
|
| 485 |
if idx < len(user_profile["recommended_directions"]):
|
| 486 |
-
# 选定的大方向
|
| 487 |
sel_dir = user_profile["recommended_directions"][idx]
|
| 488 |
user_profile["selected_direction"] = sel_dir
|
| 489 |
direction_chosen = True
|
| 490 |
-
# 进入:给出该方向下的3个具体职业
|
| 491 |
return recommend_3jobs_for_direction(
|
| 492 |
direction=sel_dir,
|
| 493 |
bg_info=user_profile["bg_info"] or "",
|
|
@@ -503,15 +532,13 @@ def predict(message, history):
|
|
| 503 |
forward_done = True
|
| 504 |
return "已多次换方向,结束推荐。"
|
| 505 |
else:
|
| 506 |
-
# 再次推荐3大方向
|
| 507 |
return recommend_3directions()
|
| 508 |
else:
|
| 509 |
return "请回复1/2/3选择方向,或输入'换'来重新推荐"
|
| 510 |
|
| 511 |
-
#
|
| 512 |
elif direction_chosen and not jobs_recommended and not job_chosen:
|
| 513 |
# 此时 message 应该是“AI 给出3个具体职业”后,用户的输入
|
| 514 |
-
# 学生现在选“1/2/3”或“换”
|
| 515 |
choice = message.strip().lower()
|
| 516 |
if choice in ["1","2","3"]:
|
| 517 |
idx = int(choice) - 1
|
|
@@ -520,7 +547,7 @@ def predict(message, history):
|
|
| 520 |
user_profile["final_choice"] = final_job
|
| 521 |
job_chosen = True
|
| 522 |
|
| 523 |
-
# 生成详细介绍
|
| 524 |
detail_msg = do_selected_career_detail(
|
| 525 |
selected_career=final_job,
|
| 526 |
bg_info=user_profile["bg_info"] or "",
|
|
@@ -529,17 +556,25 @@ def predict(message, history):
|
|
| 529 |
dd=user_profile["dream_day"] or ""
|
| 530 |
)
|
| 531 |
forward_deep_dive_done = True
|
| 532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
else:
|
| 534 |
return "无效的选项,请重新输入1/2/3或'换'"
|
| 535 |
elif choice == "换":
|
| 536 |
-
# 学生对这3个具体职业不满意
|
| 537 |
recommendation_round += 1
|
| 538 |
if recommendation_round > 2:
|
| 539 |
forward_done = True
|
| 540 |
return "已多次换职业,结束推荐。"
|
| 541 |
else:
|
| 542 |
-
# 重新推荐3个具体职业
|
| 543 |
sel_dir = user_profile.get("selected_direction") or "未知方向"
|
| 544 |
return recommend_3jobs_for_direction(
|
| 545 |
direction=sel_dir,
|
|
@@ -551,7 +586,29 @@ def predict(message, history):
|
|
| 551 |
else:
|
| 552 |
return "请回复1/2/3选择具体职业,或输入'换'来重新推荐"
|
| 553 |
|
| 554 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
elif job_chosen and not roadmap_offered and not roadmap_done:
|
| 556 |
roadmap_offered = True
|
| 557 |
return "需要一个时间轴式职业路线图吗?如需,则回复【要】,否则回复【不要】。"
|
|
@@ -591,7 +648,6 @@ def predict(message, history):
|
|
| 591 |
except Exception as e:
|
| 592 |
return f"发生错误: {str(e)}"
|
| 593 |
|
| 594 |
-
# 如果都没被return,执行这里:
|
| 595 |
return "信息收集完毕,如还未得到最终回复,请再输入任意文字继续。"
|
| 596 |
|
| 597 |
|
|
@@ -687,6 +743,9 @@ footer {
|
|
| 687 |
|
| 688 |
global direction_chosen, jobs_recommended, job_chosen
|
| 689 |
|
|
|
|
|
|
|
|
|
|
| 690 |
current_q_index = 0
|
| 691 |
questions[:] = base_questions
|
| 692 |
for k in user_profile:
|
|
@@ -708,6 +767,9 @@ footer {
|
|
| 708 |
jobs_recommended = False
|
| 709 |
job_chosen = False
|
| 710 |
|
|
|
|
|
|
|
|
|
|
| 711 |
return []
|
| 712 |
|
| 713 |
reset.click(reset_state, outputs=chatbot)
|
|
@@ -716,4 +778,4 @@ footer {
|
|
| 716 |
return [{"role":"assistant","content": questions[0][1]}]
|
| 717 |
|
| 718 |
demo.load(auto_first, outputs=chatbot)
|
| 719 |
-
demo.launch()
|
|
|
|
| 12 |
"dream_day": None,
|
| 13 |
"forward_direction_choice": None,
|
| 14 |
|
| 15 |
+
# Forward模式下更多状态
|
| 16 |
"recommended_directions": [], # 3个大方向
|
| 17 |
"selected_direction": None, # 学生最终选定的大方向
|
| 18 |
"recommended_jobs": [], # 3个具体职业
|
|
|
|
| 48 |
forward_done = False
|
| 49 |
backward_done = False
|
| 50 |
forward_recommendation_given = False
|
|
|
|
| 51 |
recommendation_round = 0
|
| 52 |
forward_deep_dive_done = False
|
| 53 |
roadmap_offered = False
|
| 54 |
roadmap_done = False
|
| 55 |
|
|
|
|
| 56 |
direction_chosen = False # 是否已经选定大方向
|
| 57 |
jobs_recommended = False # 是否已给出3个具体职业
|
| 58 |
job_chosen = False # 是否选定了具体职业
|
| 59 |
|
| 60 |
+
# ========== 新增:处理 A/B/C 三部分问题的标记 ==========
|
| 61 |
+
post_career_detail_asked = False # 是否已询问用户要看A/B/C
|
| 62 |
+
post_career_detail_done = False # 是否已回答完A/B/C
|
| 63 |
+
|
| 64 |
+
|
| 65 |
# ============================ 模型设置 ============================
|
| 66 |
model_default = "gpt-4o"
|
| 67 |
token_default = 2000
|
| 68 |
temp_default = 0.7
|
| 69 |
top_p_default = 0.95
|
| 70 |
|
| 71 |
+
# ~~~~~~~~~~~~~~~~~~~~~~~ 新增函数:answer_abc_questions ~~~~~~~~~~~~~~~~~~~~~~~
|
| 72 |
+
def answer_abc_questions(selected, bg_info, wv, ps, dd):
|
| 73 |
"""
|
| 74 |
+
根据用户选择 A/B/C/AB/ABC 等,返回相应的额外建议内容。
|
| 75 |
+
你可以自定义下面三段文案,以符合你的需要。
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
"""
|
| 77 |
+
text_A = f"""
|
| 78 |
+
**A: 专业/选课方向 & 求职入门建议**
|
| 79 |
+
- (这里可结合bg_info, wv, ps, dd给一些更针对的建议)
|
| 80 |
+
"""
|
| 81 |
+
|
| 82 |
+
text_B = f"""
|
| 83 |
+
**B: 本校资源利用建议**
|
| 84 |
+
- (这里介绍如何利用所在学校的Career Center、社团、实验室资源、校友网等)
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
text_C = f"""
|
| 88 |
+
**C: 实习 & Experience 积累 (networking)**
|
| 89 |
+
- (这里可提到怎么找实习、如何做networking、如何累积实操项目等)
|
| 90 |
+
"""
|
| 91 |
+
|
| 92 |
+
sel = selected.lower()
|
| 93 |
+
response_parts = []
|
| 94 |
+
if "a" in sel:
|
| 95 |
+
response_parts.append(text_A)
|
| 96 |
+
if "b" in sel:
|
| 97 |
+
response_parts.append(text_B)
|
| 98 |
+
if "c" in sel:
|
| 99 |
+
response_parts.append(text_C)
|
| 100 |
+
|
| 101 |
+
if not response_parts:
|
| 102 |
+
return "好的,你暂时不需要查看这三个专项。"
|
| 103 |
+
|
| 104 |
+
return "\n".join(response_parts)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 提供具体职业后,再深入介绍 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 108 |
+
def do_selected_career_detail(selected_career, bg_info, wv, ps, dd):
|
| 109 |
prompt = f"""
|
| 110 |
你是一位专业的职业规划顾问。
|
| 111 |
学生最终选择的具体职业: {selected_career}
|
|
|
|
| 147 |
|
| 148 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 路线图生成函数 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 149 |
def do_time_roadmap():
|
| 150 |
+
direction = user_profile.get("final_choice") or user_profile.get("selected_direction") or \
|
| 151 |
+
user_profile.get("forward_direction_choice") or user_profile.get("specific_career")
|
| 152 |
bg_info = user_profile["bg_info"] or "未知专业"
|
| 153 |
wv = user_profile["work_value"] or "暂无"
|
| 154 |
ps = user_profile["personality_summary"] or "暂无"
|
|
|
|
| 194 |
|
| 195 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 给定大方向后,再给3个具体职业 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 196 |
def recommend_3jobs_for_direction(direction, bg_info, wv, ps, dd):
|
|
|
|
|
|
|
|
|
|
| 197 |
prompt = f"""
|
| 198 |
你是一位专业的职业规划顾问。
|
| 199 |
学生选定的大方向:{direction}
|
|
|
|
| 247 |
|
| 248 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 深度分析函数(可做备用) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 249 |
def do_deep_analysis():
|
|
|
|
| 250 |
direction = user_profile["forward_direction_choice"] or "尚未选择"
|
| 251 |
bg_info = user_profile["bg_info"] or "未知背景"
|
| 252 |
wv = user_profile["work_value"] or "无"
|
|
|
|
| 398 |
|
| 399 |
global direction_chosen, jobs_recommended, job_chosen
|
| 400 |
|
| 401 |
+
# 新增全局标记
|
| 402 |
+
global post_career_detail_asked, post_career_detail_done
|
| 403 |
+
|
| 404 |
# ======================== 初始化 =========================
|
| 405 |
if not history:
|
| 406 |
current_q_index = 0
|
|
|
|
| 424 |
jobs_recommended = False
|
| 425 |
job_chosen = False
|
| 426 |
|
| 427 |
+
# 新增标记重置
|
| 428 |
+
post_career_detail_asked = False
|
| 429 |
+
post_career_detail_done = False
|
| 430 |
+
|
| 431 |
# ======================== 先处理基础问题 =========================
|
| 432 |
if 0 < current_q_index <= len(questions):
|
| 433 |
key = questions[current_q_index - 1][0]
|
|
|
|
| 455 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 456 |
if mode == "是":
|
| 457 |
if in_backward_flow and not backward_done:
|
|
|
|
| 458 |
if backward_index > 0 and backward_index <= len(backward_additional_questions):
|
| 459 |
prev_key = backward_additional_questions[backward_index - 1][0]
|
| 460 |
user_profile[prev_key] = message.strip()
|
|
|
|
| 466 |
else:
|
| 467 |
backward_done = True
|
| 468 |
|
|
|
|
| 469 |
if backward_done:
|
| 470 |
try:
|
| 471 |
api_key = os.environ.get("API_TOKEN")
|
|
|
|
| 493 |
# Forward模式处理
|
| 494 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 495 |
else:
|
| 496 |
+
# 如果还没选大方向/没问完前置问题
|
| 497 |
if in_forward_flow and not forward_done and not direction_chosen and not jobs_recommended and not job_chosen and not roadmap_done:
|
| 498 |
if forward_index > 0 and forward_index <= len(forward_additional_questions):
|
| 499 |
prev_key = forward_additional_questions[forward_index - 1][0]
|
|
|
|
| 504 |
forward_index += 1
|
| 505 |
return prompt_text
|
| 506 |
|
|
|
|
| 507 |
elif not forward_recommendation_given:
|
| 508 |
forward_recommendation_given = True
|
| 509 |
return recommend_3directions()
|
|
|
|
| 514 |
if choice in ["1","2","3"]:
|
| 515 |
idx = int(choice) - 1
|
| 516 |
if idx < len(user_profile["recommended_directions"]):
|
|
|
|
| 517 |
sel_dir = user_profile["recommended_directions"][idx]
|
| 518 |
user_profile["selected_direction"] = sel_dir
|
| 519 |
direction_chosen = True
|
|
|
|
| 520 |
return recommend_3jobs_for_direction(
|
| 521 |
direction=sel_dir,
|
| 522 |
bg_info=user_profile["bg_info"] or "",
|
|
|
|
| 532 |
forward_done = True
|
| 533 |
return "已多次换方向,结束推荐。"
|
| 534 |
else:
|
|
|
|
| 535 |
return recommend_3directions()
|
| 536 |
else:
|
| 537 |
return "请回复1/2/3选择方向,或输入'换'来重新推荐"
|
| 538 |
|
| 539 |
+
# 已选定大方向 -> 推荐了3个具体职业
|
| 540 |
elif direction_chosen and not jobs_recommended and not job_chosen:
|
| 541 |
# 此时 message 应该是“AI 给出3个具体职业”后,用户的输入
|
|
|
|
| 542 |
choice = message.strip().lower()
|
| 543 |
if choice in ["1","2","3"]:
|
| 544 |
idx = int(choice) - 1
|
|
|
|
| 547 |
user_profile["final_choice"] = final_job
|
| 548 |
job_chosen = True
|
| 549 |
|
| 550 |
+
# 生成更详细介绍
|
| 551 |
detail_msg = do_selected_career_detail(
|
| 552 |
selected_career=final_job,
|
| 553 |
bg_info=user_profile["bg_info"] or "",
|
|
|
|
| 556 |
dd=user_profile["dream_day"] or ""
|
| 557 |
)
|
| 558 |
forward_deep_dive_done = True
|
| 559 |
+
|
| 560 |
+
# 关键:现在我们“询问 A/B/C” -> 设置 post_career_detail_asked = True
|
| 561 |
+
global post_career_detail_asked
|
| 562 |
+
post_career_detail_asked = True
|
| 563 |
+
|
| 564 |
+
return detail_msg + "\n\n我还可以针对以下三方面提供建议:\n" \
|
| 565 |
+
"A:专业/选课 & 求职方向\n" \
|
| 566 |
+
"B:本校资源利用建议\n" \
|
| 567 |
+
"C:实习 & networking 积累\n" \
|
| 568 |
+
"如需要其中一个或多个,请输入 A / B / C / AB / BC / AC / ABC\n" \
|
| 569 |
+
"如果都不需要,请回复“不需要”。"
|
| 570 |
else:
|
| 571 |
return "无效的选项,请重新输入1/2/3或'换'"
|
| 572 |
elif choice == "换":
|
|
|
|
| 573 |
recommendation_round += 1
|
| 574 |
if recommendation_round > 2:
|
| 575 |
forward_done = True
|
| 576 |
return "已多次换职业,结束推荐。"
|
| 577 |
else:
|
|
|
|
| 578 |
sel_dir = user_profile.get("selected_direction") or "未知方向"
|
| 579 |
return recommend_3jobs_for_direction(
|
| 580 |
direction=sel_dir,
|
|
|
|
| 586 |
else:
|
| 587 |
return "请回复1/2/3选择具体职业,或输入'换'来重新推荐"
|
| 588 |
|
| 589 |
+
# ============== 新增:处理 A/B/C答疑 ==============
|
| 590 |
+
elif post_career_detail_asked and not post_career_detail_done:
|
| 591 |
+
user_choice = message.strip().lower()
|
| 592 |
+
if user_choice in ["不需要", "no", "n"]:
|
| 593 |
+
post_career_detail_done = True
|
| 594 |
+
# 接下来问时间轴
|
| 595 |
+
roadmap_offered = True
|
| 596 |
+
return "好的,不查看这三个专项。那需要一个时间轴式职业路线图吗?如需,则回复【要】,否则回复【不要】。"
|
| 597 |
+
else:
|
| 598 |
+
# 调用 answer_abc_questions
|
| 599 |
+
abc_text = answer_abc_questions(
|
| 600 |
+
selected=user_choice,
|
| 601 |
+
bg_info=user_profile["bg_info"],
|
| 602 |
+
wv=user_profile["work_value"],
|
| 603 |
+
ps=user_profile["personality_summary"],
|
| 604 |
+
dd=user_profile["dream_day"]
|
| 605 |
+
)
|
| 606 |
+
post_career_detail_done = True
|
| 607 |
+
# 问时间轴
|
| 608 |
+
roadmap_offered = True
|
| 609 |
+
return abc_text + "\n\n以上是你所选的A/B/C专项信息。需要一个时间轴式职业路线图吗?如需,则回复【要】,否则回复【不要】。"
|
| 610 |
+
|
| 611 |
+
# 已选定具体职业 -> 问是否需要时间轴
|
| 612 |
elif job_chosen and not roadmap_offered and not roadmap_done:
|
| 613 |
roadmap_offered = True
|
| 614 |
return "需要一个时间轴式职业路线图吗?如需,则回复【要】,否则回复【不要】。"
|
|
|
|
| 648 |
except Exception as e:
|
| 649 |
return f"发生错误: {str(e)}"
|
| 650 |
|
|
|
|
| 651 |
return "信息收集完毕,如还未得到最终回复,请再输入任意文字继续。"
|
| 652 |
|
| 653 |
|
|
|
|
| 743 |
|
| 744 |
global direction_chosen, jobs_recommended, job_chosen
|
| 745 |
|
| 746 |
+
# 新增
|
| 747 |
+
global post_career_detail_asked, post_career_detail_done
|
| 748 |
+
|
| 749 |
current_q_index = 0
|
| 750 |
questions[:] = base_questions
|
| 751 |
for k in user_profile:
|
|
|
|
| 767 |
jobs_recommended = False
|
| 768 |
job_chosen = False
|
| 769 |
|
| 770 |
+
post_career_detail_asked = False
|
| 771 |
+
post_career_detail_done = False
|
| 772 |
+
|
| 773 |
return []
|
| 774 |
|
| 775 |
reset.click(reset_state, outputs=chatbot)
|
|
|
|
| 778 |
return [{"role":"assistant","content": questions[0][1]}]
|
| 779 |
|
| 780 |
demo.load(auto_first, outputs=chatbot)
|
| 781 |
+
demo.launch()
|