Update app.py
Browse files
app.py
CHANGED
|
@@ -332,9 +332,9 @@ def generate(
|
|
| 332 |
# Fix bug that last answer is not recorded!
|
| 333 |
# Parse the outputs into a readable sentence and record them
|
| 334 |
# Filter out empty strings and join the remaining strings with spaces
|
| 335 |
-
|
| 336 |
# Print the readable sentence
|
| 337 |
-
|
| 338 |
|
| 339 |
# Save chat history to .csv file on HuggingFace Hub
|
| 340 |
#pd.DataFrame(conversation).to_csv(DATA_FILE, index=False)
|
|
@@ -379,7 +379,7 @@ def generate(
|
|
| 379 |
|
| 380 |
# Add timestamp column
|
| 381 |
conversation_df = pd.DataFrame(conversation)
|
| 382 |
-
|
| 383 |
conversation_df['timestamp'] = timestamp
|
| 384 |
|
| 385 |
# Append new conversation to existing data
|
|
@@ -388,7 +388,7 @@ def generate(
|
|
| 388 |
else:
|
| 389 |
# If file doesn't exist, create new file with conversation data
|
| 390 |
conversation_df = pd.DataFrame(conversation)
|
| 391 |
-
|
| 392 |
conversation_df['timestamp'] = timestamp
|
| 393 |
conversation_df.to_csv(data_file, index=False)
|
| 394 |
|
|
|
|
| 332 |
# Fix bug that last answer is not recorded!
|
| 333 |
# Parse the outputs into a readable sentence and record them
|
| 334 |
# Filter out empty strings and join the remaining strings with spaces
|
| 335 |
+
readable_sentence = ' '.join(filter(lambda x: x.strip(), outputs))
|
| 336 |
# Print the readable sentence
|
| 337 |
+
print(readable_sentence)
|
| 338 |
|
| 339 |
# Save chat history to .csv file on HuggingFace Hub
|
| 340 |
#pd.DataFrame(conversation).to_csv(DATA_FILE, index=False)
|
|
|
|
| 379 |
|
| 380 |
# Add timestamp column
|
| 381 |
conversation_df = pd.DataFrame(conversation)
|
| 382 |
+
conversation_df['readable_sentence'] = readable_sentence
|
| 383 |
conversation_df['timestamp'] = timestamp
|
| 384 |
|
| 385 |
# Append new conversation to existing data
|
|
|
|
| 388 |
else:
|
| 389 |
# If file doesn't exist, create new file with conversation data
|
| 390 |
conversation_df = pd.DataFrame(conversation)
|
| 391 |
+
conversation_df['readable_sentence'] = readable_sentence
|
| 392 |
conversation_df['timestamp'] = timestamp
|
| 393 |
conversation_df.to_csv(data_file, index=False)
|
| 394 |
|