Update src/pdfchatbot.py
Browse files- src/pdfchatbot.py +1 -23
src/pdfchatbot.py
CHANGED
|
@@ -170,26 +170,4 @@ class PDFChatBot:
|
|
| 170 |
if not text:
|
| 171 |
raise gr.Error('Enter text')
|
| 172 |
history.append((text, ''))
|
| 173 |
-
return history
|
| 174 |
-
|
| 175 |
-
def download_chat_history(self, history):
|
| 176 |
-
"""
|
| 177 |
-
Download the chat history as a CSV file.
|
| 178 |
-
|
| 179 |
-
Parameters:
|
| 180 |
-
history (list): List of chat history tuples.
|
| 181 |
-
Returns:
|
| 182 |
-
gr.outputs.File: A CSV file containing the chat history.
|
| 183 |
-
"""
|
| 184 |
-
import csv
|
| 185 |
-
import io
|
| 186 |
-
|
| 187 |
-
output = io.StringIO()
|
| 188 |
-
writer = csv.writer(output)
|
| 189 |
-
writer.writerow(["User Input", "Bot Response"]) # header row
|
| 190 |
-
|
| 191 |
-
for user_input, bot_response in history:
|
| 192 |
-
writer.writerow([user_input, bot_response])
|
| 193 |
-
|
| 194 |
-
output.seek(0)
|
| 195 |
-
return gr.outputs.File("chat_history.csv", output.read(), "text/csv")
|
|
|
|
| 170 |
if not text:
|
| 171 |
raise gr.Error('Enter text')
|
| 172 |
history.append((text, ''))
|
| 173 |
+
return history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|