Spaces:
Running
Running
Upload app_v2_entry_hot.py
Browse files- app_v2_entry_hot.py +24 -0
app_v2_entry_hot.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Hot topics patch - makes AI topics always visible at top of HOT list."""
|
| 2 |
+
# This file is imported by app_v2_entry.py
|
| 3 |
+
|
| 4 |
+
# AI topics to prepend to hot topics
|
| 5 |
+
AI_HOT_TOPICS = [
|
| 6 |
+
{'label': '#Công nghệ AI', 'topic': 'Công nghệ AI', 'count': 0},
|
| 7 |
+
{'label': '#World Cup 2026', 'topic': 'World Cup 2026', 'count': 0},
|
| 8 |
+
{'label': '#Kinh tế Việt Nam', 'topic': 'Kinh tế Việt Nam', 'count': 0},
|
| 9 |
+
{'label': '#Bóng đá châu Âu', 'topic': 'Bóng đá châu Âu', 'count': 0},
|
| 10 |
+
{'label': '#Giá vàng', 'topic': 'Giá vàng', 'count': 0},
|
| 11 |
+
{'label': '#Thời tiết', 'topic': 'Thời tiết', 'count': 0},
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
def prepend_ai_hot_topics(topics):
|
| 15 |
+
"""Prepend AI topics to hot topics list, ensuring they're always visible."""
|
| 16 |
+
if not topics:
|
| 17 |
+
return AI_HOT_TOPICS[:]
|
| 18 |
+
# Remove duplicates that already exist
|
| 19 |
+
existing_topics = [t.get('topic', '').lower() for t in topics]
|
| 20 |
+
result = []
|
| 21 |
+
for ai_topic in AI_HOT_TOPICS:
|
| 22 |
+
if ai_topic.get('topic', '').lower() not in existing_topics:
|
| 23 |
+
result.append(ai_topic)
|
| 24 |
+
return result + topics
|