Update app.py
Browse files
app.py
CHANGED
|
@@ -61,14 +61,14 @@ job_chosen = False # 是否选定了具体职业
|
|
| 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 |
-
|
|
|
|
| 72 |
def answer_abc_questions(selected, bg_info, wv, ps, dd):
|
| 73 |
"""
|
| 74 |
根据用户选择 A/B/C/AB/ABC 等,返回相应的额外建议内容。
|
|
@@ -387,6 +387,7 @@ def generate_system_prompt():
|
|
| 387 |
|
| 388 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 主逻辑函数 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 389 |
def predict(message, history):
|
|
|
|
| 390 |
global current_q_index, questions
|
| 391 |
global in_forward_flow, in_backward_flow
|
| 392 |
global forward_index, backward_index
|
|
@@ -398,7 +399,6 @@ def predict(message, history):
|
|
| 398 |
|
| 399 |
global direction_chosen, jobs_recommended, job_chosen
|
| 400 |
|
| 401 |
-
# 新增全局标记
|
| 402 |
global post_career_detail_asked, post_career_detail_done
|
| 403 |
|
| 404 |
# ======================== 初始化 =========================
|
|
@@ -424,7 +424,7 @@ def predict(message, history):
|
|
| 424 |
jobs_recommended = False
|
| 425 |
job_chosen = False
|
| 426 |
|
| 427 |
-
#
|
| 428 |
post_career_detail_asked = False
|
| 429 |
post_career_detail_done = False
|
| 430 |
|
|
@@ -557,8 +557,7 @@ def predict(message, history):
|
|
| 557 |
)
|
| 558 |
forward_deep_dive_done = True
|
| 559 |
|
| 560 |
-
# 关键:现在我们“询问 A/B/C”
|
| 561 |
-
global post_career_detail_asked
|
| 562 |
post_career_detail_asked = True
|
| 563 |
|
| 564 |
return detail_msg + "\n\n我还可以针对以下三方面提供建议:\n" \
|
|
@@ -567,6 +566,7 @@ def predict(message, history):
|
|
| 567 |
"C:实习 & networking 积累\n" \
|
| 568 |
"如需要其中一个或多个,请输入 A / B / C / AB / BC / AC / ABC\n" \
|
| 569 |
"如果都不需要,请回复“不需要”。"
|
|
|
|
| 570 |
else:
|
| 571 |
return "无效的选项,请重新输入1/2/3或'换'"
|
| 572 |
elif choice == "换":
|
|
@@ -591,11 +591,9 @@ def predict(message, history):
|
|
| 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"],
|
|
@@ -604,7 +602,6 @@ def predict(message, history):
|
|
| 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 |
|
|
@@ -743,7 +740,6 @@ footer {
|
|
| 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
|
|
|
|
| 61 |
post_career_detail_asked = False # 是否已询问用户要看A/B/C
|
| 62 |
post_career_detail_done = False # 是否已回答完A/B/C
|
| 63 |
|
|
|
|
| 64 |
# ============================ 模型设置 ============================
|
| 65 |
model_default = "gpt-4o"
|
| 66 |
token_default = 2000
|
| 67 |
temp_default = 0.7
|
| 68 |
top_p_default = 0.95
|
| 69 |
|
| 70 |
+
|
| 71 |
+
# ~~~~~~~~~~~~~~~~~~~~~~~ 函数:answer_abc_questions ~~~~~~~~~~~~~~~~~~~~~~~
|
| 72 |
def answer_abc_questions(selected, bg_info, wv, ps, dd):
|
| 73 |
"""
|
| 74 |
根据用户选择 A/B/C/AB/ABC 等,返回相应的额外建议内容。
|
|
|
|
| 387 |
|
| 388 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 主逻辑函数 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 389 |
def predict(message, history):
|
| 390 |
+
# ========== 必须在函数最开头声明全局变量 ==========
|
| 391 |
global current_q_index, questions
|
| 392 |
global in_forward_flow, in_backward_flow
|
| 393 |
global forward_index, backward_index
|
|
|
|
| 399 |
|
| 400 |
global direction_chosen, jobs_recommended, job_chosen
|
| 401 |
|
|
|
|
| 402 |
global post_career_detail_asked, post_career_detail_done
|
| 403 |
|
| 404 |
# ======================== 初始化 =========================
|
|
|
|
| 424 |
jobs_recommended = False
|
| 425 |
job_chosen = False
|
| 426 |
|
| 427 |
+
# 重置 ABC 标记
|
| 428 |
post_career_detail_asked = False
|
| 429 |
post_career_detail_done = False
|
| 430 |
|
|
|
|
| 557 |
)
|
| 558 |
forward_deep_dive_done = True
|
| 559 |
|
| 560 |
+
# 关键:现在我们“询问 A/B/C”
|
|
|
|
| 561 |
post_career_detail_asked = True
|
| 562 |
|
| 563 |
return detail_msg + "\n\n我还可以针对以下三方面提供建议:\n" \
|
|
|
|
| 566 |
"C:实习 & networking 积累\n" \
|
| 567 |
"如需要其中一个或多个,请输入 A / B / C / AB / BC / AC / ABC\n" \
|
| 568 |
"如果都不需要,请回复“不需要”。"
|
| 569 |
+
|
| 570 |
else:
|
| 571 |
return "无效的选项,请重新输入1/2/3或'换'"
|
| 572 |
elif choice == "换":
|
|
|
|
| 591 |
user_choice = message.strip().lower()
|
| 592 |
if user_choice in ["不需要", "no", "n"]:
|
| 593 |
post_career_detail_done = True
|
|
|
|
| 594 |
roadmap_offered = True
|
| 595 |
return "好的,不查看这三个专项。那需要一个时间轴式职业路线图吗?如需,则回复【要】,否则回复【不要】。"
|
| 596 |
else:
|
|
|
|
| 597 |
abc_text = answer_abc_questions(
|
| 598 |
selected=user_choice,
|
| 599 |
bg_info=user_profile["bg_info"],
|
|
|
|
| 602 |
dd=user_profile["dream_day"]
|
| 603 |
)
|
| 604 |
post_career_detail_done = True
|
|
|
|
| 605 |
roadmap_offered = True
|
| 606 |
return abc_text + "\n\n以上是你所选的A/B/C专项信息。需要一个时间轴式职业路线图吗?如需,则回复【要】,否则回复【不要】。"
|
| 607 |
|
|
|
|
| 740 |
|
| 741 |
global direction_chosen, jobs_recommended, job_chosen
|
| 742 |
|
|
|
|
| 743 |
global post_career_detail_asked, post_career_detail_done
|
| 744 |
|
| 745 |
current_q_index = 0
|