Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import os
|
|
| 5 |
import requests
|
| 6 |
from pypdf import PdfReader
|
| 7 |
import gradio as gr
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
load_dotenv(override=True)
|
|
@@ -19,10 +20,30 @@ def push(text):
|
|
| 19 |
}
|
| 20 |
)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
def record_user_details(email, name="Name not provided", notes="not provided"):
|
| 24 |
push(f"Recording {name} with email {email} and notes {notes}")
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
def record_unknown_question(question):
|
| 28 |
push(f"Recording {question}")
|
|
@@ -106,7 +127,8 @@ Your responsibility is to represent {self.name} for interactions on the website
|
|
| 106 |
You are given a summary of {self.name}'s background and LinkedIn profile which you can use to answer questions. \
|
| 107 |
Be professional and engaging, as if talking to a potential client or future employer who came across the website. \
|
| 108 |
If you don't know the answer to any question, use your record_unknown_question tool to record the question that you couldn't answer, even if it's about something trivial or unrelated to career. \
|
| 109 |
-
If the user is engaging in discussion, try to steer them towards getting in touch via email; ask for their email and record it using your record_user_details tool.
|
|
|
|
| 110 |
|
| 111 |
system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.linkedin}\n\n"
|
| 112 |
system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
|
|
|
|
| 5 |
import requests
|
| 6 |
from pypdf import PdfReader
|
| 7 |
import gradio as gr
|
| 8 |
+
import base64
|
| 9 |
|
| 10 |
|
| 11 |
load_dotenv(override=True)
|
|
|
|
| 20 |
}
|
| 21 |
)
|
| 22 |
|
| 23 |
+
def send_email(from_email, name, notes):
|
| 24 |
+
auth = base64.b64encode(f'api:{os.getenv("MAILGUN_API_KEY")}'.encode()).decode()
|
| 25 |
+
|
| 26 |
+
response = requests.post(
|
| 27 |
+
f'https://api.mailgun.net/v3/{os.getenv("MAILGUN_DOMAIN")}/messages',
|
| 28 |
+
headers={
|
| 29 |
+
'Authorization': f'Basic {auth}'
|
| 30 |
+
},
|
| 31 |
+
data={
|
| 32 |
+
'from': f'Contact Form <mailgun@{os.getenv("MAILGUN_DOMAIN")}>',
|
| 33 |
+
'to': os.getenv("MAILGUN_RECIPIENT"),
|
| 34 |
+
'subject': f'New Contact: {name} ({from_email})',
|
| 35 |
+
'text': f'Name: {name}\nEmail: {from_email}\nNotes: {notes}'
|
| 36 |
+
}
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
return response.status_code == 200
|
| 40 |
+
|
| 41 |
|
| 42 |
def record_user_details(email, name="Name not provided", notes="not provided"):
|
| 43 |
push(f"Recording {name} with email {email} and notes {notes}")
|
| 44 |
+
# Send email notification
|
| 45 |
+
email_sent = send_email(email, name, notes)
|
| 46 |
+
return {"recorded": "ok", "email_sent": email_sent}
|
| 47 |
|
| 48 |
def record_unknown_question(question):
|
| 49 |
push(f"Recording {question}")
|
|
|
|
| 127 |
You are given a summary of {self.name}'s background and LinkedIn profile which you can use to answer questions. \
|
| 128 |
Be professional and engaging, as if talking to a potential client or future employer who came across the website. \
|
| 129 |
If you don't know the answer to any question, use your record_unknown_question tool to record the question that you couldn't answer, even if it's about something trivial or unrelated to career. \
|
| 130 |
+
If the user is engaging in discussion, try to steer them towards getting in touch via email; ask for their email and record it using your record_user_details tool. \
|
| 131 |
+
When a user provides their email, both a push notification and an email notification will be sent."
|
| 132 |
|
| 133 |
system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.linkedin}\n\n"
|
| 134 |
system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
|