Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -77,14 +77,14 @@ tools = [{"type": "function", "function": record_user_details_json},
|
|
77 |
class Me:
|
78 |
|
79 |
def __init__(self):
|
80 |
-
self.openai = OpenAI(
|
81 |
self.name = "Samuel Alex"
|
82 |
-
reader = PdfReader("me/
|
83 |
-
self.
|
84 |
for page in reader.pages:
|
85 |
text = page.extract_text()
|
86 |
if text:
|
87 |
-
self.
|
88 |
with open("me/summary.txt", "r", encoding="utf-8") as f:
|
89 |
self.summary = f.read()
|
90 |
|
@@ -104,12 +104,12 @@ class Me:
|
|
104 |
system_prompt = f"You are acting as {self.name}. You are answering questions on {self.name}'s website, \
|
105 |
particularly questions related to {self.name}'s career, background, skills and experience. \
|
106 |
Your responsibility is to represent {self.name} for interactions on the website as faithfully as possible. \
|
107 |
-
You are given a summary of {self.name}'s background and
|
108 |
Be professional and engaging, as if talking to a potential client or future employer who came across the website. \
|
109 |
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. \
|
110 |
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. "
|
111 |
|
112 |
-
system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.
|
113 |
system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
|
114 |
return system_prompt
|
115 |
|
@@ -117,7 +117,7 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
117 |
messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
|
118 |
done = False
|
119 |
while not done:
|
120 |
-
response = self.openai.chat.completions.create(model="
|
121 |
if response.choices[0].finish_reason=="tool_calls":
|
122 |
message = response.choices[0].message
|
123 |
tool_calls = message.tool_calls
|
|
|
77 |
class Me:
|
78 |
|
79 |
def __init__(self):
|
80 |
+
self.openai = OpenAI()
|
81 |
self.name = "Samuel Alex"
|
82 |
+
reader = PdfReader("me/Sam_CV.pdf")
|
83 |
+
self.Sam_CV = ""
|
84 |
for page in reader.pages:
|
85 |
text = page.extract_text()
|
86 |
if text:
|
87 |
+
self.Sam_CV += text
|
88 |
with open("me/summary.txt", "r", encoding="utf-8") as f:
|
89 |
self.summary = f.read()
|
90 |
|
|
|
104 |
system_prompt = f"You are acting as {self.name}. You are answering questions on {self.name}'s website, \
|
105 |
particularly questions related to {self.name}'s career, background, skills and experience. \
|
106 |
Your responsibility is to represent {self.name} for interactions on the website as faithfully as possible. \
|
107 |
+
You are given a summary of {self.name}'s background and CV profile which you can use to answer questions. \
|
108 |
Be professional and engaging, as if talking to a potential client or future employer who came across the website. \
|
109 |
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. \
|
110 |
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. "
|
111 |
|
112 |
+
system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.Sam_CV}\n\n"
|
113 |
system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
|
114 |
return system_prompt
|
115 |
|
|
|
117 |
messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
|
118 |
done = False
|
119 |
while not done:
|
120 |
+
response = self.openai.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=tools)
|
121 |
if response.choices[0].finish_reason=="tool_calls":
|
122 |
message = response.choices[0].message
|
123 |
tool_calls = message.tool_calls
|