Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import PyPDF2
|
|
| 4 |
import docx
|
| 5 |
from docx import Document
|
| 6 |
import os
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
|
|
@@ -23,9 +25,9 @@ messages = []
|
|
| 23 |
|
| 24 |
latest_resume_text = ""
|
| 25 |
desired_position = ""
|
| 26 |
-
default_text_1 = "
|
| 27 |
|
| 28 |
-
default_text_2 = "
|
| 29 |
|
| 30 |
default_text_3 = "请帮我阅读候选人简历并总结出以下几个部分。第一个板块是“个人信息”,请总结出此后选人的姓名,性别,工作经验(多少年),最高学历,毕业院校,专业,和毕业时间。第二个部分是此候选人的本人评价,放进一个自然段里。第三个部分是具体得工作经历。第四个部分是做过的项目经验。请根据你对于这位候选人简历的最细致的阅读排出以上几个部分。每个部分由自己的标题:五个标题为 个人信息,本人评价,工作经历,和项目经验。请把每一个小项写得细致一点,并且用数字排序!"
|
| 31 |
|
|
@@ -240,7 +242,12 @@ def generate_resume_document(latest_resume_text):
|
|
| 240 |
doc.save(word_filename)
|
| 241 |
return word_filename
|
| 242 |
|
| 243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
|
| 246 |
|
|
@@ -279,6 +286,7 @@ def CustomChatGPT(user_input, uploaded_file):
|
|
| 279 |
|
| 280 |
if "请帮我阅读候选人简历" in user_input:
|
| 281 |
word_filename = generate_resume_document(latest_resume_text)
|
|
|
|
| 282 |
ChatGPT_reply = "Resume generated successfully. Please download the file using the link below."
|
| 283 |
messages = []
|
| 284 |
else:
|
|
@@ -286,10 +294,14 @@ def CustomChatGPT(user_input, uploaded_file):
|
|
| 286 |
doc.add_paragraph(ChatGPT_reply)
|
| 287 |
word_filename = "generated_response.docx"
|
| 288 |
doc.save(word_filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
# reset the messages to start a new conversation
|
| 290 |
messages = []
|
| 291 |
|
| 292 |
-
return ChatGPT_reply, word_filename
|
| 293 |
|
| 294 |
|
| 295 |
|
|
@@ -330,7 +342,7 @@ def main():
|
|
| 330 |
"""
|
| 331 |
|
| 332 |
with gr.Blocks(css=custom_css) as demo:
|
| 333 |
-
gr.Markdown("#
|
| 334 |
|
| 335 |
with gr.Row():
|
| 336 |
with gr.Column():
|
|
@@ -338,8 +350,8 @@ def main():
|
|
| 338 |
file_input = gr.File(file_count="multiple", label="Upload Resume")
|
| 339 |
|
| 340 |
with gr.Row():
|
| 341 |
-
btn1 = gr.Button("
|
| 342 |
-
btn2 = gr.Button("
|
| 343 |
btn3 = gr.Button("简历生成", elem_classes=["custom-button"])
|
| 344 |
|
| 345 |
|
|
@@ -349,26 +361,27 @@ def main():
|
|
| 349 |
|
| 350 |
|
| 351 |
with gr.Row():
|
| 352 |
-
submit_btn = gr.Button("
|
| 353 |
-
clear_btn = gr.Button("
|
| 354 |
clear_btn.click(fn=clear_inputs, inputs=[], outputs=[])
|
| 355 |
|
| 356 |
with gr.Column():
|
| 357 |
with gr.Row():
|
| 358 |
-
output_text = gr.Textbox(label="ChatGPT
|
| 359 |
with gr.Row():
|
| 360 |
-
output_word = gr.File(label="
|
| 361 |
# output_pdf = gr.File(label="Download PDF File")
|
|
|
|
| 362 |
|
| 363 |
-
submit_btn.click(fn=CustomChatGPT, inputs=[text_input, file_input], outputs=[output_text, output_word])
|
| 364 |
|
| 365 |
with gr.Row():
|
| 366 |
log_text = gr.Textbox(label="Log Content", interactive=True, lines=1)
|
| 367 |
|
| 368 |
with gr.Row():
|
| 369 |
-
view_log_button = gr.Button("
|
| 370 |
-
download_log_button = gr.Button("
|
| 371 |
-
clear_log_button = gr.Button("
|
| 372 |
|
| 373 |
view_log_button.click(fn=read_log_file, inputs=[], outputs=log_text)
|
| 374 |
download_log_button.click(fn=get_log_file, inputs=[], outputs=[])
|
|
@@ -379,9 +392,4 @@ def main():
|
|
| 379 |
|
| 380 |
|
| 381 |
if __name__ == "__main__":
|
| 382 |
-
main()
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
|
|
|
| 4 |
import docx
|
| 5 |
from docx import Document
|
| 6 |
import os
|
| 7 |
+
from docx2pdf import convert
|
| 8 |
+
|
| 9 |
|
| 10 |
|
| 11 |
|
|
|
|
| 25 |
|
| 26 |
latest_resume_text = ""
|
| 27 |
desired_position = ""
|
| 28 |
+
default_text_1 = "请帮我总结我上传的简历"
|
| 29 |
|
| 30 |
+
default_text_2 = "请帮我把我上传的简历进行脱敏处理。"
|
| 31 |
|
| 32 |
default_text_3 = "请帮我阅读候选人简历并总结出以下几个部分。第一个板块是“个人信息”,请总结出此后选人的姓名,性别,工作经验(多少年),最高学历,毕业院校,专业,和毕业时间。第二个部分是此候选人的本人评价,放进一个自然段里。第三个部分是具体得工作经历。第四个部分是做过的项目经验。请根据你对于这位候选人简历的最细致的阅读排出以上几个部分。每个部分由自己的标题:五个标题为 个人信息,本人评价,工作经历,和项目经验。请把每一个小项写得细致一点,并且用数字排序!"
|
| 33 |
|
|
|
|
| 242 |
doc.save(word_filename)
|
| 243 |
return word_filename
|
| 244 |
|
| 245 |
+
# create a function that automatically convert a docx file to a pdf file
|
| 246 |
+
def convert_to_pdf(word_filename):
|
| 247 |
+
pdf_filename = word_filename.replace(".docx", ".pdf")
|
| 248 |
+
doc = docx.Document(word_filename)
|
| 249 |
+
doc.save(pdf_filename)
|
| 250 |
+
return pdf_filename
|
| 251 |
|
| 252 |
|
| 253 |
|
|
|
|
| 286 |
|
| 287 |
if "请帮我阅读候选人简历" in user_input:
|
| 288 |
word_filename = generate_resume_document(latest_resume_text)
|
| 289 |
+
pdf_filename = convert_to_pdf(word_filename)
|
| 290 |
ChatGPT_reply = "Resume generated successfully. Please download the file using the link below."
|
| 291 |
messages = []
|
| 292 |
else:
|
|
|
|
| 294 |
doc.add_paragraph(ChatGPT_reply)
|
| 295 |
word_filename = "generated_response.docx"
|
| 296 |
doc.save(word_filename)
|
| 297 |
+
# pdf_filename = convert_to_pdf(word_filename)
|
| 298 |
+
|
| 299 |
+
convert(word_filename, pdf_filename)
|
| 300 |
+
|
| 301 |
# reset the messages to start a new conversation
|
| 302 |
messages = []
|
| 303 |
|
| 304 |
+
return ChatGPT_reply, word_filename, pdf_filename
|
| 305 |
|
| 306 |
|
| 307 |
|
|
|
|
| 342 |
"""
|
| 343 |
|
| 344 |
with gr.Blocks(css=custom_css) as demo:
|
| 345 |
+
gr.Markdown("# 简历分析系统", elem_classes=["centered-title"])
|
| 346 |
|
| 347 |
with gr.Row():
|
| 348 |
with gr.Column():
|
|
|
|
| 350 |
file_input = gr.File(file_count="multiple", label="Upload Resume")
|
| 351 |
|
| 352 |
with gr.Row():
|
| 353 |
+
btn1 = gr.Button("总结简历", elem_classes=["custom-button"])
|
| 354 |
+
btn2 = gr.Button("脱敏处理", elem_classes=["custom-button"])
|
| 355 |
btn3 = gr.Button("简历生成", elem_classes=["custom-button"])
|
| 356 |
|
| 357 |
|
|
|
|
| 361 |
|
| 362 |
|
| 363 |
with gr.Row():
|
| 364 |
+
submit_btn = gr.Button("提交", elem_classes=["custom-button"])
|
| 365 |
+
clear_btn = gr.Button("清楚", elem_classes=["custom-button"])
|
| 366 |
clear_btn.click(fn=clear_inputs, inputs=[], outputs=[])
|
| 367 |
|
| 368 |
with gr.Column():
|
| 369 |
with gr.Row():
|
| 370 |
+
output_text = gr.Textbox(label="ChatGPT回复", interactive=True, lines=1)
|
| 371 |
with gr.Row():
|
| 372 |
+
output_word = gr.File(label="下载word文件")
|
| 373 |
# output_pdf = gr.File(label="Download PDF File")
|
| 374 |
+
output_pdf = gr.File(label="下载PDF文件")
|
| 375 |
|
| 376 |
+
submit_btn.click(fn=CustomChatGPT, inputs=[text_input, file_input], outputs=[output_text, output_word, output_pdf])
|
| 377 |
|
| 378 |
with gr.Row():
|
| 379 |
log_text = gr.Textbox(label="Log Content", interactive=True, lines=1)
|
| 380 |
|
| 381 |
with gr.Row():
|
| 382 |
+
view_log_button = gr.Button("对话记录", elem_classes=["custom-button"])
|
| 383 |
+
download_log_button = gr.Button("下载对话记录", elem_classes=["custom-button"])
|
| 384 |
+
clear_log_button = gr.Button("清楚对话记录", elem_classes=["custom-button"])
|
| 385 |
|
| 386 |
view_log_button.click(fn=read_log_file, inputs=[], outputs=log_text)
|
| 387 |
download_log_button.click(fn=get_log_file, inputs=[], outputs=[])
|
|
|
|
| 392 |
|
| 393 |
|
| 394 |
if __name__ == "__main__":
|
| 395 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|