Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
import threading
|
3 |
from flask import Flask, render_template, request, jsonify
|
4 |
-
from rss_processor import fetch_rss_feeds, process_and_store_articles, vector_db
|
5 |
import logging
|
6 |
import time
|
7 |
from datetime import datetime
|
@@ -25,6 +25,8 @@ def load_feeds_in_background():
|
|
25 |
process_and_store_articles(articles)
|
26 |
last_update_time = time.time() # Update timestamp when new articles are added
|
27 |
logger.info("Background feed processing complete")
|
|
|
|
|
28 |
loading_complete = True
|
29 |
except Exception as e:
|
30 |
logger.error(f"Error in background feed loading: {e}")
|
@@ -35,6 +37,11 @@ def index():
|
|
35 |
global loading_complete
|
36 |
loading_complete = False # Reset on each load
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
# Start background feed loading
|
39 |
threading.Thread(target=load_feeds_in_background, daemon=True).start()
|
40 |
|
|
|
1 |
import os
|
2 |
import threading
|
3 |
from flask import Flask, render_template, request, jsonify
|
4 |
+
from rss_processor import fetch_rss_feeds, process_and_store_articles, vector_db, download_from_hf_hub, upload_to_hf_hub
|
5 |
import logging
|
6 |
import time
|
7 |
from datetime import datetime
|
|
|
25 |
process_and_store_articles(articles)
|
26 |
last_update_time = time.time() # Update timestamp when new articles are added
|
27 |
logger.info("Background feed processing complete")
|
28 |
+
# Upload updated DB to Hugging Face Hub
|
29 |
+
upload_to_hf_hub()
|
30 |
loading_complete = True
|
31 |
except Exception as e:
|
32 |
logger.error(f"Error in background feed loading: {e}")
|
|
|
37 |
global loading_complete
|
38 |
loading_complete = False # Reset on each load
|
39 |
|
40 |
+
# Ensure Chroma DB is downloaded from Hugging Face Hub on first load
|
41 |
+
if not os.path.exists("chroma_db"):
|
42 |
+
logger.info("Downloading Chroma DB from Hugging Face Hub...")
|
43 |
+
download_from_hf_hub()
|
44 |
+
|
45 |
# Start background feed loading
|
46 |
threading.Thread(target=load_feeds_in_background, daemon=True).start()
|
47 |
|