Spaces:
Sleeping
Sleeping
Commit
·
da61e92
1
Parent(s):
4475e24
3.75 fixes display again
Browse files
app.py
CHANGED
@@ -647,11 +647,9 @@ class ProcessingUI:
|
|
647 |
|
648 |
def _update_recent_items(self, row, sentiment, event_type):
|
649 |
"""Update recent items display with custom styling"""
|
650 |
-
# Maintain a list of recent items in session state
|
651 |
if 'recent_items' not in st.session_state:
|
652 |
st.session_state.recent_items = []
|
653 |
|
654 |
-
# Add new item to the beginning of the list
|
655 |
new_item = {
|
656 |
'entity': row['Объект'],
|
657 |
'headline': row['Заголовок'],
|
@@ -661,62 +659,66 @@ class ProcessingUI:
|
|
661 |
}
|
662 |
|
663 |
st.session_state.recent_items.insert(0, new_item)
|
664 |
-
# Keep only last 10 items
|
665 |
st.session_state.recent_items = st.session_state.recent_items[:10]
|
666 |
|
667 |
-
#
|
668 |
-
|
669 |
<style>
|
670 |
-
.
|
671 |
max-height: 400px;
|
672 |
overflow-y: auto;
|
673 |
-
}}
|
674 |
-
.news-item {{
|
675 |
padding: 10px;
|
676 |
-
|
|
|
|
|
|
|
677 |
border-radius: 4px;
|
678 |
background-color: #f8f9fa;
|
679 |
-
}
|
680 |
-
.
|
681 |
border-left: 4px solid #FF6B6B;
|
682 |
-
}
|
683 |
-
.
|
684 |
border-left: 4px solid #4ECDC4;
|
685 |
-
}
|
686 |
-
.
|
687 |
font-weight: bold;
|
688 |
-
|
689 |
-
}
|
690 |
-
.
|
691 |
-
margin: 5px
|
692 |
-
}
|
693 |
-
.
|
694 |
font-size: 0.9em;
|
695 |
color: #666;
|
696 |
-
}
|
697 |
</style>
|
698 |
-
|
699 |
-
|
|
|
|
|
700 |
|
701 |
for item in st.session_state.recent_items:
|
702 |
-
if item['sentiment'] in ['Positive', 'Negative']:
|
703 |
sentiment_class = 'negative' if item['sentiment'] == 'Negative' else 'positive'
|
704 |
-
|
705 |
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
{f" | {event_info}" if event_info else ""}
|
713 |
-
| {item['time']}
|
714 |
-
</div>
|
715 |
-
</div>
|
716 |
"""
|
|
|
|
|
|
|
717 |
|
718 |
-
|
719 |
-
|
|
|
|
|
|
|
720 |
|
721 |
def _update_entity_view(self):
|
722 |
"""Update entity tab visualizations"""
|
@@ -1613,7 +1615,7 @@ def main():
|
|
1613 |
st.set_page_config(layout="wide")
|
1614 |
|
1615 |
with st.sidebar:
|
1616 |
-
st.title("::: AI-анализ мониторинга новостей (v.3.
|
1617 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
1618 |
|
1619 |
model_choice = st.radio(
|
|
|
647 |
|
648 |
def _update_recent_items(self, row, sentiment, event_type):
|
649 |
"""Update recent items display with custom styling"""
|
|
|
650 |
if 'recent_items' not in st.session_state:
|
651 |
st.session_state.recent_items = []
|
652 |
|
|
|
653 |
new_item = {
|
654 |
'entity': row['Объект'],
|
655 |
'headline': row['Заголовок'],
|
|
|
659 |
}
|
660 |
|
661 |
st.session_state.recent_items.insert(0, new_item)
|
|
|
662 |
st.session_state.recent_items = st.session_state.recent_items[:10]
|
663 |
|
664 |
+
# Custom CSS
|
665 |
+
st.markdown("""
|
666 |
<style>
|
667 |
+
.news-container {
|
668 |
max-height: 400px;
|
669 |
overflow-y: auto;
|
|
|
|
|
670 |
padding: 10px;
|
671 |
+
}
|
672 |
+
.news-item {
|
673 |
+
padding: 10px;
|
674 |
+
margin-bottom: 10px;
|
675 |
border-radius: 4px;
|
676 |
background-color: #f8f9fa;
|
677 |
+
}
|
678 |
+
.negative {
|
679 |
border-left: 4px solid #FF6B6B;
|
680 |
+
}
|
681 |
+
.positive {
|
682 |
border-left: 4px solid #4ECDC4;
|
683 |
+
}
|
684 |
+
.entity-name {
|
685 |
font-weight: bold;
|
686 |
+
margin-bottom: 5px;
|
687 |
+
}
|
688 |
+
.headline-text {
|
689 |
+
margin-bottom: 5px;
|
690 |
+
}
|
691 |
+
.meta-info {
|
692 |
font-size: 0.9em;
|
693 |
color: #666;
|
694 |
+
}
|
695 |
</style>
|
696 |
+
""", unsafe_allow_html=True)
|
697 |
+
|
698 |
+
# Build items display
|
699 |
+
items_display = "<div class='news-container'>"
|
700 |
|
701 |
for item in st.session_state.recent_items:
|
702 |
+
if item['sentiment'] in ['Positive', 'Negative']:
|
703 |
sentiment_class = 'negative' if item['sentiment'] == 'Negative' else 'positive'
|
704 |
+
event_text = f" | Событие: {item['event_type']}" if item['event_type'] != 'Нет' else ""
|
705 |
|
706 |
+
item_html = f"""
|
707 |
+
<div class='news-item {sentiment_class}'>
|
708 |
+
<div class='entity-name'>{item['entity']}</div>
|
709 |
+
<div class='headline-text'>{item['headline']}</div>
|
710 |
+
<div class='meta-info'>Тональность: {item['sentiment']}{event_text} | {item['time']}</div>
|
711 |
+
</div>
|
|
|
|
|
|
|
|
|
712 |
"""
|
713 |
+
items_display += item_html
|
714 |
+
|
715 |
+
items_display += "</div>"
|
716 |
|
717 |
+
# Display the items
|
718 |
+
try:
|
719 |
+
self.recent_items_container.markdown(items_display, unsafe_allow_html=True)
|
720 |
+
except Exception as e:
|
721 |
+
st.error(f"Error displaying recent items: {str(e)}")
|
722 |
|
723 |
def _update_entity_view(self):
|
724 |
"""Update entity tab visualizations"""
|
|
|
1615 |
st.set_page_config(layout="wide")
|
1616 |
|
1617 |
with st.sidebar:
|
1618 |
+
st.title("::: AI-анализ мониторинга новостей (v.3.75):::")
|
1619 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
1620 |
|
1621 |
model_choice = st.radio(
|