Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -95,7 +95,6 @@ class Me:
|
|
95 |
self.session_log = []
|
96 |
Path("chat_logs").mkdir(exist_ok=True)
|
97 |
|
98 |
-
# Download resume and summary
|
99 |
gdown.download("https://drive.google.com/uc?id=1xz2RowkImpI8odYv8zvKdlRHaKfILn40", "linkedin.pdf", quiet=False)
|
100 |
reader = PdfReader("linkedin.pdf")
|
101 |
self.linkedin = "".join(page.extract_text() or "" for page in reader.pages)
|
@@ -148,17 +147,36 @@ If you can't answer something, call `record_unknown_question`. If a user seems i
|
|
148 |
model="gpt-4o",
|
149 |
messages=messages,
|
150 |
tools=tools,
|
151 |
-
stream=
|
152 |
)
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
-
self.session_log.append({"role": "assistant", "content": full_response})
|
162 |
self.save_session_log()
|
163 |
|
164 |
def save_session_log(self):
|
|
|
95 |
self.session_log = []
|
96 |
Path("chat_logs").mkdir(exist_ok=True)
|
97 |
|
|
|
98 |
gdown.download("https://drive.google.com/uc?id=1xz2RowkImpI8odYv8zvKdlRHaKfILn40", "linkedin.pdf", quiet=False)
|
99 |
reader = PdfReader("linkedin.pdf")
|
100 |
self.linkedin = "".join(page.extract_text() or "" for page in reader.pages)
|
|
|
147 |
model="gpt-4o",
|
148 |
messages=messages,
|
149 |
tools=tools,
|
150 |
+
stream=False
|
151 |
)
|
152 |
|
153 |
+
reply = response.choices[0].message
|
154 |
+
|
155 |
+
if reply.tool_calls:
|
156 |
+
messages.append(reply)
|
157 |
+
tool_results = self.handle_tool_call(reply.tool_calls)
|
158 |
+
messages.extend(tool_results)
|
159 |
+
|
160 |
+
follow_up = "✅ I've saved that info. Let me know if you'd like to ask more questions."
|
161 |
+
self.session_log.append({"role": "assistant", "content": follow_up})
|
162 |
+
yield follow_up
|
163 |
+
else:
|
164 |
+
stream = self.openai.chat.completions.create(
|
165 |
+
model="gpt-4o",
|
166 |
+
messages=messages,
|
167 |
+
tools=tools,
|
168 |
+
stream=True
|
169 |
+
)
|
170 |
+
|
171 |
+
full_response = ""
|
172 |
+
for chunk in stream:
|
173 |
+
delta = chunk.choices[0].delta
|
174 |
+
if hasattr(delta, "content") and delta.content:
|
175 |
+
full_response += delta.content
|
176 |
+
yield full_response
|
177 |
+
|
178 |
+
self.session_log.append({"role": "assistant", "content": full_response})
|
179 |
|
|
|
180 |
self.save_session_log()
|
181 |
|
182 |
def save_session_log(self):
|