HelenaXH commited on
Commit
33bcb2d
·
verified ·
1 Parent(s): 049d943

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -68
app.py CHANGED
@@ -1,15 +1,10 @@
1
  import gradio as gr
2
  from openai import OpenAI
3
  import os
4
- import time
5
 
6
- # ========== 全局变量与基础问题 ==========
7
  user_profile = {
8
  "mode": None,
9
- "age": None,
10
- "degree": None,
11
- "interests": None,
12
- "mbti": None,
13
  "specific_career": None,
14
  "bg_info": None,
15
  "test_choice": None,
@@ -17,11 +12,7 @@ user_profile = {
17
  }
18
 
19
  base_questions = [
20
- ("mode", "你是否有心仪的职业方向?\n- 如果有,请回复'是'(Backward模式)\n- 如果没有,请回复'否'(Forward模式)"),
21
- ("age", "你的年龄范围是?(例如:'18岁以下','18-21岁','21-25岁','25-29岁','30岁以上')"),
22
- ("degree", "你目前的学历是什么?(例如:'本科在读','本科毕业','硕士在读','博士')"),
23
- ("interests", "请列出几个你的兴趣爱好,用逗号分隔。(例如:编程,心理学,设计)"),
24
- ("mbti", "你的MBTI人格类型是什么?(例如:INFP,INTJ,ENFP等)如果不知道,可以回复'不知道'")
25
  ]
26
 
27
  forward_additional_questions = [
@@ -31,6 +22,7 @@ forward_additional_questions = [
31
  ]
32
 
33
  backward_additional_questions = [
 
34
  ("bg_info", "请提供你的学校、年级、专业以及已有的实习或项目经历,以便更好地帮你规划如何达成目标。")
35
  ]
36
 
@@ -43,73 +35,40 @@ backward_index = 0
43
  forward_done = False
44
  backward_done = False
45
 
46
- system_prompt_default = "你是一位专业的职业规划顾问,帮助学生规划他们的职业路径。"
47
  model_default = "gpt-4o"
 
48
  temp_default = 0.7
49
  top_p_default = 0.95
50
- token_default = 2000
51
 
 
52
  def generate_system_prompt():
53
  mode = user_profile["mode"]
54
- age = user_profile["age"]
55
- degree = user_profile["degree"]
56
- interests = user_profile["interests"]
57
- mbti = user_profile["mbti"]
58
  specific_career = user_profile["specific_career"]
59
  bg_info = user_profile["bg_info"]
60
  test_choice = user_profile["test_choice"]
61
  forward_career_choice = user_profile["forward_career_choice"]
62
- if mode and "是" in mode:
63
- prompt = f"""
64
- 你是一位专业的职业规划顾问,使用"Backward Design"方法帮助学生规划他们的职业路径。
65
- 学生个人资料:
66
- - 年龄: {age}
67
- - : {degree}
68
- - 兴趣爱好: {interests}
69
- - MBTI类型: {mbti}
70
- - 目标职业: {specific_career}
71
- - 学术背景: {bg_info}
72
-
73
- 请分析学生提出的职业方向:
74
- 1. 提供该职业的简要分析
75
- 2. 列该领域排名靠前的组织/公司
76
- 3. 分析该职所需的技能能力
77
- 4. 描述职业发展和上升空间
78
-
79
- 然后,基于生的背景,请提供以下方面的具体建议:
80
- 1. 专业选择建议(是否需要转专业、双学位等)
81
- 2. 推荐的选课方向及理由
82
- 3. 需要学习的关键技能
83
- 4. 必要的资认证或考试
84
- 5. 如何利用学校资源(社团、项目、教授等)
85
- 6. 实习和经验积累策略(包括人脉拓展建议)
86
- 7. 简历优化建议
87
-
88
- 最后,请用Markdown格式提供清晰的职业路线图,格式如下:
89
- """
90
- else:
91
- prompt = f"""
92
- 你是一位专业的职业规划顾问,使用"Forward Design"方法帮助学生探索适合的职业路径。
93
- 学生个人资料:
94
- - 年龄: {age}
95
- - 学历: {degree}
96
- - 兴趣爱好: {interests}
97
- - MBTI类型: {mbti}
98
- - 学术背景: {bg_info}
99
- - 是否做过职业测评: {test_choice}
100
- - 学生选择感兴趣的职业方向: {forward_career_choice}
101
-
102
- 请根据学生的背景和个人资料进行分析:
103
- 1. 总结学生的优势和劣势
104
- 2. 分析学生的性格特点和职业适配性
105
- 3. 基于学生的学历背景、兴趣爱好和性格特点,推荐若干可能适合的职业大方向
106
- 4. 当学生选择了特定方向后,请进一步推荐3个具体职业,并针对每个职业提供:
107
- - 职业描述和日常工作内容
108
- - 该职业对学生的适合度分析
109
- - 入行门槛和要求
110
- - 详细的准备步骤(如选课、必要技能培训、资格认证或考试、如何利用学校资源、实习积累、简历优化等)
111
-
112
- 最后,请用Markdown格式提供一个清晰的职业路线图:
113
  """
114
  return prompt
115
 
 
1
  import gradio as gr
2
  from openai import OpenAI
3
  import os
 
4
 
5
+ # ========== 用户资料 & 问题设置 ==========
6
  user_profile = {
7
  "mode": None,
 
 
 
 
8
  "specific_career": None,
9
  "bg_info": None,
10
  "test_choice": None,
 
12
  }
13
 
14
  base_questions = [
15
+ ("mode", "你是否有心仪的职业方向?\n- 如果有,请回复'是'(Backward模式)\n- 如果没有,请回复'否'(Forward模式)")
 
 
 
 
16
  ]
17
 
18
  forward_additional_questions = [
 
22
  ]
23
 
24
  backward_additional_questions = [
25
+ ("specific_career", "请具体描述你想要从事的职业方向。"),
26
  ("bg_info", "请提供你的学校、年级、专业以及已有的实习或项目经历,以便更好地帮你规划如何达成目标。")
27
  ]
28
 
 
35
  forward_done = False
36
  backward_done = False
37
 
 
38
  model_default = "gpt-4o"
39
+ token_default = 2000
40
  temp_default = 0.7
41
  top_p_default = 0.95
 
42
 
43
+ # ========== Prompt 生成 ==========
44
  def generate_system_prompt():
45
  mode = user_profile["mode"]
 
 
 
 
46
  specific_career = user_profile["specific_career"]
47
  bg_info = user_profile["bg_info"]
48
  test_choice = user_profile["test_choice"]
49
  forward_career_choice = user_profile["forward_career_choice"]
50
+
51
+ if "" in (mode or ""):
52
+ return f"""
53
+ 你是一位专业的职业规划顾问,使用"Backward Design"方法帮助学生实现他们的职业目标。
54
+ 学生目标职业: {specific_career}
55
+ 术背景: {bg_info}
56
+
57
+ 请提供以下内容:
58
+ 1. 职业的简要分析
59
+ 2. 排名前列的组织或公司
60
+ 3. 所需技能和能力
61
+ 4. 职业发展空间
62
+
63
+ 并结合学生背景,提
64
+ 1. 业和课程建议
65
+ 2. 关键技能学习建议
66
+ 3. 资格认证与考试建议
67
+ 4. 如何利用校资源
68
+ 5. 实习和项目建议
69
+ 6. 简历优化建议
70
+
71
+ 最后,请用Markdown式呈现清��职业路径:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  """
73
  return prompt
74