arka7 commited on
Commit
8cc3554
·
verified ·
1 Parent(s): faf0342

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -166,6 +166,11 @@ def sync_from_hf():
166
  try:
167
  dataset = load_dataset(HF_DATASET_REPO, split="train", token=HF_TOKEN)
168
 
 
 
 
 
 
169
  # Convert dataset to SQLite
170
  conn = get_db_connection()
171
  cursor = conn.cursor()
@@ -199,8 +204,9 @@ def sync_from_hf():
199
  return True
200
 
201
  except Exception as e:
202
- if "not found" in str(e).lower() or "doesn't exist" in str(e).lower():
203
- print(f"ℹ️ Dataset '{HF_DATASET_REPO}' doesn't exist yet, will create on first save")
 
204
  return False
205
  else:
206
  print(f"⚠️ Error loading dataset: {e}")
@@ -444,6 +450,7 @@ def check_topic_similarity(new_topic: str) -> str:
444
 
445
  @tool
446
  def count_words(text: str) -> str:
 
447
  return f"Word count: {len(text.split())}"
448
 
449
  @tool
 
166
  try:
167
  dataset = load_dataset(HF_DATASET_REPO, split="train", token=HF_TOKEN)
168
 
169
+ # Check if dataset is empty
170
+ if len(dataset) == 0:
171
+ print("ℹ️ Dataset exists but is empty")
172
+ return False
173
+
174
  # Convert dataset to SQLite
175
  conn = get_db_connection()
176
  cursor = conn.cursor()
 
204
  return True
205
 
206
  except Exception as e:
207
+ error_msg = str(e).lower()
208
+ if "not found" in error_msg or "doesn't exist" in error_msg or "doesn't contain any data files" in error_msg:
209
+ print(f"ℹ️ Dataset '{HF_DATASET_REPO}' doesn't exist yet or is empty, will create on first save")
210
  return False
211
  else:
212
  print(f"⚠️ Error loading dataset: {e}")
 
450
 
451
  @tool
452
  def count_words(text: str) -> str:
453
+ """Count the number of words in the given text."""
454
  return f"Word count: {len(text.split())}"
455
 
456
  @tool