Spaces:
Runtime error
Runtime error
Update with custom questins
Browse files
app.py
CHANGED
@@ -45,8 +45,12 @@ def download_and_parse_json_blob(storage_connection_string, container_name, blob
|
|
45 |
# Parameter "title" und "email" aus dem JSON-Datenobjekt extrahieren und zurückgeben
|
46 |
title = json_data.get("title", "")
|
47 |
email = json_data.get("email", "")
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
return title, email
|
50 |
except Exception as e:
|
51 |
print(f"Fehler beim Herunterladen und Verarbeiten der JSON-Datei: {str(e)}")
|
52 |
return None, None
|
@@ -79,8 +83,6 @@ def download_pdf_blob_as_text(storage_connection_string, container_name, blob_na
|
|
79 |
def load_job_data(job, resume, job_params):
|
80 |
if not job:
|
81 |
try:
|
82 |
-
print("Hello there")
|
83 |
-
print(job_params["job"])
|
84 |
pdf_filename_jobdescription = job_params["job"]+".pdf"
|
85 |
pdf_filename_cv = job_params["job"]+"_resume.pdf"
|
86 |
json_filename = job_params["job"]+"_jsondata.json"
|
@@ -89,6 +91,7 @@ def load_job_data(job, resume, job_params):
|
|
89 |
job = download_pdf_blob_as_text(storage_connection_string, container_name, pdf_filename_jobdescription)
|
90 |
resume = download_pdf_blob_as_text(storage_connection_string, container_name, pdf_filename_cv)
|
91 |
job_params = download_and_parse_json_blob(storage_connection_string,container_name,json_filename)
|
|
|
92 |
return job, resume, job_params, gr.Label.update("Evaluation for the job: "+job_params[0])
|
93 |
except:
|
94 |
gr.Error("An error occurred, the job description could not be loaded. Please contact the recruiter.")
|
@@ -128,8 +131,21 @@ def bot(history, job, resume, job_params):
|
|
128 |
if not resume or not job:
|
129 |
yield history
|
130 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
-
system = sys_prompt.format(job=job, resume=resume, n=10)
|
133 |
messages = [{"role": "system", "content": system}]
|
134 |
for user, assistant in history:
|
135 |
if user:
|
@@ -191,13 +207,9 @@ def send_evaluation(history, job, resume, job_params):
|
|
191 |
# E-Mail-Nachricht erstellen
|
192 |
subject = "Evaluation for the job: "+job_params[0]
|
193 |
message = f"""Dear Recruiter,
|
194 |
-
|
195 |
Please find attached the complete chat history for this evaluation, resume and summary.
|
196 |
-
|
197 |
The evaluation AI-supported summarized:
|
198 |
-
|
199 |
{ai_summary}
|
200 |
-
|
201 |
Sincerely,
|
202 |
Your Evaluation Tool
|
203 |
"""
|
@@ -262,7 +274,7 @@ Your Evaluation Tool
|
|
262 |
print("Fehler beim Senden der E-Mail:", str(e))
|
263 |
|
264 |
def handle_start_click(welcome_label, start):
|
265 |
-
return gr.Label.update("", visible=False), gr.Button.update("
|
266 |
|
267 |
|
268 |
css = "footer {visibility: hidden} #component-0{height: 90vh !important} #chatbot{height: 85vh !important} #welcome_label {text-align: center!important}"
|
|
|
45 |
# Parameter "title" und "email" aus dem JSON-Datenobjekt extrahieren und zurückgeben
|
46 |
title = json_data.get("title", "")
|
47 |
email = json_data.get("email", "")
|
48 |
+
question_one = json_data.get("question_one", "")
|
49 |
+
question_two = json_data.get("question_two", "")
|
50 |
+
question_three = json_data.get("question_three", "")
|
51 |
+
|
52 |
|
53 |
+
return title, email, question_one, question_two, question_three
|
54 |
except Exception as e:
|
55 |
print(f"Fehler beim Herunterladen und Verarbeiten der JSON-Datei: {str(e)}")
|
56 |
return None, None
|
|
|
83 |
def load_job_data(job, resume, job_params):
|
84 |
if not job:
|
85 |
try:
|
|
|
|
|
86 |
pdf_filename_jobdescription = job_params["job"]+".pdf"
|
87 |
pdf_filename_cv = job_params["job"]+"_resume.pdf"
|
88 |
json_filename = job_params["job"]+"_jsondata.json"
|
|
|
91 |
job = download_pdf_blob_as_text(storage_connection_string, container_name, pdf_filename_jobdescription)
|
92 |
resume = download_pdf_blob_as_text(storage_connection_string, container_name, pdf_filename_cv)
|
93 |
job_params = download_and_parse_json_blob(storage_connection_string,container_name,json_filename)
|
94 |
+
print(job_params)
|
95 |
return job, resume, job_params, gr.Label.update("Evaluation for the job: "+job_params[0])
|
96 |
except:
|
97 |
gr.Error("An error occurred, the job description could not be loaded. Please contact the recruiter.")
|
|
|
131 |
if not resume or not job:
|
132 |
yield history
|
133 |
return
|
134 |
+
if len(job_params[2])>0 or len(job_params[3])>0 or len(job_params[4])>0:
|
135 |
+
questions_combined = ""
|
136 |
+
if len(job_params[2])>0:
|
137 |
+
questions_combined += "-"+job_params[2]+"\n"
|
138 |
+
if len(job_params[3])>0:
|
139 |
+
questions_combined += "-"+job_params[3]+"\n"
|
140 |
+
if len(job_params[4])>0:
|
141 |
+
questions_combined += "-"+job_params[4]+"\n"
|
142 |
+
|
143 |
+
extension_text = "The recruiter has predefined the following question(s): \n\n" + questions_combined + "\nPlease ask these questions one after the other first and only then generate your own questions so that you get a total of 10 questions together with the predefined ones."
|
144 |
+
|
145 |
+
system = sys_prompt.format(job=job, resume=resume, n=10, extension=extension_text)
|
146 |
+
else:
|
147 |
+
system = sys_prompt.format(job=job, resume=resume, n=10, extension="")
|
148 |
|
|
|
149 |
messages = [{"role": "system", "content": system}]
|
150 |
for user, assistant in history:
|
151 |
if user:
|
|
|
207 |
# E-Mail-Nachricht erstellen
|
208 |
subject = "Evaluation for the job: "+job_params[0]
|
209 |
message = f"""Dear Recruiter,
|
|
|
210 |
Please find attached the complete chat history for this evaluation, resume and summary.
|
|
|
211 |
The evaluation AI-supported summarized:
|
|
|
212 |
{ai_summary}
|
|
|
213 |
Sincerely,
|
214 |
Your Evaluation Tool
|
215 |
"""
|
|
|
274 |
print("Fehler beim Senden der E-Mail:", str(e))
|
275 |
|
276 |
def handle_start_click(welcome_label, start):
|
277 |
+
return gr.Label.update("", visible=False), gr.Button.update("Interview started", scale=0,interactive=False)
|
278 |
|
279 |
|
280 |
css = "footer {visibility: hidden} #component-0{height: 90vh !important} #chatbot{height: 85vh !important} #welcome_label {text-align: center!important}"
|