Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
# =====================================================
|
| 5 |
-
# 1. إعداد الصفحة والتصميم المتقدم (CSS)
|
| 6 |
# =====================================================
|
| 7 |
st.set_page_config(
|
| 8 |
page_title="Big Data Hero 🤖",
|
|
@@ -32,7 +32,7 @@ html, body, [class*="css"] {
|
|
| 32 |
margin-bottom: 20px;
|
| 33 |
}
|
| 34 |
|
| 35 |
-
/* رسالة الترحيب الثابتة
|
| 36 |
.welcome-box {
|
| 37 |
background: #111827;
|
| 38 |
padding: 20px;
|
|
@@ -71,12 +71,32 @@ html, body, [class*="css"] {
|
|
| 71 |
text-align: right;
|
| 72 |
}
|
| 73 |
|
| 74 |
-
/*
|
| 75 |
div[data-testid="stTextInput"] > div {
|
|
|
|
| 76 |
border: 2px solid #00f2ff !important;
|
| 77 |
border-radius: 12px !important;
|
| 78 |
-
box-shadow: 0 0
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
}
|
| 81 |
|
| 82 |
/* تخصيص أزرار القائمة الجانبية */
|
|
@@ -107,7 +127,7 @@ section[data-testid="stSidebar"] {
|
|
| 107 |
|
| 108 |
.sidebar-heading {
|
| 109 |
color: #ffd700;
|
| 110 |
-
font-size:
|
| 111 |
font-weight: bold;
|
| 112 |
margin-top: 15px;
|
| 113 |
margin-bottom: 10px;
|
|
@@ -252,7 +272,7 @@ if "chat_history" not in st.session_state:
|
|
| 252 |
# =====================================================
|
| 253 |
st.markdown('<div class="main-title">🤖 Big Data Hero</div>', unsafe_allow_html=True)
|
| 254 |
|
| 255 |
-
# إخفاء رسالة الترحيب العلوية
|
| 256 |
if st.session_state.display_content == "chat" and len(st.session_state.chat_history) == 0:
|
| 257 |
st.markdown("""
|
| 258 |
<div class="welcome-box">
|
|
@@ -260,9 +280,8 @@ if st.session_state.display_content == "chat" and len(st.session_state.chat_hist
|
|
| 260 |
</div>
|
| 261 |
""", unsafe_allow_html=True)
|
| 262 |
|
| 263 |
-
# القناة الأولى: الشات بوت التفاعلي الحر (بدون كلمة المحادثة الفورية)
|
| 264 |
if st.session_state.display_content == "chat":
|
| 265 |
-
# تم حذف جملة "المحادثة الفورية الذكية" تماماً من هنا بناءً على طلبك لشاشة دخول أنيقة
|
| 266 |
for msg in st.session_state.chat_history:
|
| 267 |
if msg["role"] == "user":
|
| 268 |
st.markdown(f'<div class="chat-bubble chat-user">👤 أنت: {msg["text"]}</div>', unsafe_allow_html=True)
|
|
@@ -272,7 +291,7 @@ if st.session_state.display_content == "chat":
|
|
| 272 |
if len(st.session_state.chat_history) > 0:
|
| 273 |
st.markdown("---")
|
| 274 |
|
| 275 |
-
# حقل الإدخال
|
| 276 |
user_query = st.text_input("👇 اكتب سؤالك هنا بخصوص البيانات الضخمة وسأجيبك فوراً...", key="chat_input")
|
| 277 |
|
| 278 |
if st.button("🚀 إرسال السؤال والتحليل"):
|
|
@@ -287,11 +306,11 @@ if st.session_state.display_content == "chat":
|
|
| 287 |
st.session_state.chat_history.append({"role": "bot", "text": reply})
|
| 288 |
st.rerun()
|
| 289 |
|
| 290 |
-
# القناة الثانية: عرض محتوى الأزرار الجانبية
|
| 291 |
elif st.session_state.display_content in DATA:
|
| 292 |
st.markdown(f'<div class="chat-bubble chat-bot" style="max-width:100%;">{DATA[st.session_state.display_content]}</div>', unsafe_allow_html=True)
|
| 293 |
|
| 294 |
-
# القناة الثالثة: اختبار التحدي مع تأثير البالونات
|
| 295 |
elif st.session_state.display_content == "quiz":
|
| 296 |
st.markdown("### 🎯 التحدي والاختبار الذكي:")
|
| 297 |
if st.session_state.quiz_index < len(QUIZ_DATA):
|
|
@@ -309,12 +328,12 @@ elif st.session_state.display_content == "quiz":
|
|
| 309 |
st.session_state.quiz_index += 1
|
| 310 |
st.rerun()
|
| 311 |
else:
|
| 312 |
-
# ال
|
| 313 |
if st.session_state.score == len(QUIZ_DATA):
|
| 314 |
st.balloons()
|
| 315 |
-
st.
|
| 316 |
else:
|
| 317 |
-
st.
|
| 318 |
|
| 319 |
if st.button("🔄 إعادة خوض التحدي من جديد"):
|
| 320 |
st.session_state.quiz_index = 0
|
|
@@ -334,11 +353,13 @@ elif st.session_state.display_content == "stats":
|
|
| 334 |
st.bar_chart(chart_data)
|
| 335 |
|
| 336 |
# =====================================================
|
| 337 |
-
# 6. عناصر وتصميم القائمة الجانبية (Sidebar)
|
| 338 |
# =====================================================
|
| 339 |
with st.sidebar:
|
| 340 |
st.markdown('<div class="sidebar-heading">🏆 لوحة أبطال المستقبل</div>', unsafe_allow_html=True)
|
| 341 |
-
|
|
|
|
|
|
|
| 342 |
st.markdown("---")
|
| 343 |
|
| 344 |
if st.button("💬 فتح الشات التفاعلي الحر"):
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
# =====================================================
|
| 5 |
+
# 1. إعداد الصفحة والتصميم المتقدم (CSS المحدث)
|
| 6 |
# =====================================================
|
| 7 |
st.set_page_config(
|
| 8 |
page_title="Big Data Hero 🤖",
|
|
|
|
| 32 |
margin-bottom: 20px;
|
| 33 |
}
|
| 34 |
|
| 35 |
+
/* رسالة الترحيب الثابتة التفاعلية */
|
| 36 |
.welcome-box {
|
| 37 |
background: #111827;
|
| 38 |
padding: 20px;
|
|
|
|
| 71 |
text-align: right;
|
| 72 |
}
|
| 73 |
|
| 74 |
+
/* حل مشكلة المستطيل الأبيض: تخصيص صندوق إدخال النصوص بلون داكن وهوامش مضيئة */
|
| 75 |
div[data-testid="stTextInput"] > div {
|
| 76 |
+
background-color: #0d1117 !important;
|
| 77 |
border: 2px solid #00f2ff !important;
|
| 78 |
border-radius: 12px !important;
|
| 79 |
+
box-shadow: 0 0 15px rgba(0, 242, 255, 0.4) !important;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* ضبط لون النص المكتوب داخل صندوق الإدخال ليكون أبيض وواضح دائماً */
|
| 83 |
+
div[data-testid="stTextInput"] input {
|
| 84 |
+
color: white !important;
|
| 85 |
+
font-size: 16px !important;
|
| 86 |
+
direction: rtl !important;
|
| 87 |
+
text-align: right !important;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/* تخصيص وتكبير خط النتيجة واللوحة الجانبية لتكون بولد وواضحة جداً */
|
| 91 |
+
.score-text {
|
| 92 |
+
color: #ffd700 !important;
|
| 93 |
+
font-size: 24px !important;
|
| 94 |
+
font-weight: 900 !important;
|
| 95 |
+
text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
|
| 96 |
+
margin-top: 5px;
|
| 97 |
+
margin-bottom: 15px;
|
| 98 |
+
direction: rtl;
|
| 99 |
+
text-align: right;
|
| 100 |
}
|
| 101 |
|
| 102 |
/* تخصيص أزرار القائمة الجانبية */
|
|
|
|
| 127 |
|
| 128 |
.sidebar-heading {
|
| 129 |
color: #ffd700;
|
| 130 |
+
font-size: 20px;
|
| 131 |
font-weight: bold;
|
| 132 |
margin-top: 15px;
|
| 133 |
margin-bottom: 10px;
|
|
|
|
| 272 |
# =====================================================
|
| 273 |
st.markdown('<div class="main-title">🤖 Big Data Hero</div>', unsafe_allow_html=True)
|
| 274 |
|
| 275 |
+
# إخفاء رسالة الترحيب العلوية بمجرد الضغط على أي أيقونة أو بدء محادثة لمنع الزحام
|
| 276 |
if st.session_state.display_content == "chat" and len(st.session_state.chat_history) == 0:
|
| 277 |
st.markdown("""
|
| 278 |
<div class="welcome-box">
|
|
|
|
| 280 |
</div>
|
| 281 |
""", unsafe_allow_html=True)
|
| 282 |
|
| 283 |
+
# القناة الأولى: الشات بوت التفاعلي الحر (معدل بدون كلمة المحادثة الفورية وبمستطيل مظلم مميز)
|
| 284 |
if st.session_state.display_content == "chat":
|
|
|
|
| 285 |
for msg in st.session_state.chat_history:
|
| 286 |
if msg["role"] == "user":
|
| 287 |
st.markdown(f'<div class="chat-bubble chat-user">👤 أنت: {msg["text"]}</div>', unsafe_allow_html=True)
|
|
|
|
| 291 |
if len(st.session_state.chat_history) > 0:
|
| 292 |
st.markdown("---")
|
| 293 |
|
| 294 |
+
# حقل الإدخال الذكي بالمظهر الداكن المعزز لـ جينالي
|
| 295 |
user_query = st.text_input("👇 اكتب سؤالك هنا بخصوص البيانات الضخمة وسأجيبك فوراً...", key="chat_input")
|
| 296 |
|
| 297 |
if st.button("🚀 إرسال السؤال والتحليل"):
|
|
|
|
| 306 |
st.session_state.chat_history.append({"role": "bot", "text": reply})
|
| 307 |
st.rerun()
|
| 308 |
|
| 309 |
+
# القناة الثانية: عرض محتوى الأزرار الجانبية للمواضيع
|
| 310 |
elif st.session_state.display_content in DATA:
|
| 311 |
st.markdown(f'<div class="chat-bubble chat-bot" style="max-width:100%;">{DATA[st.session_state.display_content]}</div>', unsafe_allow_html=True)
|
| 312 |
|
| 313 |
+
# القناة الثالثة: اختبار التحدي مع تأثير البالونات الحصري فقط عند قفل الدرجة 5 من 5
|
| 314 |
elif st.session_state.display_content == "quiz":
|
| 315 |
st.markdown("### 🎯 التحدي والاختبار الذكي:")
|
| 316 |
if st.session_state.quiz_index < len(QUIZ_DATA):
|
|
|
|
| 328 |
st.session_state.quiz_index += 1
|
| 329 |
st.rerun()
|
| 330 |
else:
|
| 331 |
+
# الميزة المطلوبة: إطلاق البالونات فقط عند الحصول على النتيجة الكاملة 5 من 5 بالتمام
|
| 332 |
if st.session_state.score == len(QUIZ_DATA):
|
| 333 |
st.balloons()
|
| 334 |
+
st.markdown(f'<div class="score-text" style="color: #00f2ff !important; text-align: center;">🏆 خارق ومذهل يا بطل الأبطال! حصلت على الدرجة النهائية الكاملة: {st.session_state.score} من {len(QUIZ_DATA)} 🔥🎈</div>', unsafe_allow_html=True)
|
| 335 |
else:
|
| 336 |
+
st.markdown(f'<div class="score-text" style="text-align: center;">🏆 مبروك يا بطل! أنهيت الاختبار بنتيجة: {st.session_state.score} من {len(QUIZ_DATA)}</div>', unsafe_allow_html=True)
|
| 337 |
|
| 338 |
if st.button("🔄 إعادة خوض التحدي من جديد"):
|
| 339 |
st.session_state.quiz_index = 0
|
|
|
|
| 353 |
st.bar_chart(chart_data)
|
| 354 |
|
| 355 |
# =====================================================
|
| 356 |
+
# 6. عناصر وتصميم القائمة الجانبية (Sidebar المحدث بخط عريض وكبير)
|
| 357 |
# =====================================================
|
| 358 |
with st.sidebar:
|
| 359 |
st.markdown('<div class="sidebar-heading">🏆 لوحة أبطال المستقبل</div>', unsafe_allow_html=True)
|
| 360 |
+
|
| 361 |
+
# عرض الـ Score بخط بولد، ضخم، وبألوان واضحة تماماً لا تختفي داخل جينالي
|
| 362 |
+
st.markdown(f'<div class="score-text">⭐ مجموع نقاطك الحالية: {st.session_state.score}</div>', unsafe_allow_html=True)
|
| 363 |
st.markdown("---")
|
| 364 |
|
| 365 |
if st.button("💬 فتح الشات التفاعلي الحر"):
|