pdx97 commited on
Commit
422754d
·
verified ·
1 Parent(s): 513f9c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -52,10 +52,16 @@ from smolagents import CodeAgent, HfApiModel, tool
52
  from rank_bm25 import BM25Okapi
53
  import nltk
54
 
55
- try:
56
- nltk.data.find("tokenizers/punkt")
57
- except LookupError:
58
- nltk.download("punkt")
 
 
 
 
 
 
59
 
60
  @tool # Register the function properly as a SmolAgents tool
61
  def fetch_latest_arxiv_papers(keywords: list, num_results: int = 5) -> list:
 
52
  from rank_bm25 import BM25Okapi
53
  import nltk
54
 
55
+ import os
56
+ import shutil
57
+
58
+ # Step 1: Remove existing corrupted punkt data
59
+ nltk_data_path = os.path.join(nltk.data.path[0], "tokenizers", "punkt")
60
+ if os.path.exists(nltk_data_path):
61
+ shutil.rmtree(nltk_data_path) # Remove corrupted version
62
+
63
+ # Step 2: Download punkt again
64
+ nltk.download("punkt")
65
 
66
  @tool # Register the function properly as a SmolAgents tool
67
  def fetch_latest_arxiv_papers(keywords: list, num_results: int = 5) -> list: