Spaces:
Running
Running
Update with sms dispatch
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ from PyPDF2 import PdfReader
|
|
20 |
import openai
|
21 |
import sendgrid
|
22 |
from sendgrid.helpers.mail import Mail, Attachment, FileContent, FileName, FileType, Disposition
|
|
|
23 |
import ssl
|
24 |
ssl._create_default_https_context = ssl._create_unverified_context
|
25 |
|
@@ -201,6 +202,24 @@ WorkGenius
|
|
201 |
print("Mail generated")
|
202 |
return output_string
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
def check_keywords_in_content(database_path, table_name, input_id, keywords):
|
205 |
# Verbindung zur Datenbank herstellen
|
206 |
conn = sqlite3.connect(database_path)
|
@@ -452,6 +471,7 @@ if (st.session_state["job"] and submit) or st.session_state["docs_res"]:
|
|
452 |
st.write(final_q)
|
453 |
if len(st.session_state["final_question_string"])>0:
|
454 |
st.text_input("Enter the email address to which the test emails should be sent:",key="recruiter_mail")
|
|
|
455 |
st.text_input("Enter the job title:", key="job_title")
|
456 |
if st.button("Submit", use_container_width=True):
|
457 |
with st.spinner("Generation and dispatch of mails. This process may take a few minutes..."):
|
@@ -527,10 +547,24 @@ Your Candidate-Search-Tool
|
|
527 |
try:
|
528 |
response = sg.send(message)
|
529 |
print("E-Mail wurde erfolgreich gesendet. Statuscode:", response.status_code)
|
530 |
-
st.success('The mail dispatch and the upload of the data was successful')
|
531 |
os.remove("mailattachment.txt")
|
532 |
except Exception as e:
|
533 |
print("Fehler beim Senden der E-Mail:", str(e))
|
534 |
st.error("Unfortunately the mail dispatch did not work. Please reload the page and try again or contact the administrator. ", icon="🚨")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
|
536 |
|
|
|
20 |
import openai
|
21 |
import sendgrid
|
22 |
from sendgrid.helpers.mail import Mail, Attachment, FileContent, FileName, FileType, Disposition
|
23 |
+
from twilio.rest import Client
|
24 |
import ssl
|
25 |
ssl._create_default_https_context = ssl._create_unverified_context
|
26 |
|
|
|
202 |
print("Mail generated")
|
203 |
return output_string
|
204 |
|
205 |
+
def generate_job_bullets(job)->str:
|
206 |
+
prompt = "You are a professional recruiter whose task is to summarize the provided job description in the most important 5 key points. The key points should have a maximum of 8 words. The only thing you should return are the bullet points."
|
207 |
+
res = openai.ChatCompletion.create(
|
208 |
+
engine="gpt-4",
|
209 |
+
temperature=0.2,
|
210 |
+
messages=[
|
211 |
+
{
|
212 |
+
"role": "system",
|
213 |
+
"content": prompt,
|
214 |
+
},
|
215 |
+
{"role": "system", "content": "Job description: "+st.session_state["job_string"]}
|
216 |
+
],
|
217 |
+
)
|
218 |
+
# print(res.choices[0]["message"]["content"])
|
219 |
+
output_string = f"""{res.choices[0]["message"]["content"]}"""
|
220 |
+
# print(output_string)
|
221 |
+
return output_string
|
222 |
+
|
223 |
def check_keywords_in_content(database_path, table_name, input_id, keywords):
|
224 |
# Verbindung zur Datenbank herstellen
|
225 |
conn = sqlite3.connect(database_path)
|
|
|
471 |
st.write(final_q)
|
472 |
if len(st.session_state["final_question_string"])>0:
|
473 |
st.text_input("Enter the email address to which the test emails should be sent:",key="recruiter_mail")
|
474 |
+
st.text_input("Enter the phone number to which the test SMS should be sent (With country code, e.g. +1 for the USA or +49 for Germany):",key="recruiter_phone")
|
475 |
st.text_input("Enter the job title:", key="job_title")
|
476 |
if st.button("Submit", use_container_width=True):
|
477 |
with st.spinner("Generation and dispatch of mails. This process may take a few minutes..."):
|
|
|
547 |
try:
|
548 |
response = sg.send(message)
|
549 |
print("E-Mail wurde erfolgreich gesendet. Statuscode:", response.status_code)
|
|
|
550 |
os.remove("mailattachment.txt")
|
551 |
except Exception as e:
|
552 |
print("Fehler beim Senden der E-Mail:", str(e))
|
553 |
st.error("Unfortunately the mail dispatch did not work. Please reload the page and try again or contact the administrator. ", icon="🚨")
|
554 |
+
try:
|
555 |
+
bullets = generate_job_bullets(st.session_state["job_string"])
|
556 |
+
client = Client(os.getenv("TWILIO_SID"), os.getenv("TWILIO_API"))
|
557 |
+
message_body = f"Dear candidate,\n\nare you interested in the following position: \n\n"+st.session_state["job_title"]+"\n"+bullets+"\n\nThen please answer with 'yes'\n\nSincerely,\n"+"WorkGenius"
|
558 |
+
message = client.messages.create(
|
559 |
+
to=st.session_state["recruiter_phone"],
|
560 |
+
from_="+1 857 214 8753",
|
561 |
+
body=message_body
|
562 |
+
)
|
563 |
+
|
564 |
+
print(f"Message sent with SID: {message.sid}")
|
565 |
+
st.success('The dispatch and the upload of the data was successful')
|
566 |
+
except Exception as e:
|
567 |
+
st.error("Unfortunately the SMS dispatch did not work. Please reload the page and try again or contact the administrator. ", icon="🚨")
|
568 |
+
print("Fehler beim Senden der SMS:", str(e))
|
569 |
|
570 |
|