Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -940,17 +940,14 @@ if query:
|
|
940 |
dataset = Dataset.from_dict({'id': [], 'text': []})
|
941 |
|
942 |
def save_comment(comment):
|
943 |
-
# Check if the
|
944 |
if os.path.exists('comments'):
|
945 |
-
# Load the dataset from disk
|
946 |
dataset = Dataset.load_from_disk('comments')
|
947 |
else:
|
948 |
-
# Create a new dataset
|
949 |
dataset = Dataset.from_dict({'id': [], 'text': []})
|
950 |
|
951 |
-
#
|
952 |
-
dataset
|
953 |
-
dataset['text'].append(comment)
|
954 |
|
955 |
# Save the dataset to disk
|
956 |
dataset.save_to_disk('comments')
|
|
|
940 |
dataset = Dataset.from_dict({'id': [], 'text': []})
|
941 |
|
942 |
def save_comment(comment):
|
943 |
+
# Check if the dataset exists
|
944 |
if os.path.exists('comments'):
|
|
|
945 |
dataset = Dataset.load_from_disk('comments')
|
946 |
else:
|
|
|
947 |
dataset = Dataset.from_dict({'id': [], 'text': []})
|
948 |
|
949 |
+
# Append the new comment to the dataset
|
950 |
+
dataset = dataset.append({'id': len(dataset), 'text': comment})
|
|
|
951 |
|
952 |
# Save the dataset to disk
|
953 |
dataset.save_to_disk('comments')
|