Spaces:
Running
Running
Commit ·
027d010
1
Parent(s): da61e92
4.0
Browse files
app.py
CHANGED
|
@@ -650,6 +650,7 @@ class ProcessingUI:
|
|
| 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,66 +660,40 @@ class ProcessingUI:
|
|
| 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 |
-
#
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 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,7 +1590,7 @@ def main():
|
|
| 1615 |
st.set_page_config(layout="wide")
|
| 1616 |
|
| 1617 |
with st.sidebar:
|
| 1618 |
-
st.title("::: AI-анализ мониторинга новостей (v.
|
| 1619 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
| 1620 |
|
| 1621 |
model_choice = st.radio(
|
|
|
|
| 650 |
if 'recent_items' not in st.session_state:
|
| 651 |
st.session_state.recent_items = []
|
| 652 |
|
| 653 |
+
# Add new item to the list
|
| 654 |
new_item = {
|
| 655 |
'entity': row['Объект'],
|
| 656 |
'headline': row['Заголовок'],
|
|
|
|
| 660 |
}
|
| 661 |
|
| 662 |
st.session_state.recent_items.insert(0, new_item)
|
| 663 |
+
st.session_state.recent_items = st.session_state.recent_items[:10] # Keep last 10 items
|
| 664 |
|
| 665 |
+
# Instead of using HTML, use Streamlit's native markdown with custom formatting
|
| 666 |
+
with self.recent_items_container:
|
| 667 |
+
# Clear previous content
|
| 668 |
+
st.empty()
|
| 669 |
+
|
| 670 |
+
# Display each item using Streamlit's native components
|
| 671 |
+
for item in st.session_state.recent_items:
|
| 672 |
+
if item['sentiment'] in ['Positive', 'Negative']:
|
| 673 |
+
# Create color and style based on sentiment
|
| 674 |
+
color = "#FF6B6B" if item['sentiment'] == 'Negative' else "#4ECDC4"
|
| 675 |
+
|
| 676 |
+
# Use markdown with custom styling
|
| 677 |
+
st.markdown(
|
| 678 |
+
f"""
|
| 679 |
+
<div style='
|
| 680 |
+
padding: 10px;
|
| 681 |
+
margin-bottom: 10px;
|
| 682 |
+
border-radius: 4px;
|
| 683 |
+
background-color: #f8f9fa;
|
| 684 |
+
border-left: 4px solid {color};
|
| 685 |
+
'>
|
| 686 |
+
<div style='font-weight: bold;'>{item['entity']}</div>
|
| 687 |
+
<div style='margin: 5px 0;'>{item['headline']}</div>
|
| 688 |
+
<div style='font-size: 0.9em; color: #666;'>
|
| 689 |
+
Тональность: {item['sentiment']}
|
| 690 |
+
{f" | Событие: {item['event_type']}" if item['event_type'] != 'Нет' else ""}
|
| 691 |
+
| {item['time']}
|
| 692 |
+
</div>
|
| 693 |
+
</div>
|
| 694 |
+
""",
|
| 695 |
+
unsafe_allow_html=True
|
| 696 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 697 |
|
| 698 |
def _update_entity_view(self):
|
| 699 |
"""Update entity tab visualizations"""
|
|
|
|
| 1590 |
st.set_page_config(layout="wide")
|
| 1591 |
|
| 1592 |
with st.sidebar:
|
| 1593 |
+
st.title("::: AI-анализ мониторинга новостей (v.4.0):::")
|
| 1594 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
| 1595 |
|
| 1596 |
model_choice = st.radio(
|