For importing resume as pdf
Browse files
app.py
CHANGED
@@ -62,13 +62,35 @@ def process_resume_and_respond(pdf_file, message, history, system_message, max_t
|
|
62 |
return respond(combined_message, history, system_message, max_tokens, temperature, top_p)
|
63 |
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
"""
|
66 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
67 |
"""
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
additional_inputs=[
|
71 |
-
gr.File(label="Upload Resume PDF"),
|
72 |
gr.Textbox(value="You are a Job Advisor Chatbot.", label="System message"),
|
73 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
74 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
@@ -82,6 +104,11 @@ demo = gr.ChatInterface(
|
|
82 |
],
|
83 |
)
|
84 |
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
demo.launch()
|
|
|
62 |
return respond(combined_message, history, system_message, max_tokens, temperature, top_p)
|
63 |
|
64 |
|
65 |
+
# Store the uploaded PDF content globally
|
66 |
+
uploaded_resume_text = ""
|
67 |
+
|
68 |
+
def upload_resume(pdf_file):
|
69 |
+
global uploaded_resume_text
|
70 |
+
uploaded_resume_text = extract_text_from_pdf(pdf_file.name)
|
71 |
+
return "Resume uploaded successfully!"
|
72 |
+
|
73 |
+
|
74 |
+
def respond_with_resume(message, history, system_message, max_tokens, temperature, top_p):
|
75 |
+
global uploaded_resume_text
|
76 |
+
# Combine the uploaded resume text with the user message
|
77 |
+
combined_message = f"Resume:\n{uploaded_resume_text}\n\nUser message:\n{message}"
|
78 |
+
# Respond using the combined message
|
79 |
+
return respond(combined_message, history, system_message, max_tokens, temperature, top_p)
|
80 |
+
|
81 |
+
|
82 |
"""
|
83 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
84 |
"""
|
85 |
+
upload_interface = gr.Interface(
|
86 |
+
upload_resume,
|
87 |
+
inputs=gr.File(label="Upload Resume PDF"),
|
88 |
+
outputs=gr.Textbox(label="Upload Status"),
|
89 |
+
)
|
90 |
+
|
91 |
+
chat_interface = gr.ChatInterface(
|
92 |
+
respond_with_resume,
|
93 |
additional_inputs=[
|
|
|
94 |
gr.Textbox(value="You are a Job Advisor Chatbot.", label="System message"),
|
95 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
96 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
|
|
104 |
],
|
105 |
)
|
106 |
|
107 |
+
demo = gr.TabbedInterface(
|
108 |
+
[upload_interface, chat_interface],
|
109 |
+
["Upload Resume", "Chat with Job Advisor"]
|
110 |
+
)
|
111 |
+
|
112 |
|
113 |
if __name__ == "__main__":
|
114 |
demo.launch()
|