Update app.py
Browse files
app.py
CHANGED
|
@@ -119,29 +119,46 @@ def answer_abc_questions(selected, bg_info, wv, ps, dd):
|
|
| 119 |
desired_parts.append("C")
|
| 120 |
|
| 121 |
if not desired_parts:
|
| 122 |
-
return "
|
| 123 |
|
| 124 |
prompt_text = f"""
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
-
|
| 129 |
-
-
|
| 130 |
-
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
"""
|
| 138 |
try:
|
| 139 |
api_key = os.environ.get("API_TOKEN")
|
| 140 |
if not api_key:
|
| 141 |
-
return "
|
| 142 |
client = OpenAI(api_key=api_key)
|
| 143 |
msgs = [
|
| 144 |
-
{"role": "system", "content": "
|
| 145 |
{"role": "user", "content": prompt_text}
|
| 146 |
]
|
| 147 |
resp = client.chat.completions.create(
|
|
@@ -154,35 +171,39 @@ def answer_abc_questions(selected, bg_info, wv, ps, dd):
|
|
| 154 |
)
|
| 155 |
return resp.choices[0].message.content
|
| 156 |
except Exception as e:
|
| 157 |
-
return f"
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 职业详细介绍 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 161 |
def do_selected_career_detail(selected_career, bg_info, wv, ps, dd):
|
| 162 |
prompt = f"""
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
"""
|
| 178 |
try:
|
| 179 |
api_key = os.environ.get("API_TOKEN")
|
| 180 |
if not api_key:
|
| 181 |
-
return "
|
| 182 |
client = OpenAI(api_key=api_key)
|
| 183 |
|
| 184 |
msgs = [
|
| 185 |
-
{"role": "system", "content": "
|
| 186 |
{"role": "user", "content": prompt}
|
| 187 |
]
|
| 188 |
resp = client.chat.completions.create(
|
|
@@ -195,7 +216,7 @@ def do_selected_career_detail(selected_career, bg_info, wv, ps, dd):
|
|
| 195 |
)
|
| 196 |
return resp.choices[0].message.content
|
| 197 |
except Exception as e:
|
| 198 |
-
return f"
|
| 199 |
|
| 200 |
|
| 201 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 时间轴式规划 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
| 119 |
desired_parts.append("C")
|
| 120 |
|
| 121 |
if not desired_parts:
|
| 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}
|
| 129 |
+
- Work Value: {wv}
|
| 130 |
+
- Personality: {ps}
|
| 131 |
+
- Ideal Workday: {dd}
|
| 132 |
+
|
| 133 |
+
The student wants insights on the following module(s): {', '.join(desired_parts)}
|
| 134 |
+
Please write a separate section for each selected module in order, using Markdown formatting.
|
| 135 |
+
|
| 136 |
+
(A: Course Selection & Career Entry)
|
| 137 |
+
- Analyze the student’s current academic background and what capabilities they already have.
|
| 138 |
+
- Based on their intended career, recommend what types of courses they should focus on.
|
| 139 |
+
- Suggest course names and keywords to guide their course planning.
|
| 140 |
+
|
| 141 |
+
(B: School Resource Utilization)
|
| 142 |
+
- Provide 3 types of suggestions:
|
| 143 |
+
1. How to utilize the university's career services.
|
| 144 |
+
2. How to get involved with career-related clubs, organizations, and platforms.
|
| 145 |
+
3. How to network with alumni in their field and improve networking skills.
|
| 146 |
+
|
| 147 |
+
(C: Internships & Experience Building)
|
| 148 |
+
- Suggest platforms to find internships.
|
| 149 |
+
- Recommend internship directions aligned with the student’s career goal.
|
| 150 |
+
- Provide tips for preparing materials and applying.
|
| 151 |
+
- Strategies for gaining experience through networking, internships, or campus jobs.
|
| 152 |
+
|
| 153 |
+
Only include the modules selected by the student. Do not generate content for unselected modules.
|
| 154 |
"""
|
| 155 |
try:
|
| 156 |
api_key = os.environ.get("API_TOKEN")
|
| 157 |
if not api_key:
|
| 158 |
+
return "Wrong:API_TOKEN Not set"
|
| 159 |
client = OpenAI(api_key=api_key)
|
| 160 |
msgs = [
|
| 161 |
+
{"role": "system", "content": "You are a professional career advisor who provides module-specific (A/B/C) analysis and suggestions."},
|
| 162 |
{"role": "user", "content": prompt_text}
|
| 163 |
]
|
| 164 |
resp = client.chat.completions.create(
|
|
|
|
| 171 |
)
|
| 172 |
return resp.choices[0].message.content
|
| 173 |
except Exception as e:
|
| 174 |
+
return f"Wrong ABC: {str(e)}"
|
| 175 |
+
|
| 176 |
|
| 177 |
|
|
|
|
| 178 |
def do_selected_career_detail(selected_career, bg_info, wv, ps, dd):
|
| 179 |
prompt = f"""
|
| 180 |
+
You are a professional career planning advisor.
|
| 181 |
+
|
| 182 |
+
The student has selected the following specific career: {selected_career}
|
| 183 |
+
Student Profile:
|
| 184 |
+
- Academic Background: {bg_info}
|
| 185 |
+
- Work Value: {wv}
|
| 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)
|
| 193 |
+
4. Key skills and certifications required
|
| 194 |
+
5. Typical work rhythm (fast-paced or routine?)
|
| 195 |
+
6. Industry outlook
|
| 196 |
+
|
| 197 |
+
Please use Markdown formatting in separate sections, with a minimum of 300 words.
|
| 198 |
"""
|
| 199 |
try:
|
| 200 |
api_key = os.environ.get("API_TOKEN")
|
| 201 |
if not api_key:
|
| 202 |
+
return "Wrong:API_TOKEN not set"
|
| 203 |
client = OpenAI(api_key=api_key)
|
| 204 |
|
| 205 |
msgs = [
|
| 206 |
+
{"role": "system", "content": "You are a professional career advisor who provides in-depth career descriptions."},
|
| 207 |
{"role": "user", "content": prompt}
|
| 208 |
]
|
| 209 |
resp = client.chat.completions.create(
|
|
|
|
| 216 |
)
|
| 217 |
return resp.choices[0].message.content
|
| 218 |
except Exception as e:
|
| 219 |
+
return f"Wrong path: {str(e)}"
|
| 220 |
|
| 221 |
|
| 222 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 时间轴式规划 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|