Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -163,6 +163,11 @@ def download_threads_as_pdf(chat_threads):
|
|
| 163 |
for msg in chats:
|
| 164 |
role = "You" if msg["role"] == "user" else "Assistant"
|
| 165 |
text = f"{role}: {msg['content']}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
pdf.multi_cell(0, 10, text)
|
| 167 |
pdf.ln(5)
|
| 168 |
pdf_output = BytesIO()
|
|
@@ -171,6 +176,7 @@ def download_threads_as_pdf(chat_threads):
|
|
| 171 |
pdf_output.seek(0)
|
| 172 |
return pdf_output
|
| 173 |
|
|
|
|
| 174 |
# --- Streamlit UI ---
|
| 175 |
st.set_page_config(page_title="🧠 Deep Research Assistant 3.0", layout="centered")
|
| 176 |
|
|
|
|
| 163 |
for msg in chats:
|
| 164 |
role = "You" if msg["role"] == "user" else "Assistant"
|
| 165 |
text = f"{role}: {msg['content']}"
|
| 166 |
+
# Safely encode for Latin-1 by replacing unknown characters
|
| 167 |
+
try:
|
| 168 |
+
text = text.encode('latin-1').decode('latin-1')
|
| 169 |
+
except UnicodeEncodeError:
|
| 170 |
+
text = text.encode('latin-1', 'replace').decode('latin-1')
|
| 171 |
pdf.multi_cell(0, 10, text)
|
| 172 |
pdf.ln(5)
|
| 173 |
pdf_output = BytesIO()
|
|
|
|
| 176 |
pdf_output.seek(0)
|
| 177 |
return pdf_output
|
| 178 |
|
| 179 |
+
|
| 180 |
# --- Streamlit UI ---
|
| 181 |
st.set_page_config(page_title="🧠 Deep Research Assistant 3.0", layout="centered")
|
| 182 |
|