Spaces:
Sleeping
Sleeping
xingxf03
commited on
Commit
•
1563988
1
Parent(s):
3f2e44b
add full examples
Browse files
app.py
CHANGED
@@ -5,27 +5,29 @@ from pydantic import BaseModel
|
|
5 |
import openai
|
6 |
import os
|
7 |
|
8 |
-
|
9 |
openai.api_base = "https://api.wzunjh.top/v1"
|
10 |
|
|
|
11 |
def ask_gpt(prompt):
|
12 |
response = openai.ChatCompletion.create(
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
)
|
18 |
print(response)
|
19 |
return response.choices[0].message.content.strip()
|
20 |
|
|
|
21 |
def ask_gpt_with_history(history):
|
22 |
response = openai.ChatCompletion.create(
|
23 |
-
|
24 |
-
|
25 |
)
|
26 |
print(response)
|
27 |
return response.choices[0].message.content.strip()
|
28 |
|
|
|
29 |
async def predict(input, history):
|
30 |
"""
|
31 |
Predict the response of the chatbot and complete a running list of chat history.
|
@@ -173,20 +175,22 @@ with gr.Blocks(title="HRMaster", theme="soft") as demo:
|
|
173 |
eduLevel_input = gr.Textbox(label="最低学历要求")
|
174 |
workYearArr_input = gr.Textbox(label="工作年限要求")
|
175 |
with gr.Column():
|
176 |
-
jd_output_text = gr.
|
177 |
jd_button = gr.Button(value="岗位JD生成")
|
178 |
jd_button.click(generate_jd, [jobTitle_input, eduLevel_input, workYearArr_input], jd_output_text)
|
179 |
-
|
180 |
-
|
|
|
181 |
|
|
|
182 |
|
183 |
with gr.Tab("简历筛选辅助"):
|
184 |
with gr.Row():
|
185 |
resume_file = gr.File(label="请上传简历(目前仅支持上传txt格式简历)", file_types=["text"])
|
186 |
-
text_output = gr.
|
187 |
talent_row = gr.Row(visible=False)
|
188 |
with talent_row:
|
189 |
-
resume_text = gr.
|
190 |
hua_button = gr.Button(value="生成人才画像", )
|
191 |
hua_button.click(generate_talent_portrait, text_output, resume_text)
|
192 |
|
@@ -196,16 +200,34 @@ with gr.Blocks(title="HRMaster", theme="soft") as demo:
|
|
196 |
person_job_fit = gr.Textbox(label="人岗匹配度")
|
197 |
fit_button = gr.Button(value="计算人岗匹配度", )
|
198 |
fit_button.click(person_job_fit_gene, [text_output, jd], person_job_fit)
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
resume_file.change(parse_file, resume_file, [text_output, talent_row, jd_row, radar_row])
|
207 |
-
# 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,cache_examples=True,)
|
208 |
-
|
209 |
|
210 |
with gr.Tab("面试过程辅助"):
|
211 |
interview_row = gr.Row(visible=True)
|
@@ -214,7 +236,8 @@ with gr.Blocks(title="HRMaster", theme="soft") as demo:
|
|
214 |
interview_questions_generator_button = gr.Button(value="面试问题生成")
|
215 |
copy_interview_questions_button = gr.Button(value="拷贝面试问题", visible=False)
|
216 |
interview_questions_generator_button.click(generate_interview_questions_new, [text_output, jd],
|
217 |
-
[interview_questions_text,
|
|
|
218 |
|
219 |
with gr.Tab("测试数据生成"):
|
220 |
with gr.Row():
|
@@ -224,28 +247,42 @@ with gr.Blocks(title="HRMaster", theme="soft") as demo:
|
|
224 |
value=["个人信息", "教育背景", "工作经历", "技能专长", "项目经验", "自我评价"], multiselect=True, label="简历维度",
|
225 |
info="测试简历维度信息"
|
226 |
)
|
227 |
-
test_resume_text = gr.
|
228 |
resume_gene_button = gr.Button("测试数据生成")
|
229 |
resume_gene_button.click(generate_test_resume, [targrt_job, resume_item_list], test_resume_text)
|
|
|
|
|
|
|
|
|
|
|
230 |
|
231 |
with gr.Tab("面试评价生成器"):
|
232 |
with gr.Row():
|
233 |
with gr.Column():
|
234 |
-
commu_skills = gr.Radio(["强", "中", "弱"], label="沟通能力",
|
|
|
235 |
pro_skills = gr.Radio(["强", "中", "弱"], label="专业知识", info="评估候选人在岗位所需的专业知识的掌握程度。")
|
236 |
tech_skills = gr.Radio(["强", "中", "弱"], label="技术能力", info="评估候选人在岗位所需的专业技能方面的掌握程度。")
|
237 |
-
solve_skills = gr.Radio(["强", "中", "弱"], label="解决问题的能力",
|
|
|
238 |
team_skills = gr.Radio(["强", "中", "弱"], label="团队合作能力",
|
239 |
info="评估候选人在与他人合作、协调和沟通方面的能力,包括与面试官的互动、参与小组讨论等。")
|
240 |
-
pressure_resistance = gr.Radio(["强", "中", "弱"], label="抗压能力",
|
|
|
241 |
if_ok = gr.Radio(["是", "否"], label="是否录用", info="最终结果")
|
|
|
242 |
with gr.Column():
|
243 |
-
interview_feedback_text = gr.
|
244 |
result_button = gr.Button(value="面试评价生成")
|
245 |
result_button.click(generate_interview_feedback,
|
246 |
inputs=[commu_skills, pro_skills, tech_skills, solve_skills, team_skills,
|
247 |
pressure_resistance, if_ok],
|
248 |
outputs=interview_feedback_text)
|
|
|
|
|
|
|
|
|
|
|
249 |
with gr.Tab("HRChat"):
|
250 |
with gr.Column():
|
251 |
chatbot = gr.Chatbot(label="HRChat")
|
@@ -254,8 +291,8 @@ with gr.Blocks(title="HRMaster", theme="soft") as demo:
|
|
254 |
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
|
255 |
txt.submit(predict, [txt, state], [chatbot, state])
|
256 |
clear.click(lambda: None, None, chatbot, queue=False)
|
257 |
-
|
258 |
-
|
259 |
|
260 |
-
if __name__ == "__main__":
|
261 |
-
|
|
|
5 |
import openai
|
6 |
import os
|
7 |
|
|
|
8 |
openai.api_base = "https://api.wzunjh.top/v1"
|
9 |
|
10 |
+
|
11 |
def ask_gpt(prompt):
|
12 |
response = openai.ChatCompletion.create(
|
13 |
+
model="gpt-3.5-turbo", # here we use `gpt-3.5-turbo` model, while Stanford-Alpaca uses `text-davinci-003`
|
14 |
+
messages=[
|
15 |
+
{"role": "user", "content": prompt},
|
16 |
+
]
|
17 |
)
|
18 |
print(response)
|
19 |
return response.choices[0].message.content.strip()
|
20 |
|
21 |
+
|
22 |
def ask_gpt_with_history(history):
|
23 |
response = openai.ChatCompletion.create(
|
24 |
+
model="gpt-3.5-turbo", # here we use `gpt-3.5-turbo` model, while Stanford-Alpaca uses `text-davinci-003`
|
25 |
+
messages=history
|
26 |
)
|
27 |
print(response)
|
28 |
return response.choices[0].message.content.strip()
|
29 |
|
30 |
+
|
31 |
async def predict(input, history):
|
32 |
"""
|
33 |
Predict the response of the chatbot and complete a running list of chat history.
|
|
|
175 |
eduLevel_input = gr.Textbox(label="最低学历要求")
|
176 |
workYearArr_input = gr.Textbox(label="工作年限要求")
|
177 |
with gr.Column():
|
178 |
+
jd_output_text = gr.Textbox(label="生成的岗位JD")
|
179 |
jd_button = gr.Button(value="岗位JD生成")
|
180 |
jd_button.click(generate_jd, [jobTitle_input, eduLevel_input, workYearArr_input], jd_output_text)
|
181 |
+
with gr.Column():
|
182 |
+
gr.Examples([["java开发工程师", "本科", "三年以上"], ["算法工程师", "研究生", "一年以上"]],
|
183 |
+
[jobTitle_input, eduLevel_input, workYearArr_input], [jd_output_text], fn=generate_jd,
|
184 |
|
185 |
+
)
|
186 |
|
187 |
with gr.Tab("简历筛选辅助"):
|
188 |
with gr.Row():
|
189 |
resume_file = gr.File(label="请上传简历(目前仅支持上传txt格式简历)", file_types=["text"])
|
190 |
+
text_output = gr.Textbox(label="简历信息")
|
191 |
talent_row = gr.Row(visible=False)
|
192 |
with talent_row:
|
193 |
+
resume_text = gr.Textbox(label="人才画像")
|
194 |
hua_button = gr.Button(value="生成人才画像", )
|
195 |
hua_button.click(generate_talent_portrait, text_output, resume_text)
|
196 |
|
|
|
200 |
person_job_fit = gr.Textbox(label="人岗匹配度")
|
201 |
fit_button = gr.Button(value="计算人岗匹配度", )
|
202 |
fit_button.click(person_job_fit_gene, [text_output, jd], person_job_fit)
|
203 |
+
test_jd = '''
|
204 |
+
职位名称:Java开发工程师工作职责:
|
205 |
+
1. 根据业务需求,参与需求分析、系统设计和架构设计。
|
206 |
+
2. 开发和维护基于Java技术的Web应用程序、服务端组件和工具。
|
207 |
+
3. 编写高质量的可维护、可扩展的代码,并进行单元测试和代码审查。
|
208 |
+
4. 对现有系统进行优化和性能调优,确保系统的高可用性和稳定性。
|
209 |
+
5. 与产品经理、设计师和测试人员紧密合作,确保产品质量和用户体验。
|
210 |
+
6. 持续学习和研究新的技术和开发工具,提出并实施技术创新和改进。
|
211 |
+
|
212 |
+
任职要求:
|
213 |
+
1. 精通Java编程语言,熟悉Java相关的开发框架和工具,如Spring、Hibernate等。
|
214 |
+
2. 具备扎实的计算机基础知识,熟悉面向对象设计和设计模式。
|
215 |
+
3. 具备良好的数据结构和算法基础,对系统性能优化有一定的经验。
|
216 |
+
4. 熟悉Web开发相关的技术,如HTML、CSS、JavaScript等。
|
217 |
+
5. 具备良好的沟通能力和团队协作能力,能够与团队成员和其他相关岗位进行有效的沟通和合作。
|
218 |
+
6. 具备良好的问题解决能力和学习能力,能够快速地理解和解决技术问题。
|
219 |
+
7. 具备良好的代码风格和规范意识,注重代码质量和可维护性。
|
220 |
+
'''
|
221 |
+
gr.Examples([test_jd], [jd], [person_job_fit], fn=person_job_fit_gene, )
|
222 |
+
radar_row = gr.Row(visible=False)
|
223 |
+
with radar_row:
|
224 |
+
radar_outputs = gr.Plot(label="能力雷达图")
|
225 |
+
radar_reasons = gr.Textbox(label="打分理由")
|
226 |
+
radar_button = gr.Button(value="生成能力雷达图")
|
227 |
+
radar_button.click(gene_talent_radar, [text_output, jd], [radar_outputs, radar_reasons])
|
228 |
+
gr.Examples([os.path.join(os.path.dirname(__file__), "test_resume.txt")], resume_file,
|
229 |
+
[text_output, talent_row, jd_row, radar_row], fn=parse_file, cache_examples=True)
|
230 |
resume_file.change(parse_file, resume_file, [text_output, talent_row, jd_row, radar_row])
|
|
|
|
|
231 |
|
232 |
with gr.Tab("面试过程辅助"):
|
233 |
interview_row = gr.Row(visible=True)
|
|
|
236 |
interview_questions_generator_button = gr.Button(value="面试问题生成")
|
237 |
copy_interview_questions_button = gr.Button(value="拷贝面试问题", visible=False)
|
238 |
interview_questions_generator_button.click(generate_interview_questions_new, [text_output, jd],
|
239 |
+
[interview_questions_text,
|
240 |
+
copy_interview_questions_button])
|
241 |
|
242 |
with gr.Tab("测试数据生成"):
|
243 |
with gr.Row():
|
|
|
247 |
value=["个人信息", "教育背景", "工作经历", "技能专长", "项目经验", "自我评价"], multiselect=True, label="简历维度",
|
248 |
info="测试简历维度信息"
|
249 |
)
|
250 |
+
test_resume_text = gr.Textbox(label="生成的测试简历信息")
|
251 |
resume_gene_button = gr.Button("测试数据生成")
|
252 |
resume_gene_button.click(generate_test_resume, [targrt_job, resume_item_list], test_resume_text)
|
253 |
+
test_targrt_job = "java开发工程师"
|
254 |
+
test_resume_item_list = ["个人信息", "教育背景", "工作经历", "实习经历", "技能专长", "项目经验", "获奖与荣誉", "自我评价"]
|
255 |
+
gr.Examples([[test_targrt_job, test_resume_item_list]], targrt_job, resume_item_list,
|
256 |
+
fn=generate_test_resume,
|
257 |
+
)
|
258 |
|
259 |
with gr.Tab("面试评价生成器"):
|
260 |
with gr.Row():
|
261 |
with gr.Column():
|
262 |
+
commu_skills = gr.Radio(["强", "中", "弱"], label="沟通能力",
|
263 |
+
info="评估候选人的口头表达能力、听取并理解问题的能力、回答问题的清晰度和逻辑性等。")
|
264 |
pro_skills = gr.Radio(["强", "中", "弱"], label="专业知识", info="评估候选人在岗位所需的专业知识的掌握程度。")
|
265 |
tech_skills = gr.Radio(["强", "中", "弱"], label="技术能力", info="评估候选人在岗位所需的专业技能方面的掌握程度。")
|
266 |
+
solve_skills = gr.Radio(["强", "中", "弱"], label="解决问题的能力",
|
267 |
+
info="评估候选人在面对问题时的分析能力、创新思维、解决问题的方法和结果。")
|
268 |
team_skills = gr.Radio(["强", "中", "弱"], label="团队合作能力",
|
269 |
info="评估候选人在与他人合作、协调和沟通方面的能力,包括与面试官的互动、参与小组讨论等。")
|
270 |
+
pressure_resistance = gr.Radio(["强", "中", "弱"], label="抗压能力",
|
271 |
+
info="评估候选人在应对压力、处理复杂情境以及适应变化上的能力。")
|
272 |
if_ok = gr.Radio(["是", "否"], label="是否录用", info="最终结果")
|
273 |
+
|
274 |
with gr.Column():
|
275 |
+
interview_feedback_text = gr.Textbox(label="面试评价")
|
276 |
result_button = gr.Button(value="面试评价生成")
|
277 |
result_button.click(generate_interview_feedback,
|
278 |
inputs=[commu_skills, pro_skills, tech_skills, solve_skills, team_skills,
|
279 |
pressure_resistance, if_ok],
|
280 |
outputs=interview_feedback_text)
|
281 |
+
gr.Examples([["强", "中", "弱", "强", "中", "弱", "是"]],
|
282 |
+
[commu_skills, pro_skills, tech_skills, solve_skills, team_skills,
|
283 |
+
pressure_resistance, if_ok], interview_feedback_text,
|
284 |
+
fn=generate_interview_feedback,
|
285 |
+
)
|
286 |
with gr.Tab("HRChat"):
|
287 |
with gr.Column():
|
288 |
chatbot = gr.Chatbot(label="HRChat")
|
|
|
291 |
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
|
292 |
txt.submit(predict, [txt, state], [chatbot, state])
|
293 |
clear.click(lambda: None, None, chatbot, queue=False)
|
294 |
+
# with gr.Accordion("Open for More!"):
|
295 |
+
# gr.Markdown("Look at me...")
|
296 |
|
297 |
+
if __name__ == "__main__":
|
298 |
+
demo.launch()
|