xiaofeifei commited on
Commit
8bc2ac8
·
1 Parent(s): 21b7d8e

init commit

Browse files

Signed-off-by: vax521 <13263397018@163.com>

Files changed (5) hide show
  1. app.py +464 -0
  2. requirements.txt +1 -0
  3. test_resume.txt +40 -0
  4. test_resume_算法.txt +43 -0
  5. utils.py +101 -0
app.py ADDED
@@ -0,0 +1,464 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from utils import draw_radar_chart, draw_multi_radar_chart, extract_json
2
+ import gradio as gr
3
+ from pydantic import BaseModel
4
+ import os
5
+ import requests
6
+ import json
7
+
8
+ def get_access_token():
9
+ """
10
+ 使用 API Key,Secret Key 获取access_token,替换下列示例中的应用API Key、应用Secret Key
11
+ """
12
+
13
+ url = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=TG0gvfr6GPTLE3xQvTfESTv1&client_secret=zgIKU71KMox73p4jljCUC3sgifoLDDd1"
14
+
15
+ payload = json.dumps("")
16
+ headers = {
17
+ 'Content-Type': 'application/json',
18
+ 'Accept': 'application/json'
19
+ }
20
+
21
+ response = requests.request("POST", url, headers=headers, data=payload)
22
+ return response.json().get("access_token")
23
+
24
+ def ask_gpt(prompt):
25
+ url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=" + get_access_token()
26
+ print(prompt)
27
+ payload = json.dumps({
28
+ "messages": [
29
+ {
30
+ "role": "user",
31
+ "content": prompt
32
+ }
33
+ ]
34
+ })
35
+ headers = {
36
+ 'Content-Type': 'application/json'
37
+ }
38
+
39
+ response = requests.request("POST", url, headers=headers, data=payload)
40
+ print(response)
41
+ return json.loads(response.text)['result']
42
+
43
+
44
+ def ask_gpt_with_history(history):
45
+ url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=" + get_access_token()
46
+
47
+ payload = json.dumps({
48
+ "messages": history
49
+ })
50
+ headers = {
51
+ 'Content-Type': 'application/json'
52
+ }
53
+
54
+ response = requests.request("POST", url, headers=headers, data=payload)
55
+ return json.loads(response.text)['result']
56
+
57
+
58
+ async def predict(input, history):
59
+ """
60
+ Predict the response of the chatbot and complete a running list of chat history.
61
+ """
62
+ history.append({"role": "user", "content": input})
63
+ response = ask_gpt_with_history(history)
64
+ history.append({"role": "assistant", "content": response})
65
+ messages = [(history[i]["content"], history[i + 1]["content"]) for i in range(0, len(history) - 1, 2)]
66
+ return messages, history
67
+
68
+
69
+ class Message(BaseModel):
70
+ role: str
71
+ content: str
72
+
73
+
74
+ def parse_file(file):
75
+ txt = pure_parse_file(file)
76
+ return txt, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
77
+
78
+
79
+ def pure_parse_file(file):
80
+ with open(file.name, encoding="utf8") as in_file:
81
+ txt = in_file.read()
82
+ return txt
83
+
84
+
85
+ # 生成人才画像
86
+ def generate_talent_portrait(resume):
87
+ prompt = f"你现在是HR招聘专家,下面是候选人的简历:\n\"\"\"\"{resume}\"\"\"\"\n请你分析候选人的教育背景、工作经验、技能等方面的特点,给出候选人的人才画像,并概括性的分析候选人的优点和不足。"
88
+ return ask_gpt(prompt)
89
+
90
+
91
+ # 人岗匹配度
92
+ def person_job_fit_gene(resume, jd):
93
+ # prompt = f"你现在是HR招聘专家,某职位要求是:{{{jd}}}\n某候选人简历如下:{{{get_talent_outline(resume)}}}" + "。岗位与候选人之间的匹配度可以用0-1之间的数字表示,0表示完全不匹配,1表示完全匹配。请你评估应聘岗位与候选人的匹配度,并给出理由。"
94
+ prompt = '''你现在是HR招聘专家,某职位要求是:
95
+ {}
96
+ 某候选人简历信息如下:{}。
97
+ 针对候选人的简历与职位要求进行匹配度评估,采取以下规则:1. 教育背景匹配度评估:
98
+ - 完全匹配:候选人的教育背景与职位要求完全符合。
99
+ - 较为匹配:候选人的教育背景与职位要求有一定的相关性,但不完全符合。
100
+ - 较不匹配:候选人的教育背景与职位要求有一些不相关的情况。
101
+ - 完全不匹配:候选人的教育背景与职位要求完全不符合。
102
+
103
+ 2. 工作经验匹配度评估:
104
+ - 完全匹配:候选人的工作经验与职位要求完全符合。
105
+ - 较为匹配:候选人的工作经验与职位要求具备相应的技能和经验,但可能缺少某些方面的经验。
106
+ - 较不匹配:候选人的工作经验与职位要求相差较大,缺乏相关的技能和经验。
107
+ - 完全不匹配:候选人的工作经验与职位要求完全不符合。
108
+
109
+ 3. 技能与能力匹配度评估:
110
+ - 完全匹配:候选人具备职位要求的所有必备技能和能力。
111
+ - 较为匹配:候选人具备部分职位要求的技能和能力,但可能缺少某些方面的能力。
112
+ - 较不匹配:候选人缺乏职位要求的关键技能和能力。
113
+ - 完全不匹配:候选人的技能和能力与职位要求完全不符合。
114
+
115
+ 4. 其他因素综合考虑:
116
+ - 完全匹配:候选人除了教育背景、工作经验和技能与能力外,还具备其他与职位要求相关的因素,如培训经历、认证证书等。
117
+ - 较为匹配:候选人除了教育背景、工作经验和技能与能力外,可能还具备一些与职位要求相关的因素。
118
+ - 较��匹配:候选人缺乏与职位要求相关的其他因素。
119
+ - 完全不匹配:候选人的其他因素与职位要求完全不符合。
120
+
121
+ 5. 整体的人岗匹配度:
122
+ 综合考量候选人的教育背景、工作经验、技能与能力以及其他因素得到整体的岗位匹配度。
123
+ 根据以上规则,对简历与职位要求之间的匹配度进行评估,并划分为完全匹配、较为匹配、较不匹配和完全不匹配四个档次。
124
+ 评估结果请以json格式返回给我,下面是返回结果的示例:
125
+
126
+ "教育背景匹配度":{
127
+ "结果":"",
128
+ "评估说明":""
129
+ },
130
+ "工作经验匹配度":{
131
+ "结果":"",
132
+ "评估说明":""
133
+ },
134
+ "技能与能力匹配度":{
135
+ "结果":"",
136
+ "评估说明":""
137
+ },
138
+ "其他因素匹配度":{
139
+ "结果":"",
140
+ "评估说明":""
141
+ },
142
+ "整体匹配度":{
143
+ "结果":"",
144
+ "评估说明":""
145
+
146
+
147
+ '''.format(jd, resume)
148
+ res = ask_gpt(prompt)
149
+ res = res.replace("\n","")
150
+ res = res.replace("```","")
151
+ res = res.replace("json","")
152
+ data = json.loads(res)
153
+ edu_matching = data['教育背景匹配度']['结果']
154
+ edu_description = data['教育背景匹配度']['评估说明']
155
+
156
+ work_exp_matching = data['工作经验匹配度']['结果']
157
+ work_exp_description = data['工作经验匹配度']['评估说明']
158
+
159
+ skill_matching = data['技能与能力匹配度']['结果']
160
+ skill_description = data['技能与能力匹配度']['评估说明']
161
+
162
+ other_matching = data['其他因素匹配度']['结果']
163
+ other_description = data['其他因素匹配度']['评估说明']
164
+
165
+ overall_matching = data['整体匹配度']['结果']
166
+ overall_description = data['整体匹配度']['评估说明']
167
+ return gr.update(value=edu_matching), gr.update(value=work_exp_matching, ), gr.update(
168
+ value=skill_matching, ), gr.update(value=other_matching, ), gr.update(
169
+ value=overall_matching, ), edu_description, work_exp_description, skill_description, other_description, overall_description
170
+
171
+
172
+ # interview_questions
173
+ def generate_interview_questions(work_experience):
174
+ prompt = f"你现在是HR招聘专家,下面是候选人A的工作经历:{work_experience}\n我可以问哪些问题来判断该候选人的能力水平?"
175
+ return ask_gpt(prompt)
176
+
177
+
178
+ # interview_questions
179
+ def generate_interview_questions_new(resume, jd):
180
+ # prompt = f"你现在是HR高级面试官,某职位要求是:{{{jd}}}\n下面是候选人A简历的:\n{resume}\n请你生成一些面试问题来判断该候选人的能力水平。注意,请把面试问题以python列表格式返回给我,不要返回任何额外内容。"
181
+ prompt = f"你现在是HR高级面试官,某职位要求是:{{{jd}}}\n下面是候选人A简历的:\n{resume}\n请你生成一些面试问题来判断该候选人的能力水平。注意,只返回面试问题即可,不要返回任何额外内容。"
182
+ res = ask_gpt(prompt)
183
+ return res
184
+
185
+
186
+ def generate_jd(jobTitle, eduLevel, workYearArr):
187
+ prompt = "你现在是HR招聘专家,你需要发布一个名称为\"" + jobTitle + "\"的职位,请你撰写一份该职位的JD,内容包括工作职责和任职要求。"
188
+ if eduLevel != "":
189
+ prompt += "该岗位的最低学历要求为" + eduLevel + "。"
190
+ if workYearArr != "":
191
+ prompt += "该岗位的工作年限要求为" + workYearArr + "。"
192
+ prompt += "注意:非必要情况不要使用英文,内容不要包含薪酬福利等敏感信息。"
193
+ return ask_gpt(prompt)
194
+
195
+
196
+ def generate_test_resume(target_job, item_list):
197
+ resume_gene_prompt = f"你现在是HR测试数据生成器,请帮我生成一份求职目标为{target_job}的候选人简历,需要包含以下关键信息:\n{item_list}。\n注意,结果请以markdown格式返回给我,并且不要返回额外信息。"
198
+ print(resume_gene_prompt)
199
+ return ask_gpt(resume_gene_prompt)
200
+
201
+
202
+ def generate_interview_feedback(commu_skills, pro_skills, tech_skills, solve_skills, team_skills, pressure_resistance,
203
+ if_ok):
204
+ prompt = f"""
205
+ 你现在是HR招聘专家,下面是某候选人的面试评估结果:
206
+ ***
207
+ 沟通能力:{commu_skills}
208
+ 专业知识:{pro_skills}
209
+ 技术能力:{tech_skills}
210
+ 解决问题的能力:{solve_skills}
211
+ 团队合作能力:{team_skills}
212
+ 抗压能力:{pressure_resistance}
213
+ 是否录用:{if_ok}
214
+ ***
215
+ 请你根据是否录用结果和其他各项能力的表现生成一份面试评价。
216
+ """
217
+ print(prompt)
218
+ return ask_gpt(prompt)
219
+
220
+
221
+ def gene_ability_score(resume):
222
+ prompt = f"""你现在是HR招聘专家.
223
+ 某候选人简历如下:
224
+ {{{resume}}}
225
+ 请你从[教育背景、工作经验、技能特长、项目经历和成果、领导力和管理能力、自我学习和发展能力、沟通和协作能力、岗位匹配度]这八个维度对候选人进行打分,分数范围是0-100,并针对每个维���的分数给出相应的打分理由。
226
+ 教育背景:
227
+ 评价规则:80-100表示教育背景优秀,毕业于985、211大学;60-79表示教育背景良好、毕业于普通重点大学;70分以下表示毕业于普通大学。
228
+ 工作经验:
229
+ 评价规则:80-100表示候选人具有丰富的相关工作经验,曾承担重要职责并取得显著的成绩;60-79表示候选人有一定的工作经验,能够胜任职务,但成绩一般;60分以下表示候选人工作经验较少或表现普通。
230
+ 技能特长:
231
+ 评价规则:80-100表示候选人在相关技能方面突出,掌握了多项技能,具备深厚的专业知识;60-79表示候选人具备一些相关技能,能够熟练运用;60分以下表示候选人技能较少或掌握程度一般。
232
+ 项目经历和成果:
233
+ 评价规则:80-100表示候选人在项目中表现出色,取得了显著的项目成果,具备解决问题和团队合作能力;60-79表示候选人在项目中有一些成绩,能够参与并完成任务;60分以下表示候选人在项目中表现一般或成绩较少。
234
+ 领导力和管理能力:
235
+ 评价规则:80-100表示候选人具备优秀的领导力和管理能力,曾成功承担过领导职责或项目管理职务;60-79表示候选人具备一定的领导力和管理能力,曾有一定的领导经验;60分以下表示候选人领导能力较弱或未有相关经验。
236
+ 自我学习和发展能力:
237
+ 评价规则:80-100表示候选人具有积极主动地学习和扩充知识的意愿和能力,持续学习并不断提升自己;60-79表示候选人有一些学习和发展的意愿和能力,但不够积极主动;60分以下表示候选人学习和发展能力较弱或缺乏积极性。
238
+ 沟通和协作能力:
239
+ 评价规则:80-100表示候选人具备良好的沟通和协作能力,能够与他人有效地进行交流和合作;60-79表示候选人具备一定的沟通和协作能力,能够与他人合作完成任务;60分以下表示候选人沟通和协作能力较弱或简历中描述有限。
240
+ 注意,结果参考下面的JSON字符串,以json格式返回给我,不要返回任何额外信息。
241
+ 返回结果参考:
242
+
243
+ "教育背景": "81",
244
+ "工作经验":"68",
245
+ "技能特长":"69",
246
+ "项目经历和成果":"85",
247
+ "领导力和管理能力":"96",
248
+ "自我学习和发展能力":"100",
249
+ "沟通和协作能力":"56",
250
+ "打分理由":"理性评估"
251
+
252
+ """
253
+ print(prompt)
254
+ return ask_gpt(prompt)
255
+
256
+
257
+ def radar_result_postprocess(res):
258
+ print(res)
259
+ res = extract_json(res)
260
+ json_res = json.loads(res)
261
+ print(json_res)
262
+ score_list = []
263
+ cat_list = []
264
+ for key, value in json_res.items():
265
+ if key != "打分理由":
266
+ cat_list.append(key)
267
+ score_list.append(int(value))
268
+ print(score_list)
269
+ print(cat_list)
270
+ return score_list, cat_list, json_res["打分理由"]
271
+
272
+
273
+ def gene_talent_radar(resume, jd):
274
+ res = gene_ability_score(resume)
275
+ score_list, cat_list, reason = radar_result_postprocess(res)
276
+ return draw_radar_chart(score_list, cat_list), reason
277
+
278
+
279
+ def gene_multi_talent_radar(resume1, resume2):
280
+ res1 = gene_ability_score(resume1)
281
+ res2 = gene_ability_score(resume2)
282
+ temp = []
283
+ score_list, cat_list, reason = radar_result_postprocess(res1)
284
+ score_list2, cat_list2, reason = radar_result_postprocess(res2)
285
+ temp.append(score_list)
286
+ temp.append(score_list2)
287
+ print(temp)
288
+ return draw_multi_radar_chart(temp, cat_list)
289
+
290
+
291
+ # Test Data
292
+ test_jd = '''
293
+ 职位名称:Java开发工程师
294
+
295
+ 工作职责:
296
+ 1. 根据业务需求,参与需求分析、系统设计和架构设计。
297
+ 2. 开发和维护基于Java技术的Web应用程序、服务端组件和工具。
298
+ 3. 编写高质量的可维护、可扩展的代码,并进行单元测试和代码审查。
299
+ 4. 对现有系统进行优化和性能调优,确保系统的高可用性和稳定性。
300
+ 5. 与产品经理、设计师和测试人员紧密合作,确保产品质量和用户体验。
301
+ 6. 持续学习和研究新的技术和开发工具,提出并实施技术创新和改进。
302
+
303
+ 任职要求:
304
+ 1. 精通Java编程语言,熟悉Java相关的开发框架和工具,如Spring、Hibernate等。
305
+ 2. 具备扎实的计算机基础知识,熟悉面向对象设计和设计模式。
306
+ 3. 具备良好的数据结构和算法基础,对系统性能优化有一定的经验。
307
+ 4. 熟悉Web开发相关的技术,如HTML、CSS、JavaScript等。
308
+ 5. 具备良好的沟通能力和团队协作能力,能够与团队成员和其他相关岗位进行有效的沟通和合作。
309
+ 6. 具备良好的问题解决能力和学习能力,能够快速地理解和解决技术问题。
310
+ 7. 具备良好的代码风格和规范意识,注重代码质量和可维护性。
311
+ '''
312
+
313
+ with gr.Blocks(title="HRMaster", theme="soft") as demo:
314
+ gr.Markdown("<center><h1>HRMaster</h1></center>")
315
+ gr.Markdown("<center><h2>HR recruitment professional assistant based on ERNIE Bot</h2></center>")
316
+
317
+ with gr.Tab("简历测试数据生成"):
318
+ with gr.Row():
319
+ targrt_job = gr.Textbox(label="求职目标")
320
+ resume_item_list = gr.Dropdown(
321
+ ["个人信息", "教育背景", "工作经历", "实习经历", "技能专长", "项目经验", "获奖与荣誉", "自我评价"],
322
+ value=["个人信息", "教育背景", "工作经历", "技能专长", "项目经验", "自我评价"], multiselect=True, label="简历维度",
323
+ info="测试简历维度信息"
324
+ )
325
+ test_resume_text = gr.Textbox(label="生成的测试简历信息", show_copy_button=True)
326
+ with gr.Row():
327
+ test_targrt_job_list = ["java开发工程师", "算法工程师", "运维工程师", "飞桨项目运营",
328
+ "大模型应用开发工程师", "法务专员", "财务专员"]
329
+ gr.Examples(test_targrt_job_list, targrt_job,)
330
+ with gr.Row():
331
+ resume_gene_button = gr.Button("简历测试数据生成")
332
+ resume_gene_button.click(generate_test_resume, [targrt_job, resume_item_list], test_resume_text)
333
+
334
+
335
+
336
+ with gr.Tab("岗位JD生成器"):
337
+ with gr.Row():
338
+ with gr.Column():
339
+ jobTitle_input = gr.Textbox(label="岗位名称")
340
+ eduLevel_input = gr.Textbox(label="最低学历要求")
341
+ workYearArr_input = gr.Textbox(label="工作年限要求")
342
+ with gr.Column():
343
+ jd_output_text = gr.Textbox(label="生成的岗位JD")
344
+ jd_button = gr.Button(value="岗位JD生成")
345
+ jd_button.click(generate_jd, [jobTitle_input, eduLevel_input, workYearArr_input], jd_output_text)
346
+ with gr.Row():
347
+ gr.Examples([["java开发工程师", "本科", "三年以上"], ["算法工程师", "研究生", "一年以上"], ["NLP工程师", "研究生", "两年以上"], ["AI工程师", "研究生", "一年以上"], ["法务专员", "本科", "不限"],["产品经理", "本科", "五年以上"]],
348
+ [jobTitle_input, eduLevel_input, workYearArr_input], )
349
+
350
+ with gr.Tab("简历筛选辅助"):
351
+ with gr.Row():
352
+ resume_file = gr.File(label="请上传简历(目前仅支持上传txt格式简历)", file_types=["text"])
353
+ text_output = gr.Textbox(label="简历信息")
354
+ talent_row = gr.Row(visible=False)
355
+ with talent_row:
356
+ resume_text = gr.Textbox(label="人才画像")
357
+ hua_button = gr.Button(value="生成人才画像", )
358
+ hua_button.click(generate_talent_portrait, text_output, resume_text)
359
+
360
+ jd_row = gr.Row(visible=False)
361
+ with jd_row:
362
+ with gr.Column():
363
+ jd = gr.Textbox(label="岗位JD", lines=20)
364
+ gr.Examples([test_jd], [jd])
365
+ with gr.Column():
366
+ # person_job_fit = gr.Textbox(label="人岗匹配度")
367
+ edu_matching = gr.CheckboxGroup(["完全匹配", "较为匹配", "较不匹配", "完全不匹配"], label="教育背景匹配度", info="")
368
+ edu_description = gr.Textbox(label="评估说明",)
369
+ work_exp_matching = gr.CheckboxGroup(["完全匹配", "较为匹配", "较不匹配", "完全不匹配"], label="工作经验匹配度", info="")
370
+ work_exp_description = gr.Textbox(label="评估说明")
371
+ skill_matching = gr.CheckboxGroup(["完全匹配", "较为匹配", "较不匹配", "完全不匹配"], label="技能与能力匹配度", info="")
372
+ skill_description = gr.Textbox(label="评估说明")
373
+ other_matching = gr.CheckboxGroup(["完全匹配", "较为匹配", "较不匹配", "完全不匹配"], label="其他因素匹配度", info="")
374
+ other_description = gr.Textbox(label="评估说明")
375
+ overall_matching = gr.CheckboxGroup(["完全匹配", "较为匹配", "较不匹配", "完全不匹配"], label="整体匹配度", info="")
376
+ overall_description = gr.Textbox(label="评估说明")
377
+ fit_button = gr.Button(value="计算人岗匹配度", )
378
+ fit_button.click(person_job_fit_gene, [text_output, jd],
379
+ [edu_matching, work_exp_matching, skill_matching, other_matching, overall_matching,
380
+ edu_description, work_exp_description, skill_description, other_description,
381
+ overall_description])
382
+
383
+ radar_row = gr.Row(visible=False)
384
+ with radar_row:
385
+ radar_outputs = gr.Plot(label="能力雷达图")
386
+ radar_reasons = gr.Textbox(label="打分理由")
387
+ radar_button = gr.Button(value="生成能力雷达图")
388
+ radar_button.click(gene_talent_radar, [text_output, jd], [radar_outputs, radar_reasons])
389
+ resume_file.change(parse_file, resume_file, [text_output, talent_row, jd_row, radar_row])
390
+ gr.Examples([os.path.join(os.path.dirname(__file__), "test_resume.txt")], resume_file, [text_output, talent_row, jd_row, radar_row],fn=parse_file,)
391
+
392
+ # with gr.Tab("候选人比较"):
393
+ # with gr.Row():
394
+ # resume_file_1 = gr.File(label="请上传简历(目前仅支持上传txt格式简历)", file_types=["text"])
395
+ # resume_file_1_text = gr.Textbox(label="简历信息")
396
+ # with gr.Row():
397
+ # resume_file_2 = gr.File(label="请上传简历(目前仅支持上传txt格式简历)", file_types=["text"])
398
+ # resume_file_2_text = gr.Textbox(label="简历信息")
399
+ # with gr.Row():
400
+ # compare_radar_outputs = gr.Plot(label="能力对比雷达图")
401
+ # with gr.Row():
402
+ # compare_button = gr.Button(value="生成能力对比雷达图")
403
+ # resume_file_1.change(pure_parse_file, resume_file_1, [resume_file_1_text])
404
+ # resume_file_2.change(pure_parse_file, resume_file_2, [resume_file_2_text])
405
+ # compare_button.click(gene_multi_talent_radar,[resume_file_1_text,resume_file_2_text],compare_radar_outputs)
406
+
407
+ with gr.Tab("面试过程辅助"):
408
+ gr.Markdown("面试问题生成")
409
+ # interview_row = gr.Row(visible=True)
410
+ # with interview_row:
411
+ with gr.Row():
412
+ resume_file_interview = gr.File(label="请上传简历(目前仅支持上传txt格式简历)", file_types=["text"])
413
+ text_resume_interview = gr.Textbox(label="简历信息")
414
+ with gr.Row():
415
+ gr.Examples([os.path.join(os.path.dirname(__file__), "test_resume.txt")], resume_file_interview,
416
+ [text_resume_interview], fn=pure_parse_file, )
417
+ with gr.Row():
418
+ interview_jd = gr.TextArea(label="请输入JD岗位")
419
+ gr.Examples([test_jd], [interview_jd])
420
+ with gr.Row():
421
+ interview_questions_text = gr.Textbox(label="面试问题", show_copy_button=True)
422
+ # interview_questions_text = gr.Checkboxgroup(label="面试问题", show_copy_button=True)
423
+ interview_questions_generator_button = gr.Button(value="面试问题生成")
424
+ resume_file_interview.change(pure_parse_file, resume_file_interview,[text_resume_interview,])
425
+ interview_questions_generator_button.click(generate_interview_questions_new, [text_resume_interview, interview_jd],
426
+ [interview_questions_text])
427
+ gr.Markdown("面试评价生成")
428
+ with gr.Row():
429
+ with gr.Column():
430
+ commu_skills = gr.Radio(["强", "中", "弱"], label="沟通能力",
431
+ info="评估候选人的口头表达能力、听取并理解问题的能力、回答问题的清晰度和逻辑性等。")
432
+ pro_skills = gr.Radio(["强", "中", "弱"], label="专业知识", info="评估候选人在岗位所需的专业知识的掌握程度。")
433
+ tech_skills = gr.Radio(["强", "中", "弱"], label="技术能力", info="评估候选人在岗位所需的专业技能方面的掌握程度。")
434
+ solve_skills = gr.Radio(["强", "中", "弱"], label="解决问题的能力",
435
+ info="评估候选人在面对问题时的分析能力、创新思维、解决问题的方法和结果。")
436
+ team_skills = gr.Radio(["强", "中", "弱"], label="团队合作能力",
437
+ info="评估候选人在与他人合作、协调和沟通方面的能力,包括与面试官的互动、参与小组讨论等。")
438
+ pressure_resistance = gr.Radio(["强", "中", "弱"], label="抗压能力",
439
+ info="评估候选人在应对压力、处理复杂情境以及适应变化上的能力。")
440
+ if_ok = gr.Radio(["是", "否"], label="是否录用", info="最终结果")
441
+
442
+ with gr.Column():
443
+ interview_feedback_text = gr.Textbox(label="面试评价", show_copy_button=True)
444
+ result_button = gr.Button(value="面试评价生成")
445
+ result_button.click(generate_interview_feedback,
446
+ inputs=[commu_skills, pro_skills, tech_skills, solve_skills, team_skills,
447
+ pressure_resistance, if_ok],
448
+ outputs=interview_feedback_text)
449
+ gr.Examples([["强", "中", "弱", "强", "中", "弱", "是"], ["弱", "中", "弱", "强", "中", "弱", "否"]],
450
+ [commu_skills, pro_skills, tech_skills, solve_skills, team_skills,
451
+ pressure_resistance, if_ok],
452
+ )
453
+
454
+
455
+ with gr.Tab("HRChat"):
456
+ with gr.Column():
457
+ chatbot = gr.Chatbot(label="HRChat")
458
+ state = gr.State([])
459
+ clear = gr.Button("Clear")
460
+ txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
461
+ txt.submit(predict, [txt, state], [chatbot, state])
462
+ clear.click(lambda: None, None, chatbot, queue=False)
463
+
464
+ demo.launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ plotly
test_resume.txt ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 个人信息
2
+ - 姓名:张三
3
+ - 性别:男
4
+ - 年龄:28岁
5
+ - 手机号码:13812345678
6
+ - 邮箱:zhangsan123@163.com
7
+
8
+ ## 教育背景
9
+ - 学校:清华大学
10
+ - 专业:计算机科学与技术
11
+ - 学历:本科
12
+ - 时间:2012年-2016年
13
+
14
+ ## 工作经历
15
+ - 公司名称:阿里巴巴
16
+ - 职位:Java开发工程师
17
+ - 时间:2016年-2020年
18
+ - 工作内容:负责公司核心业务系统的开发和维护,使用Java语言开发,熟练掌握Spring、MyBatis等框架,熟悉MySQL数据库。
19
+
20
+ ## 技能专长
21
+ - 熟练掌握Java语言,熟悉常用的开发框架和工具
22
+ - 熟悉MySQL数据库,具备数据库设计和优化经验
23
+ - 熟悉Linux操作系统,能够熟练使用常用命令和工具
24
+ - 具备良好的编码习惯和文档编写能力
25
+
26
+ ## 项目经验
27
+ ### 项目一:电商平台
28
+ - 时间:2018年-2019年
29
+ - 项目描述:该项目是一个B2C电商平台,主要功能包括用户注册、商品浏览、购物车管理、订单管理等。
30
+ - 职责:负责购物车模块和订单模块的开发,实现了购物车的增删改查功能,以及订单的创建和支付功能。
31
+ - 技术栈:Java、Spring、MyBatis、MySQL
32
+
33
+ ### 项目二:物流管理系统
34
+ - 时间:2016年-2017年
35
+ - 项目描述:该项目是一个物流管理系统,主要功能包括订单管理、运输管理、库存管理等。
36
+ - 职责:负责订单管理模块和运输管理模块的开发,实现了订单的创建和查询功能,以及运输状态的跟踪和更新功能。
37
+ - 技术栈:Java、Spring、MyBatis、MySQL
38
+
39
+ ## 自我评价
40
+ 本人具备扎实的Java编程能力和较强的团队协作能力,能够快速适应新的工作环境和技术栈。同时,本人具备良好的沟通能力和学习能力,能够与不同部门的同事进行良好的沟通和协作,不断提升自己的技术水平和工作能力。
test_resume_算法.txt ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 个人信息
2
+ * 姓名:张三
3
+ * 邮箱:zhangsan@email.com
4
+ * 电话:123-4567-8901
5
+ * 地址:北京市海淀区某街道某号
6
+ * 性别:男
7
+ * 出生年月:1995年1月1日
8
+ * 毕业院校:清华大学
9
+ * 专业:计算机科学与技术
10
+ * 求职城市:北京
11
+ * 求职意向:算法工程师
12
+
13
+ ## 教育背景
14
+ * 学历:硕士
15
+ * 学校名称:清华大学
16
+ * 专业:计算机科学与技术
17
+ * 毕业时间:2017年6月
18
+ * GPA:3.9/4.0
19
+ * 学术成果:发表论文2篇,其中1篇为CCF B类论文
20
+
21
+ ## 工作经历
22
+ * 公司名称:百度公司
23
+ * 职位:算法工程师
24
+ * 工作描述:负责自然语言处理算法的研究与实现,参与了公司某项重要项目的开发过程,为项目提供了高质量的算法支持。在此期间,参与了中文分词、文本分类等项目的开发工作,并取得了良好的效果。
25
+ * 工作时间:2017年7月-2020年3月
26
+ * 公司地址:北京市海淀区
27
+ * 离职原因:个人发展需要,寻求更大的发展空间
28
+
29
+ ## 技能专长
30
+ * 编程语言:Python、C++、Java
31
+ * 工具:TensorFlow、PyTorch、Keras、Git、Jupyter Notebook
32
+ * 数据库:MySQL、MongoDB
33
+ * 其他技能:机器学习、深度学习、自然语言处理、数据挖掘、数据可视化等
34
+
35
+ ## 项目经验
36
+ * 项目名称:中文分词系统开发与优化
37
+ * 项目描述:负责中文分词算法的研究与实现,采用基于词典的方法,对分词结果进行优化,提高了分词准确率。在项目过程中,使用了Python和Keras等工具,实现了高效的模型训练和部署。最终,该分词系统在某项评测中取得了国内领先的成绩。
38
+ * 项目时间:2018年9月-2019年3月
39
+ * 项目地点:北京市海淀区
40
+ * 项目团队:百度公司团队,共5人
41
+
42
+ ## 自我评价
43
+ 具有扎实的计算机基础知识,熟悉算法和数据结构,具备较强的编程能力。对机器学习和深度学习有深入的理解和实践经验,具备自然语言处理、数据挖掘等相关技能。具备较强的团队协作能力和独立思考能力,能够在复杂环境下高效完成任务。希望能够加入一个有挑战性的团队,共同创造卓越的成果。
utils.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import plotly.graph_objects as go
3
+
4
+
5
+ def draw_radar_chart(data, categories):
6
+ arr = np.array(data, dtype='int')
7
+ fig = go.Figure()
8
+ fig.add_trace(go.Scatterpolar(
9
+ r=arr,
10
+ theta=categories,
11
+ fill='toself'
12
+ ))
13
+ fig.update_layout(
14
+ polar=dict(
15
+ radialaxis=dict(
16
+ visible=True,
17
+ range=(0, 100)
18
+ )),
19
+ showlegend=False
20
+ )
21
+ return fig
22
+
23
+
24
+ def draw_multi_radar_chart(data, categories):
25
+ # arr = np.array(data, dtype='int')
26
+ # categories = ['A', 'B', 'C', 'D', 'E']
27
+
28
+ fig = go.Figure()
29
+ for arr in data:
30
+ fig.add_trace(go.Scatterpolar(
31
+ r=arr,
32
+ theta=categories,
33
+ fill='toself'
34
+ ))
35
+
36
+ fig.update_layout(
37
+ polar=dict(
38
+ radialaxis=dict(
39
+ visible=True,
40
+ range=(0, 100)
41
+ )),
42
+ showlegend=False
43
+ )
44
+
45
+ return fig
46
+
47
+
48
+ def extract_json(s):
49
+ import re
50
+
51
+ # 假设这是你的字符串
52
+ # s = '```json\n{ "key": "value" }\n```'
53
+
54
+ # 使用正则表达式匹配```json和```之间的内容
55
+ match = re.search(r'```json\s*(.*?)```', s, re.DOTALL)
56
+
57
+ # 如果找到了匹配的内容,打印出来
58
+ if match:
59
+ return match.group(1)
60
+
61
+ if __name__ == '__main__':
62
+ arr = np.array([[80, 90,90,90,],[80, 90,90,90,]],dtype='int')
63
+ categories = ['A', 'B', 'C', 'D']
64
+ print(draw_multi_radar_chart(arr,categories))
65
+ s = '''
66
+ 根据您的要求,以下是根据候选人的简历从[教育背景、工作经验、技能特长、项目经历和成果、领导力和管理能力、自我学习和发展能力、沟通和协作能力、岗位匹配度]这八个维度进行打分,并给出相应的打分理由:
67
+ ```json
68
+ {
69
+ "教育背景": {
70
+ "评价": "良好",
71
+ "打分理由": "候选人毕业于清华大学,属于985、211大学,符合优秀教育背景的要求"
72
+ },
73
+ "工作经验": {
74
+ "评价": "一般",
75
+ "打分理由": "候选人在百度公司担任算法工程师,但工作时间较短,只有两年多的工作经验,表现一般"
76
+ },
77
+ "技能特长": {
78
+ "评价": "优秀",
79
+ "打分理由": "候选人掌握多种编程语言和工具,具备扎实的计算机基础知识,掌握算法和数据结构,具备较强的编程能力,掌握机器学习和深度学习的相关技能,具备自然语言处理、数据挖掘等相关技能"
80
+ },
81
+ "项目经历和成果": {
82
+ "评价": "优秀",
83
+ "打分理由": "候选人参与了中文分词、文本分类等项目的开发工作,并取得了良好的效果,具备解决问题和团队合作能力,取得了显著的项目成果"
84
+ },
85
+ "领导力和管理能力": {
86
+ "评价": "优秀",
87
+ "打分理由": "候选人在百度公司担任算法工程师期间,负责自然语言处理算法的研究与实现,参与了公司某项重要项目的开发过程,为项目提供了高质量的算法支持,具备优秀的领导力和管理能力,曾成功承担过领导职责或项目管理职务"
88
+ },
89
+ "自我学习和发展能力": {
90
+ "评价": "100",
91
+ "打分理由": "候选人具有较强的学习意愿和能力,具备积极主动地学习和扩充知识的意愿和能力,持续学习并不断提升自己"
92
+ },
93
+ "沟通和协作能力": {
94
+ "评价": "一般",
95
+ "打分理由": "候选人在简历中提到具备一些沟通和协作能力,但简历中描述有限,能够与他人有效地进行交流和合作,但不够积极主动"
96
+ },
97
+ "岗位匹配度": "高"
98
+ }
99
+ ```
100
+ '''
101
+ print(extract_json(s))