Update app.py
Browse files
app.py
CHANGED
|
@@ -73,7 +73,7 @@ top_p_default = 0.95
|
|
| 73 |
|
| 74 |
def backward_strategy_plan(specific_career, bg_info):
|
| 75 |
prompt = f"""
|
| 76 |
-
You are a professional career planning advisor.
|
| 77 |
A student has the target career: {specific_career}
|
| 78 |
Their current background is: {bg_info}
|
| 79 |
|
|
@@ -122,7 +122,7 @@ def answer_abc_questions(selected, bg_info, wv, ps, dd):
|
|
| 122 |
return "OK, you don't need ABC"
|
| 123 |
|
| 124 |
prompt_text = f"""
|
| 125 |
-
You are a professional career planning advisor. Below is the student's background information. Please provide detailed analysis and suggestions based on the selected module(s): A, B, or C.
|
| 126 |
|
| 127 |
Student Profile:
|
| 128 |
- Academic Background: {bg_info}
|
|
@@ -186,7 +186,7 @@ Student Profile:
|
|
| 186 |
- Personality: {ps}
|
| 187 |
- Ideal Workday: {dd}
|
| 188 |
|
| 189 |
-
Please write a detailed description of this career including at least the following:
|
| 190 |
1. Average salary (entry-level / mid-level / senior)
|
| 191 |
2. Work environment (remote/hybrid/in-office, team size, etc.)
|
| 192 |
3. Promotion difficulty (what qualifications or milestones are needed)
|
|
@@ -236,7 +236,7 @@ Student Profile:
|
|
| 236 |
- Personality: {ps}
|
| 237 |
- Ideal Workday: {dd}
|
| 238 |
|
| 239 |
-
Please create a timeline-style career roadmap based on the student's background and goal.
|
| 240 |
Use the following structure as a reference:
|
| 241 |
|
| 242 |
📍 Summer after Year 2: [What internship to apply for, what activities to participate in, what certifications to pursue]
|
|
@@ -273,7 +273,7 @@ Please write the roadmap using Markdown formatting and tailor your suggestions s
|
|
| 273 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Recomend jpb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 274 |
def recommend_3jobs_for_direction(direction, bg_info, wv, ps, dd):
|
| 275 |
prompt = f"""
|
| 276 |
-
You are a professional career advisor.
|
| 277 |
The student has selected the following general career direction: {direction}
|
| 278 |
Student background: {bg_info}
|
| 279 |
Work values: {wv}
|
|
@@ -347,7 +347,7 @@ def recommend_3directions():
|
|
| 347 |
dd = user_profile["dream_day"] or "None"
|
| 348 |
|
| 349 |
rec_prompt = f"""
|
| 350 |
-
Based on the following information, write a structured student profile and recommend 3 general career directions.
|
| 351 |
Address the student as "you" (not he/she).
|
| 352 |
|
| 353 |
- Academic Background: {bg_info}
|
|
@@ -397,18 +397,18 @@ If none are suitable, type 'change'.
|
|
| 397 |
|
| 398 |
if len(dir_list) < 3:
|
| 399 |
dir_list = [
|
| 400 |
-
"
|
| 401 |
-
"
|
| 402 |
-
"
|
| 403 |
]
|
| 404 |
|
| 405 |
-
user_profile["recommended_directions"] = dir_list[:3]
|
| 406 |
return output_text
|
| 407 |
except Exception as e:
|
| 408 |
return f"Wrong direction: {str(e)}"
|
| 409 |
|
| 410 |
|
| 411 |
-
|
| 412 |
def generate_system_prompt():
|
| 413 |
mode = user_profile["mode"]
|
| 414 |
sc = user_profile["specific_career"]
|
|
@@ -420,7 +420,7 @@ def generate_system_prompt():
|
|
| 420 |
|
| 421 |
if mode == "Y":
|
| 422 |
return f"""
|
| 423 |
-
You are a professional career advisor using the Backward Design method to help students achieve their career goals.
|
| 424 |
Target career: {sc}
|
| 425 |
Background information: {bg}
|
| 426 |
Please provide:
|
|
@@ -435,7 +435,7 @@ Finally, output a career roadmap in Markdown format like this:
|
|
| 435 |
"""
|
| 436 |
else:
|
| 437 |
return f"""
|
| 438 |
-
You are a professional career advisor using the Forward Design method to help students explore suitable career paths.
|
| 439 |
Student background: {bg}
|
| 440 |
Work values: {wv}
|
| 441 |
Personality summary: {ps}
|
|
@@ -537,60 +537,60 @@ def predict(message, history):
|
|
| 537 |
forward_deep_dive_done = True
|
| 538 |
post_career_detail_asked = True
|
| 539 |
|
| 540 |
-
return strategy + "\n\
|
| 541 |
-
"\n- A:
|
| 542 |
-
"\n- B:
|
| 543 |
-
"\n- C:
|
| 544 |
-
"\
|
| 545 |
-
"\
|
| 546 |
|
| 547 |
|
| 548 |
-
|
| 549 |
elif post_career_detail_asked and not post_career_detail_done:
|
| 550 |
user_choice = message.strip().lower()
|
| 551 |
-
if user_choice in ["
|
| 552 |
post_career_detail_done = True
|
| 553 |
roadmap_offered = True
|
| 554 |
-
return "
|
| 555 |
else:
|
| 556 |
abc_text = answer_abc_questions(
|
| 557 |
selected=user_choice,
|
| 558 |
bg_info=user_profile.get("bg_info", ""),
|
| 559 |
-
wv=user_profile.get("work_value", "
|
| 560 |
-
ps=user_profile.get("personality_summary", "
|
| 561 |
-
dd=user_profile.get("dream_day", "
|
| 562 |
)
|
| 563 |
post_career_detail_done = True
|
| 564 |
roadmap_offered = True
|
| 565 |
-
return abc_text + "\n\
|
| 566 |
|
| 567 |
-
|
| 568 |
elif job_chosen and not roadmap_offered and not roadmap_done:
|
| 569 |
roadmap_offered = True
|
| 570 |
-
return "
|
| 571 |
|
| 572 |
elif roadmap_offered and not roadmap_done:
|
| 573 |
ans = message.strip().lower()
|
| 574 |
-
if ans in ["
|
| 575 |
roadmap_done = True
|
| 576 |
backward_done = True
|
| 577 |
return do_time_roadmap()
|
| 578 |
else:
|
| 579 |
roadmap_done = True
|
| 580 |
backward_done = True
|
| 581 |
-
return "
|
|
|
|
| 582 |
|
| 583 |
-
# Backward 最终总结
|
| 584 |
if backward_done:
|
| 585 |
try:
|
| 586 |
api_key = os.environ.get("API_TOKEN")
|
| 587 |
if not api_key:
|
| 588 |
-
return "
|
| 589 |
client = OpenAI(api_key=api_key)
|
| 590 |
sprompt = generate_system_prompt()
|
| 591 |
msgs = [
|
| 592 |
{"role": "system", "content": sprompt},
|
| 593 |
-
{"role": "user", "content": f"
|
| 594 |
]
|
| 595 |
resp = client.chat.completions.create(
|
| 596 |
model=model_default,
|
|
@@ -602,14 +602,14 @@ def predict(message, history):
|
|
| 602 |
)
|
| 603 |
return resp.choices[0].message.content
|
| 604 |
except Exception as e:
|
| 605 |
-
return f"
|
|
|
|
| 606 |
|
| 607 |
|
| 608 |
-
# ~~~~~~~~~ Forward模式 ~~~~~~~~~
|
| 609 |
else:
|
| 610 |
-
|
| 611 |
if in_forward_flow and not direction_chosen:
|
| 612 |
-
|
| 613 |
if forward_index > 0 and forward_index <= len(forward_additional_questions):
|
| 614 |
prev_key = forward_additional_questions[forward_index - 1][0]
|
| 615 |
user_profile[prev_key] = message.strip()
|
|
@@ -619,12 +619,12 @@ def predict(message, history):
|
|
| 619 |
forward_index += 1
|
| 620 |
return prompt_text
|
| 621 |
|
| 622 |
-
|
| 623 |
elif not forward_recommendation_given:
|
| 624 |
forward_recommendation_given = True
|
| 625 |
return recommend_3directions()
|
| 626 |
|
| 627 |
-
|
| 628 |
else:
|
| 629 |
choice = message.strip().lower()
|
| 630 |
if choice in ["1","2","3"]:
|
|
@@ -633,7 +633,7 @@ def predict(message, history):
|
|
| 633 |
sel_dir = user_profile["recommended_directions"][idx]
|
| 634 |
user_profile["selected_direction"] = sel_dir
|
| 635 |
direction_chosen = True
|
| 636 |
-
|
| 637 |
return recommend_3jobs_for_direction(
|
| 638 |
direction=sel_dir,
|
| 639 |
bg_info=user_profile["bg_info"] or "",
|
|
@@ -642,18 +642,18 @@ def predict(message, history):
|
|
| 642 |
dd=user_profile["dream_day"] or ""
|
| 643 |
)
|
| 644 |
else:
|
| 645 |
-
return "
|
| 646 |
-
elif choice == "
|
| 647 |
recommendation_round += 1
|
| 648 |
if recommendation_round > 2:
|
| 649 |
forward_done = True
|
| 650 |
-
return "
|
| 651 |
else:
|
| 652 |
return recommend_3directions()
|
| 653 |
else:
|
| 654 |
-
return "
|
| 655 |
|
| 656 |
-
|
| 657 |
elif direction_chosen and jobs_recommended and not job_chosen:
|
| 658 |
choice = message.strip().lower()
|
| 659 |
if choice in ["1","2","3"]:
|
|
@@ -672,24 +672,24 @@ def predict(message, history):
|
|
| 672 |
)
|
| 673 |
forward_deep_dive_done = True
|
| 674 |
|
| 675 |
-
|
| 676 |
post_career_detail_asked = True
|
| 677 |
|
| 678 |
-
return detail_msg + "\n\
|
| 679 |
-
"\n- A:
|
| 680 |
-
"\n- B:
|
| 681 |
-
"\n- C:
|
| 682 |
-
"\
|
| 683 |
-
"\
|
| 684 |
else:
|
| 685 |
-
return "
|
| 686 |
-
elif choice == "
|
| 687 |
recommendation_round += 1
|
| 688 |
if recommendation_round > 2:
|
| 689 |
forward_done = True
|
| 690 |
-
return "
|
| 691 |
else:
|
| 692 |
-
sel_dir = user_profile.get("selected_direction") or "
|
| 693 |
return recommend_3jobs_for_direction(
|
| 694 |
direction=sel_dir,
|
| 695 |
bg_info=user_profile["bg_info"] or "",
|
|
@@ -698,15 +698,15 @@ def predict(message, history):
|
|
| 698 |
dd=user_profile["dream_day"] or ""
|
| 699 |
)
|
| 700 |
else:
|
| 701 |
-
return "
|
| 702 |
|
| 703 |
-
|
| 704 |
elif post_career_detail_asked and not post_career_detail_done:
|
| 705 |
user_choice = message.strip().lower()
|
| 706 |
-
if user_choice in ["
|
| 707 |
post_career_detail_done = True
|
| 708 |
roadmap_offered = True
|
| 709 |
-
return "
|
| 710 |
else:
|
| 711 |
abc_text = answer_abc_questions(
|
| 712 |
selected=user_choice,
|
|
@@ -717,35 +717,35 @@ def predict(message, history):
|
|
| 717 |
)
|
| 718 |
post_career_detail_done = True
|
| 719 |
roadmap_offered = True
|
| 720 |
-
return abc_text + "\n\n
|
| 721 |
|
| 722 |
# 已选定具体职业 -> 问是否需要时间轴
|
| 723 |
elif job_chosen and not roadmap_offered and not roadmap_done:
|
| 724 |
roadmap_offered = True
|
| 725 |
-
return "
|
| 726 |
|
| 727 |
elif roadmap_offered and not roadmap_done:
|
| 728 |
ans = message.strip().lower()
|
| 729 |
-
if ans in ["
|
| 730 |
roadmap_done = True
|
| 731 |
forward_done = True
|
| 732 |
return do_time_roadmap()
|
| 733 |
else:
|
| 734 |
roadmap_done = True
|
| 735 |
forward_done = True
|
| 736 |
-
return "
|
| 737 |
|
| 738 |
-
|
| 739 |
if forward_done:
|
| 740 |
try:
|
| 741 |
api_key = os.environ.get("API_TOKEN")
|
| 742 |
if not api_key:
|
| 743 |
-
return "
|
| 744 |
client = OpenAI(api_key=api_key)
|
| 745 |
sprompt = generate_system_prompt()
|
| 746 |
msgs = [
|
| 747 |
{"role":"system","content":sprompt},
|
| 748 |
-
{"role":"user","content": f"
|
| 749 |
]
|
| 750 |
resp = client.chat.completions.create(
|
| 751 |
model=model_default,
|
|
@@ -757,7 +757,7 @@ def predict(message, history):
|
|
| 757 |
)
|
| 758 |
return resp.choices[0].message.content
|
| 759 |
except Exception as e:
|
| 760 |
-
return f"
|
| 761 |
|
| 762 |
|
| 763 |
return "Information down"
|
|
|
|
| 73 |
|
| 74 |
def backward_strategy_plan(specific_career, bg_info):
|
| 75 |
prompt = f"""
|
| 76 |
+
You are a professional career planning advisor,use english.
|
| 77 |
A student has the target career: {specific_career}
|
| 78 |
Their current background is: {bg_info}
|
| 79 |
|
|
|
|
| 122 |
return "OK, you don't need ABC"
|
| 123 |
|
| 124 |
prompt_text = f"""
|
| 125 |
+
You are a professional career planning advisor. Below is the student's background information. Please provide detailed analysis and suggestions based on the selected module(s): A, B, or C,use english.
|
| 126 |
|
| 127 |
Student Profile:
|
| 128 |
- Academic Background: {bg_info}
|
|
|
|
| 186 |
- Personality: {ps}
|
| 187 |
- Ideal Workday: {dd}
|
| 188 |
|
| 189 |
+
Please write a detailed description of this career including at least the following,use english:
|
| 190 |
1. Average salary (entry-level / mid-level / senior)
|
| 191 |
2. Work environment (remote/hybrid/in-office, team size, etc.)
|
| 192 |
3. Promotion difficulty (what qualifications or milestones are needed)
|
|
|
|
| 236 |
- Personality: {ps}
|
| 237 |
- Ideal Workday: {dd}
|
| 238 |
|
| 239 |
+
Please create a timeline-style career roadmap based on the student's background and goal,use english.
|
| 240 |
Use the following structure as a reference:
|
| 241 |
|
| 242 |
📍 Summer after Year 2: [What internship to apply for, what activities to participate in, what certifications to pursue]
|
|
|
|
| 273 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Recomend jpb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 274 |
def recommend_3jobs_for_direction(direction, bg_info, wv, ps, dd):
|
| 275 |
prompt = f"""
|
| 276 |
+
You are a professional career advisor,use english.
|
| 277 |
The student has selected the following general career direction: {direction}
|
| 278 |
Student background: {bg_info}
|
| 279 |
Work values: {wv}
|
|
|
|
| 347 |
dd = user_profile["dream_day"] or "None"
|
| 348 |
|
| 349 |
rec_prompt = f"""
|
| 350 |
+
Based on the following information, write a structured student profile and recommend 3 general career directions, use english.
|
| 351 |
Address the student as "you" (not he/she).
|
| 352 |
|
| 353 |
- Academic Background: {bg_info}
|
|
|
|
| 397 |
|
| 398 |
if len(dir_list) < 3:
|
| 399 |
dir_list = [
|
| 400 |
+
"Direction 1",
|
| 401 |
+
"Directionn2",
|
| 402 |
+
"Direction 3"
|
| 403 |
]
|
| 404 |
|
| 405 |
+
user_profile["recommended_directions"] = dir_list[:3]
|
| 406 |
return output_text
|
| 407 |
except Exception as e:
|
| 408 |
return f"Wrong direction: {str(e)}"
|
| 409 |
|
| 410 |
|
| 411 |
+
|
| 412 |
def generate_system_prompt():
|
| 413 |
mode = user_profile["mode"]
|
| 414 |
sc = user_profile["specific_career"]
|
|
|
|
| 420 |
|
| 421 |
if mode == "Y":
|
| 422 |
return f"""
|
| 423 |
+
You are a professional career advisor using the Backward Design method to help students achieve their career goals,use english.
|
| 424 |
Target career: {sc}
|
| 425 |
Background information: {bg}
|
| 426 |
Please provide:
|
|
|
|
| 435 |
"""
|
| 436 |
else:
|
| 437 |
return f"""
|
| 438 |
+
You are a professional career advisor using the Forward Design method to help students explore suitable career paths,use english.
|
| 439 |
Student background: {bg}
|
| 440 |
Work values: {wv}
|
| 441 |
Personality summary: {ps}
|
|
|
|
| 537 |
forward_deep_dive_done = True
|
| 538 |
post_career_detail_asked = True
|
| 539 |
|
| 540 |
+
return strategy + "\n\nI can do further exploration:" \
|
| 541 |
+
"\n- A:Major or course & Job direction" \
|
| 542 |
+
"\n- B:School Resources" \
|
| 543 |
+
"\n- C:Internship & networking " \
|
| 544 |
+
"\nEnter A / B / C / AB / BC / AC / ABC" \
|
| 545 |
+
"\nif No need'Please NO'。"
|
| 546 |
|
| 547 |
|
| 548 |
+
|
| 549 |
elif post_career_detail_asked and not post_career_detail_done:
|
| 550 |
user_choice = message.strip().lower()
|
| 551 |
+
if user_choice in ["Please NO", "no", "n"]:
|
| 552 |
post_career_detail_done = True
|
| 553 |
roadmap_offered = True
|
| 554 |
+
return "OK, would you like a job path【I need】,or【NO need】。"
|
| 555 |
else:
|
| 556 |
abc_text = answer_abc_questions(
|
| 557 |
selected=user_choice,
|
| 558 |
bg_info=user_profile.get("bg_info", ""),
|
| 559 |
+
wv=user_profile.get("work_value", "None"),
|
| 560 |
+
ps=user_profile.get("personality_summary", "None"),
|
| 561 |
+
dd=user_profile.get("dream_day", "None")
|
| 562 |
)
|
| 563 |
post_career_detail_done = True
|
| 564 |
roadmap_offered = True
|
| 565 |
+
return abc_text + "\n\nDo you need a time path plan?enter【I need】,or 【NO need】。"
|
| 566 |
|
| 567 |
+
|
| 568 |
elif job_chosen and not roadmap_offered and not roadmap_done:
|
| 569 |
roadmap_offered = True
|
| 570 |
+
return "Need a time path map?【I need】,or【NO need】。"
|
| 571 |
|
| 572 |
elif roadmap_offered and not roadmap_done:
|
| 573 |
ans = message.strip().lower()
|
| 574 |
+
if ans in ["I need", "yes", "y"]:
|
| 575 |
roadmap_done = True
|
| 576 |
backward_done = True
|
| 577 |
return do_time_roadmap()
|
| 578 |
else:
|
| 579 |
roadmap_done = True
|
| 580 |
backward_done = True
|
| 581 |
+
return "OK, your plan is finished"
|
| 582 |
+
|
| 583 |
|
|
|
|
| 584 |
if backward_done:
|
| 585 |
try:
|
| 586 |
api_key = os.environ.get("API_TOKEN")
|
| 587 |
if not api_key:
|
| 588 |
+
return "Wrong:API_TOKEN not set"
|
| 589 |
client = OpenAI(api_key=api_key)
|
| 590 |
sprompt = generate_system_prompt()
|
| 591 |
msgs = [
|
| 592 |
{"role": "system", "content": sprompt},
|
| 593 |
+
{"role": "user", "content": f"this material: {user_profile}. enter if you need more"}
|
| 594 |
]
|
| 595 |
resp = client.chat.completions.create(
|
| 596 |
model=model_default,
|
|
|
|
| 602 |
)
|
| 603 |
return resp.choices[0].message.content
|
| 604 |
except Exception as e:
|
| 605 |
+
return f"Wrong: {str(e)}"
|
| 606 |
+
|
| 607 |
|
| 608 |
|
|
|
|
| 609 |
else:
|
| 610 |
+
|
| 611 |
if in_forward_flow and not direction_chosen:
|
| 612 |
+
|
| 613 |
if forward_index > 0 and forward_index <= len(forward_additional_questions):
|
| 614 |
prev_key = forward_additional_questions[forward_index - 1][0]
|
| 615 |
user_profile[prev_key] = message.strip()
|
|
|
|
| 619 |
forward_index += 1
|
| 620 |
return prompt_text
|
| 621 |
|
| 622 |
+
|
| 623 |
elif not forward_recommendation_given:
|
| 624 |
forward_recommendation_given = True
|
| 625 |
return recommend_3directions()
|
| 626 |
|
| 627 |
+
|
| 628 |
else:
|
| 629 |
choice = message.strip().lower()
|
| 630 |
if choice in ["1","2","3"]:
|
|
|
|
| 633 |
sel_dir = user_profile["recommended_directions"][idx]
|
| 634 |
user_profile["selected_direction"] = sel_dir
|
| 635 |
direction_chosen = True
|
| 636 |
+
|
| 637 |
return recommend_3jobs_for_direction(
|
| 638 |
direction=sel_dir,
|
| 639 |
bg_info=user_profile["bg_info"] or "",
|
|
|
|
| 642 |
dd=user_profile["dream_day"] or ""
|
| 643 |
)
|
| 644 |
else:
|
| 645 |
+
return "Enter 1/2/3或'Change'"
|
| 646 |
+
elif choice == "Change":
|
| 647 |
recommendation_round += 1
|
| 648 |
if recommendation_round > 2:
|
| 649 |
forward_done = True
|
| 650 |
+
return "Change too many times"
|
| 651 |
else:
|
| 652 |
return recommend_3directions()
|
| 653 |
else:
|
| 654 |
+
return "enter 1,2,3 or change"
|
| 655 |
|
| 656 |
+
|
| 657 |
elif direction_chosen and jobs_recommended and not job_chosen:
|
| 658 |
choice = message.strip().lower()
|
| 659 |
if choice in ["1","2","3"]:
|
|
|
|
| 672 |
)
|
| 673 |
forward_deep_dive_done = True
|
| 674 |
|
| 675 |
+
|
| 676 |
post_career_detail_asked = True
|
| 677 |
|
| 678 |
+
return detail_msg + "\n\nI can do futher information for you:" \
|
| 679 |
+
"\n- A:major course & job" \
|
| 680 |
+
"\n- B:School Resources" \
|
| 681 |
+
"\n- C:Internship & networking" \
|
| 682 |
+
"\nneed more information A / B / C / AB / BC / AC / ABC" \
|
| 683 |
+
"\nNO need,enter'No need'。"
|
| 684 |
else:
|
| 685 |
+
return "Re enter please"
|
| 686 |
+
elif choice == "Change":
|
| 687 |
recommendation_round += 1
|
| 688 |
if recommendation_round > 2:
|
| 689 |
forward_done = True
|
| 690 |
+
return "too many changes"
|
| 691 |
else:
|
| 692 |
+
sel_dir = user_profile.get("selected_direction") or "No direction"
|
| 693 |
return recommend_3jobs_for_direction(
|
| 694 |
direction=sel_dir,
|
| 695 |
bg_info=user_profile["bg_info"] or "",
|
|
|
|
| 698 |
dd=user_profile["dream_day"] or ""
|
| 699 |
)
|
| 700 |
else:
|
| 701 |
+
return "enter 1,2,3 or renture"
|
| 702 |
|
| 703 |
+
|
| 704 |
elif post_career_detail_asked and not post_career_detail_done:
|
| 705 |
user_choice = message.strip().lower()
|
| 706 |
+
if user_choice in ["NO need", "no", "n"]:
|
| 707 |
post_career_detail_done = True
|
| 708 |
roadmap_offered = True
|
| 709 |
+
return "OK, do you need a time plan, enter 【I need】,or【NO need】。"
|
| 710 |
else:
|
| 711 |
abc_text = answer_abc_questions(
|
| 712 |
selected=user_choice,
|
|
|
|
| 717 |
)
|
| 718 |
post_career_detail_done = True
|
| 719 |
roadmap_offered = True
|
| 720 |
+
return abc_text + "\n\n this is your further information, do you need a time plan, enter【I need】, or【NO need】。"
|
| 721 |
|
| 722 |
# 已选定具体职业 -> 问是否需要时间轴
|
| 723 |
elif job_chosen and not roadmap_offered and not roadmap_done:
|
| 724 |
roadmap_offered = True
|
| 725 |
+
return "Need a time path plan enter【I need】,否则回复【NO need】。"
|
| 726 |
|
| 727 |
elif roadmap_offered and not roadmap_done:
|
| 728 |
ans = message.strip().lower()
|
| 729 |
+
if ans in ["I need", "yes", "y"]:
|
| 730 |
roadmap_done = True
|
| 731 |
forward_done = True
|
| 732 |
return do_time_roadmap()
|
| 733 |
else:
|
| 734 |
roadmap_done = True
|
| 735 |
forward_done = True
|
| 736 |
+
return "OK, plan is finished"
|
| 737 |
|
| 738 |
+
|
| 739 |
if forward_done:
|
| 740 |
try:
|
| 741 |
api_key = os.environ.get("API_TOKEN")
|
| 742 |
if not api_key:
|
| 743 |
+
return "Wrong:API_TOKEN Not set"
|
| 744 |
client = OpenAI(api_key=api_key)
|
| 745 |
sprompt = generate_system_prompt()
|
| 746 |
msgs = [
|
| 747 |
{"role":"system","content":sprompt},
|
| 748 |
+
{"role":"user","content": f"this is material: {user_profile}. enter to find more"}
|
| 749 |
]
|
| 750 |
resp = client.chat.completions.create(
|
| 751 |
model=model_default,
|
|
|
|
| 757 |
)
|
| 758 |
return resp.choices[0].message.content
|
| 759 |
except Exception as e:
|
| 760 |
+
return f"Wrong: {str(e)}"
|
| 761 |
|
| 762 |
|
| 763 |
return "Information down"
|