Spaces:
Paused
Paused
Update rss_processor.py
Browse files- rss_processor.py +2 -10
rss_processor.py
CHANGED
|
@@ -30,8 +30,6 @@ hf_api = HfApi()
|
|
| 30 |
|
| 31 |
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
| 32 |
|
| 33 |
-
vector_db = None
|
| 34 |
-
|
| 35 |
def clean_text(text):
|
| 36 |
if not text or not isinstance(text, str):
|
| 37 |
return ""
|
|
@@ -161,11 +159,7 @@ def categorize_feed(url):
|
|
| 161 |
logger.warning(f"No matching category found for URL: {url}")
|
| 162 |
return "Uncategorized"
|
| 163 |
|
| 164 |
-
def process_and_store_articles(articles):
|
| 165 |
-
if not vector_db:
|
| 166 |
-
logger.error("Vector database is not initialized. Cannot process articles.")
|
| 167 |
-
return
|
| 168 |
-
|
| 169 |
documents = []
|
| 170 |
doc_ids = []
|
| 171 |
|
|
@@ -252,8 +246,6 @@ def upload_to_hf_hub():
|
|
| 252 |
logger.error(f"Error uploading to Hugging Face Hub: {e}")
|
| 253 |
|
| 254 |
def run_update_pipeline():
|
| 255 |
-
global vector_db
|
| 256 |
-
|
| 257 |
download_from_hf_hub()
|
| 258 |
|
| 259 |
vector_db = Chroma(
|
|
@@ -264,7 +256,7 @@ def run_update_pipeline():
|
|
| 264 |
|
| 265 |
articles = fetch_rss_feeds()
|
| 266 |
if articles:
|
| 267 |
-
process_and_store_articles(articles)
|
| 268 |
|
| 269 |
upload_to_hf_hub()
|
| 270 |
logger.info("Update pipeline finished.")
|
|
|
|
| 30 |
|
| 31 |
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
| 32 |
|
|
|
|
|
|
|
| 33 |
def clean_text(text):
|
| 34 |
if not text or not isinstance(text, str):
|
| 35 |
return ""
|
|
|
|
| 159 |
logger.warning(f"No matching category found for URL: {url}")
|
| 160 |
return "Uncategorized"
|
| 161 |
|
| 162 |
+
def process_and_store_articles(articles, vector_db):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
documents = []
|
| 164 |
doc_ids = []
|
| 165 |
|
|
|
|
| 246 |
logger.error(f"Error uploading to Hugging Face Hub: {e}")
|
| 247 |
|
| 248 |
def run_update_pipeline():
|
|
|
|
|
|
|
| 249 |
download_from_hf_hub()
|
| 250 |
|
| 251 |
vector_db = Chroma(
|
|
|
|
| 256 |
|
| 257 |
articles = fetch_rss_feeds()
|
| 258 |
if articles:
|
| 259 |
+
process_and_store_articles(articles, vector_db)
|
| 260 |
|
| 261 |
upload_to_hf_hub()
|
| 262 |
logger.info("Update pipeline finished.")
|