File size: 26,635 Bytes
4a93bef
 
 
 
 
 
0b64664
4a93bef
 
 
0b64664
4a93bef
 
0eacf5f
4a93bef
0eacf5f
4a93bef
0eacf5f
 
 
 
 
 
 
 
 
 
6ca2cf0
0b64664
0eacf5f
 
1fe29a0
0eacf5f
1fe29a0
0eacf5f
1fe29a0
 
0eacf5f
 
1fe29a0
0eacf5f
 
 
 
 
1fe29a0
0eacf5f
 
1fe29a0
 
 
 
0b64664
6ca2cf0
0eacf5f
6ca2cf0
1fe29a0
6ca2cf0
1fe29a0
 
 
 
 
 
 
 
 
 
 
0eacf5f
1fe29a0
0eacf5f
0b64664
1fe29a0
0b64664
1fe29a0
 
 
 
 
0b64664
1fe29a0
0b64664
1fe29a0
0b64664
 
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b64664
1fe29a0
 
 
 
 
 
 
0b64664
1fe29a0
 
 
 
 
 
 
 
 
 
 
0b64664
1fe29a0
 
 
 
 
 
 
0b64664
1fe29a0
 
 
 
0b64664
1fe29a0
0b64664
 
 
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b64664
0eacf5f
 
1fe29a0
0eacf5f
4a93bef
1fe29a0
 
4a93bef
1fe29a0
4a93bef
 
 
 
0b64664
4a93bef
 
 
 
 
 
1fe29a0
 
4a93bef
1fe29a0
4a93bef
 
 
 
 
 
 
 
 
 
 
1fe29a0
 
4a93bef
1fe29a0
4a93bef
 
 
 
 
 
 
 
 
 
 
1fe29a0
 
4a93bef
1fe29a0
4a93bef
 
 
 
 
 
 
 
 
 
 
1fe29a0
 
4a93bef
1fe29a0
4a93bef
 
 
 
0b64664
4a93bef
 
 
 
 
 
 
6ca2cf0
0b64664
1fe29a0
 
4a93bef
1fe29a0
 
 
 
 
 
 
6ca2cf0
1fe29a0
4a93bef
 
 
 
 
 
 
0eacf5f
 
1fe29a0
 
 
 
 
 
0eacf5f
4a93bef
0eacf5f
4a93bef
 
 
1fe29a0
 
 
 
 
 
 
4a93bef
 
 
1fe29a0
 
 
 
4a93bef
0eacf5f
1fe29a0
 
 
 
 
4a93bef
 
 
1fe29a0
4a93bef
0b64664
1fe29a0
 
 
 
 
 
0b64664
 
4a93bef
1fe29a0
0eacf5f
1fe29a0
 
 
 
4a93bef
 
 
0b64664
4a93bef
 
 
 
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
4a93bef
 
 
 
 
 
1fe29a0
4a93bef
1fe29a0
 
 
 
 
 
 
 
4a93bef
 
 
 
 
 
 
 
 
 
 
1fe29a0
4a93bef
1fe29a0
 
 
 
 
 
 
 
4a93bef
 
 
 
 
 
 
 
 
 
 
1fe29a0
4a93bef
 
 
0b64664
4a93bef
 
1fe29a0
 
4a93bef
 
 
 
 
1fe29a0
 
4a93bef
 
 
 
 
1fe29a0
 
4a93bef
 
 
 
 
1fe29a0
 
4a93bef
 
 
 
 
1fe29a0
 
4a93bef
 
 
 
 
 
0b64664
1fe29a0
0b64664
 
 
 
1fe29a0
 
0b64664
 
 
 
 
1fe29a0
 
0b64664
 
 
 
 
1fe29a0
0b64664
1fe29a0
0b64664
 
1fe29a0
 
 
 
 
 
0b64664
 
 
 
 
 
 
 
 
 
4a93bef
 
 
0b64664
4a93bef
 
 
 
 
0b64664
 
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b64664
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a93bef
0b64664
 
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b64664
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a93bef
 
 
1fe29a0
4a93bef
 
 
 
 
 
 
1fe29a0
 
4a93bef
 
 
 
1fe29a0
 
4a93bef
 
 
 
1fe29a0
 
4a93bef
 
 
 
1fe29a0
 
4a93bef
 
 
 
1fe29a0
 
4a93bef
 
 
 
1fe29a0
 
4a93bef
 
 
1fe29a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a93bef
 
 
0b64664
4a93bef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1fe29a0
4a93bef
 
 
1fe29a0
4a93bef
1fe29a0
 
 
4a93bef
 
1fe29a0
4a93bef
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
import streamlit as st
import os
from supabase import create_client, Client
from datetime import datetime
import json

# Thiết lập page config
st.set_page_config(
    page_title="Multi-Agent System - Gia sư Toán AI",
    page_icon="🤖",
    layout="wide"
)

def init_supabase_client() -> Client:
    """
    Khởi tạo Supabase client
    """
    url = os.getenv("SUPABASE_URL")
    key = os.getenv("SUPABASE_KEY")
    
    if not url or not key:
        st.error("Không tìm thấy SUPABASE_URL hoặc SUPABASE_KEY trong file .env")
        st.stop()
    
    return create_client(url, key)

def display_system_architecture():
    """
    Hiển thị kiến trúc hệ thống
    """
    st.markdown("""
    <div style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
                padding: 2rem; 
                border-radius: 15px; 
                margin-bottom: 2rem;
                text-align: center;'>
        <h1 style='color: white; margin-bottom: 1rem; font-size: 2.5rem;'>
            🤖 An Adaptive Multi-Agent Tutoring System
        </h1>
        <p style='color: #f0f0f0; font-size: 1.2rem; margin-bottom: 0;'>
            Hệ thống gia sư thông minh với kiến trúc đa tác nhân thích ứng
        </p>
    </div>
    """, unsafe_allow_html=True)
    
    # Placeholder cho hình ảnh system architecture
    st.markdown("### 📊 Kiến trúc Hệ thống")
    
    # Container cho hình ảnh với styling đẹp
    with st.container():
        col1, col2, col3 = st.columns([1, 3, 1])
        with col2:
            st.image("images/system.jpg", use_container_width=True)

def display_agents():
    """
    Hiển thị chi tiết từng Agent với giao diện được tối ưu hóa
    """
    # Header section
    st.markdown("""
    <div style="margin: 3rem 0 2rem 0;">
        <h2 style="text-align: center; color: #333; margin-bottom: 0.5rem; font-size: 2.5rem;">
            🤖 Chi tiết các AI Agents
        </h2>
        <p style="text-align: center; color: #666; font-size: 1.1rem; margin-bottom: 2rem;">
            Khám phá hệ sinh thái AI agents thông minh và chuyên biệt
        </p>
    </div>
    """, unsafe_allow_html=True)
    
    # CSS được tối ưu hóa - loại bỏ các effect phức tạp
    st.markdown("""
    <style>
    .agent-container {
        background: white;
        border-radius: 15px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        margin-bottom: 2rem;
        overflow: hidden;
        border: 1px solid rgba(0,0,0,0.05);
    }
    
    .agent-header {
        padding: 2rem;
        color: white;
    }
    
    .agent-title {
        display: flex;
        align-items: center;
        margin-bottom: 1rem;
        font-size: 1.8rem;
        font-weight: 600;
    }
    
    .agent-title-icon {
        font-size: 2.5rem;
        margin-right: 1rem;
    }
    
    .agent-role {
        background: rgba(255,255,255,0.2);
        padding: 1rem;
        border-radius: 10px;
        font-size: 1.1rem;
        border: 1px solid rgba(255,255,255,0.2);
    }
    
    .agent-body {
        padding: 2rem;
        background: #fafafa;
    }
    
    .agent-features {
        background: white;
        border-radius: 12px;
        padding: 1.5rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        border: 1px solid rgba(0,0,0,0.05);
    }
    
    .features-title {
        display: flex;
        align-items: center;
        margin-bottom: 1.5rem;
        font-size: 1.3rem;
        font-weight: 600;
        color: #333;
    }
    
    .features-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .feature-item {
        padding: 0.8rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        display: flex;
        align-items: flex-start;
    }
    
    .feature-item:last-child {
        border-bottom: none;
    }
    
    .feature-bullet {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin-right: 1rem;
        margin-top: 0.5rem;
        flex-shrink: 0;
    }
    
    .feature-text {
        flex: 1;
        line-height: 1.6;
    }
    
    .feature-name {
        font-weight: 600;
        margin-right: 0.5rem;
    }
    
    .image-placeholder {
        background: rgba(255,255,255,0.9);
        border: 2px dashed #ddd;
        border-radius: 12px;
        padding: 2rem;
        text-align: center;
        height: 250px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    .placeholder-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
        opacity: 0.7;
    }
    
    .placeholder-text {
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: #333;
    }
    
    .placeholder-path {
        font-size: 0.9rem;
        color: #666;
        font-family: monospace;
        background: rgba(0,0,0,0.05);
        padding: 0.3rem 0.8rem;
        border-radius: 15px;
    }
    </style>
    """, unsafe_allow_html=True)
    
    # Định nghĩa thông tin các agents
    agents = [
        {
            "number": "1",
            "name": "Informer Agent",
            "icon": "🧠",
            "gradient": "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
            "color": "#667eea",
            "role": "Chuyên gia giải toán với khả năng truy xuất thông tin thông minh",
            "image": "images/informer_agent.png",
            "features": [
                "RAG Pipeline: Sử dụng Retrieval-Augmented Generation để tìm kiếm thông tin từ sách giáo khoa",
                "Embedding Search: Tìm kiếm ngữ nghĩa thông minh với Vietnamese bi-encoder",
                "Detailed Solutions: Sinh lời giải chi tiết, từng bước dễ hiểu",
                "Context Awareness: Hiểu ngữ cảnh câu hỏi để đưa ra câu trả lời phù hợp"
            ]
        },
        {
            "number": "2",
            "name": "Practice Agent",
            "icon": "📝",
            "gradient": "linear-gradient(135deg, #f093fb 0%, #f5576c 100%)",
            "color": "#f093fb",
            "role": "Chuyên gia tạo bài tập và đề xuất tài liệu học tập",
            "image": "images/practice_agent.png",
            "features": [
                "Exercise Generation: Tạo bài tập mới phù hợp với điểm yếu của học sinh",
                "Video Recommendation: Đề xuất video học tập từ knowledge base",
                "Adaptive Difficulty: Điều chỉnh độ khó bài tập theo trình độ",
                "Creative Problems: Soạn câu hỏi sáng tạo, không có trong sách"
            ]
        },
        {
            "number": "3",
            "name": "Insight Agent",
            "icon": "🔍",
            "gradient": "linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",
            "color": "#4facfe",
            "role": "Chuyên gia phân tích tâm lý và học tập của học sinh",
            "image": "images/insight_agent.png",
            "features": [
                "Weakness Analysis: Phân tích điểm yếu từ lịch sử hội thoại",
                "Sentiment Detection: Nhận diện cảm xúc và tâm trạng học sinh",
                "Learning Pattern: Phát hiện patterns trong cách học của học sinh",
                "Personalized Insights: Đưa ra những insight cá nhân hóa"
            ]
        },
        {
            "number": "4",
            "name": "Verifier Agent",
            "icon": "✅",
            "gradient": "linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)",
            "color": "#a8edea",
            "role": "Chuyên gia kiểm tra chất lượng và tính chính xác",
            "image": "images/verifier_agent.png",
            "features": [
                "Solution Verification: Kiểm tra tính đúng đắn của lời giải",
                "Error Detection: Phát hiện và chỉ ra lỗi sai",
                "Quality Assurance: Đảm bảo chất lượng câu trả lời",
                "Correction Suggestions: Đưa ra gợi ý sửa lỗi"
            ]
        },
        {
            "number": "5",
            "name": "Tutor Agent (Orchestrator)",
            "icon": "🎯",
            "gradient": "linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%)",
            "color": "#fcb69f",
            "role": "Trung tâm điều phối và quản lý toàn bộ hệ thống",
            "image": "images/tutor_agent.png",
            "features": [
                "Intent Classification: Phân loại ý định người dùng (greeting, math_question, practice, stress, etc.)",
                "Agent Orchestration: Điều phối các agent khác theo luồng phù hợp",
                "Conversation Management: Quản lý bối cảnh và luồng hội thoại",
                "Proactive Learning: Chủ động đề xuất bài tập khi phát hiện cơ hội",
                "Emotional Support: Hỗ trợ tâm lý khi học sinh gặp khó khăn"
            ]
        }
    ]
    
    # Hiển thị từng agent
    for i, agent in enumerate(agents):
        # Container chính
        st.markdown(f"""
        <div class="agent-container">
            <div class="agent-header" style="background: {agent['gradient']};">
                <div class="agent-title">
                    <span class="agent-title-icon">{agent['icon']}</span>
                    <span>Agent {agent['number']}: {agent['name']}</span>
                </div>
                <div class="agent-role">
                    <strong>Vai trò:</strong> {agent['role']}
                </div>
            </div>
        """, unsafe_allow_html=True)
        
        # Body với layout 2 cột
        col1, col2 = st.columns([2, 1])
        
        with col1:
            st.markdown(f"""
            <div class="agent-body">
                <div class="agent-features">
                    <div class="features-title">
                        <span style="margin-right: 0.5rem;">🔧</span>
                        <span>Chức năng chính</span>
                    </div>
                    <ul class="features-list">
            """, unsafe_allow_html=True)
            
            for feature in agent['features']:
                parts = feature.split(': ', 1)
                if len(parts) == 2:
                    st.markdown(f"""
                    <li class="feature-item">
                        <div class="feature-bullet" style="background: {agent['color']};"></div>
                        <div class="feature-text">
                            <span class="feature-name" style="color: {agent['color']};">{parts[0]}:</span>
                            <span>{parts[1]}</span>
                        </div>
                    </li>
                    """, unsafe_allow_html=True)
                else:
                    st.markdown(f"""
                    <li class="feature-item">
                        <div class="feature-bullet" style="background: {agent['color']};"></div>
                        <div class="feature-text">{feature}</div>
                    </li>
                    """, unsafe_allow_html=True)
            
            st.markdown("""
                    </ul>
                </div>
            </div>
            """, unsafe_allow_html=True)
        
        with col2:
            try:
                st.image(agent['image'], use_container_width=True, caption=f"Agent {agent['number']}: {agent['name']}")
            except:
                st.markdown(f"""
                <div class="agent-body">
                    <div class="image-placeholder">
                        <div class="placeholder-icon" style="color: {agent['color']};">{agent['icon']}</div>
                        <div class="placeholder-text">Agent {agent['number']} Image</div>
                        <div class="placeholder-path">{agent['image']}</div>
                    </div>
                </div>
                """, unsafe_allow_html=True)
        
        # Đóng container
        st.markdown("</div>", unsafe_allow_html=True)
        
        # Spacing giữa các agents
        if i < len(agents) - 1:
            st.markdown("<div style='margin: 2rem 0;'></div>", unsafe_allow_html=True)

def display_system_components():
    """
    Hiển thị các thành phần của hệ thống
    """
    st.markdown("## 🏗️ Các Thành phần Hệ thống")
    
    # Orchestration Hub
    with st.container():
        st.markdown("""
        <div style='background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h3 style='color: white; margin-bottom: 0.5rem;'>
                🎯 Orchestration Hub
            </h3>
            <p style='color: #f0f0f0; margin-bottom: 0;'>
                Trung tâm điều phối và quản lý tất cả các tác nhân trong hệ thống
            </p>
        </div>
        """, unsafe_allow_html=True)
    
    # Hai flows chính
    col1, col2 = st.columns(2)
    
    with col1:
        st.markdown("""
        <div style='background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h3 style='color: #8B0000; margin-bottom: 1rem;'>
                📝 Flow A: Problem-Solving
            </h3>
            <div style='background: rgba(255,255,255,0.2); padding: 1rem; border-radius: 8px;'>
                <h4 style='color: #8B0000; margin-bottom: 0.5rem;'>RAG & Verification</h4>
                <ul style='color: #2F4F4F; margin-bottom: 0;'>
                    <li>Xử lý truy vấn RAG</li>
                    <li>Giải quyết yêu cầu</li>
                    <li>Xác thực và soạn thảo</li>
                    <li>Cung cấp câu trả lời cuối cùng</li>
                </ul>
            </div>
        </div>
        """, unsafe_allow_html=True)
    
    with col2:
        st.markdown("""
        <div style='background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h3 style='color: #2F4F4F; margin-bottom: 1rem;'>
                🎯 Flow B: Personalization
            </h3>
            <div style='background: rgba(255,255,255,0.2); padding: 1rem; border-radius: 8px;'>
                <h4 style='color: #2F4F4F; margin-bottom: 0.5rem;'>Learning Engine</h4>
                <ul style='color: #2F4F4F; margin-bottom: 0;'>
                    <li>Phân tích thông tin người dùng</li>
                    <li>Gửi chủ đề phù hợp</li>
                    <li>Truy vấn dữ liệu</li>
                    <li>Tạo bài tập cá nhân hóa</li>
                </ul>
            </div>
        </div>
        """, unsafe_allow_html=True)

def display_workflow_details():
    """
    Hiển thị chi tiết quy trình làm việc - được tối ưu hóa
    """
    st.markdown("## 🔄 Quy trình Hoạt động")
    
    # Workflow steps
    workflow_steps = [
        {
            "step": "1",
            "title": "Nhận câu hỏi từ học sinh",
            "description": "Hệ thống nhận và phân tích câu hỏi từ người dùng",
            "icon": "❓",
            "color": "#FF6B6B"
        },
        {
            "step": "2", 
            "title": "Orchestration Hub phân tích",
            "description": "Trung tâm điều phối quyết định luồng xử lý phù hợp",
            "icon": "🎯",
            "color": "#4ECDC4"
        },
        {
            "step": "3",
            "title": "Xử lý song song",
            "description": "Flow A giải quyết vấn đề, Flow B cá nhân hóa trải nghiệm",
            "icon": "⚡",
            "color": "#45B7D1"
        },
        {
            "step": "4",
            "title": "Cập nhật hồ sơ học sinh",
            "description": "Hệ thống cập nhật thông tin học tập và điểm yếu",
            "icon": "📊",
            "color": "#96CEB4"
        },
        {
            "step": "5",
            "title": "Trả lời cuối cùng",
            "description": "Cung cấp câu trả lời được xác thực và cá nhân hóa",
            "icon": "✅",
            "color": "#FECA57"
        }
    ]
    
    for i, step in enumerate(workflow_steps):
        # Tạo layout cho từng bước
        col1, col2 = st.columns([1, 4])
        
        with col1:
            st.markdown(f"""
            <div style='width: 70px; 
                        height: 70px; 
                        background: {step['color']}; 
                        border-radius: 50%; 
                        display: flex; 
                        align-items: center; 
                        justify-content: center; 
                        margin: 0 auto;'>
                <span style='font-size: 1.8rem;'>{step['icon']}</span>
            </div>
            """, unsafe_allow_html=True)
        
        with col2:
            st.markdown(f"""
            <div style='background: {step['color']}20; 
                        padding: 1rem; 
                        border-radius: 10px; 
                        margin-bottom: 1rem;
                        border-left: 4px solid {step['color']};'>
                <h4 style='color: #333; margin-bottom: 0.5rem;'>
                    Bước {step['step']}: {step['title']}
                </h4>
                <p style='color: #666; margin-bottom: 0;'>
                    {step['description']}
                </p>
            </div>
            """, unsafe_allow_html=True)
        
        # Thêm mũi tên giữa các bước (trừ bước cuối)
        if i < len(workflow_steps) - 1:
            st.markdown("""
            <div style='text-align: center; margin: 1rem 0;'>
                <span style='font-size: 1.5rem; color: #ccc;'>⬇️</span>
            </div>
            """, unsafe_allow_html=True)

def display_technical_features():
    """
    Hiển thị các tính năng kỹ thuật
    """
    st.markdown("## 🛠️ Tính năng Kỹ thuật")
    
    col1, col2 = st.columns(2)
    
    with col1:
        st.markdown("""
        <div style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h4 style='color: white; margin-bottom: 1rem;'>
                🔍 RAG (Retrieval-Augmented Generation)
            </h4>
            <ul style='color: #f0f0f0; margin-bottom: 0;'>
                <li>Truy xuất thông tin từ cơ sở dữ liệu</li>
                <li>Tăng cường khả năng sinh text</li>
                <li>Đảm bảo tính chính xác cao</li>
                <li>Xác thực câu trả lời</li>
            </ul>
        </div>
        """, unsafe_allow_html=True)
        
        st.markdown("""
        <div style='background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h4 style='color: white; margin-bottom: 1rem;'>
                🎯 Personalization Engine
            </h4>
            <ul style='color: #f0f0f0; margin-bottom: 0;'>
                <li>Phân tích điểm yếu học sinh</li>
                <li>Tạo bài tập cá nhân hóa</li>
                <li>Theo dõi tiến độ học tập</li>
                <li>Đề xuất nội dung phù hợp</li>
            </ul>
        </div>
        """, unsafe_allow_html=True)
    
    with col2:
        st.markdown("""
        <div style='background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h4 style='color: white; margin-bottom: 1rem;'>
                🧠 Adaptive Learning
            </h4>
            <ul style='color: #f0f0f0; margin-bottom: 0;'>
                <li>Học thích ứng theo năng lực</li>
                <li>Điều chỉnh độ khó tự động</li>
                <li>Phản hồi thời gian thực</li>
                <li>Tối ưu hóa trải nghiệm</li>
            </ul>
        </div>
        """, unsafe_allow_html=True)
        
        st.markdown("""
        <div style='background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); 
                    padding: 1.5rem; 
                    border-radius: 10px; 
                    margin-bottom: 1rem;'>
            <h4 style='color: white; margin-bottom: 1rem;'>
                📊 User Profile Management
            </h4>
            <ul style='color: #f0f0f0; margin-bottom: 0;'>
                <li>Lưu trữ lịch sử học tập</li>
                <li>Phân tích pattern học tập</li>
                <li>Cập nhật thông tin real-time</li>
                <li>Báo cáo tiến độ chi tiết</li>
            </ul>
        </div>
        """, unsafe_allow_html=True)

def display_benefits():
    """
    Hiển thị lợi ích của hệ thống - được tối ưu hóa
    """
    st.markdown("## 🌟 Lợi ích của Hệ thống")
    
    benefits = [
        {
            "icon": "🎯",
            "title": "Học tập cá nhân hóa",
            "description": "Mỗi học sinh nhận được trải nghiệm học tập được tùy chỉnh theo nhu cầu riêng",
            "color": "#FF6B6B"
        },
        {
            "icon": "⚡",
            "title": "Phản hồi tức thì",
            "description": "Hệ thống đa tác nhân cho phép xử lý song song, đưa ra phản hồi nhanh chóng",
            "color": "#4ECDC4"
        },
        {
            "icon": "🧠",
            "title": "Học thích ứng thông minh",
            "description": "AI phân tích và điều chỉnh phương pháp dạy theo tiến bộ của từng học sinh",
            "color": "#45B7D1"
        },
        {
            "icon": "📊",
            "title": "Theo dõi tiến độ chi tiết",
            "description": "Báo cáo và phân tích tiến độ học tập giúp tối ưu hóa quá trình học",
            "color": "#96CEB4"
        },
        {
            "icon": "🔍",
            "title": "Độ chính xác cao",
            "description": "Hệ thống RAG và xác thực đảm bảo thông tin chính xác và đáng tin cậy",
            "color": "#FECA57"
        },
        {
            "icon": "🌐",
            "title": "Mở rộng dễ dàng",
            "description": "Kiến trúc đa tác nhân cho phép mở rộng và thêm tính năng mới linh hoạt",
            "color": "#FF9FF3"
        }
    ]
    
    # Hiển thị benefits trong lưới 2x3
    for i in range(0, len(benefits), 2):
        col1, col2 = st.columns(2)
        
        with col1:
            if i < len(benefits):
                benefit = benefits[i]
                st.markdown(f"""
                <div style='background: {benefit['color']}20; 
                            padding: 1.5rem; 
                            border-radius: 10px; 
                            margin-bottom: 1rem;
                            border-left: 4px solid {benefit['color']};
                            height: 130px;'>
                    <div style='display: flex; align-items: center; margin-bottom: 0.5rem;'>
                        <span style='font-size: 1.8rem; margin-right: 0.5rem;'>{benefit['icon']}</span>
                        <h4 style='color: #333; margin: 0;'>{benefit['title']}</h4>
                    </div>
                    <p style='color: #666; margin: 0; font-size: 0.9rem;'>
                        {benefit['description']}
                    </p>
                </div>
                """, unsafe_allow_html=True)
        
        with col2:
            if i + 1 < len(benefits):
                benefit = benefits[i + 1]
                st.markdown(f"""
                <div style='background: {benefit['color']}20; 
                            padding: 1.5rem; 
                            border-radius: 10px; 
                            margin-bottom: 1rem;
                            border-left: 4px solid {benefit['color']};
                            height: 130px;'>
                    <div style='display: flex; align-items: center; margin-bottom: 0.5rem;'>
                        <span style='font-size: 1.8rem; margin-right: 0.5rem;'>{benefit['icon']}</span>
                        <h4 style='color: #333; margin: 0;'>{benefit['title']}</h4>
                    </div>
                    <p style='color: #666; margin: 0; font-size: 0.9rem;'>
                        {benefit['description']}
                    </p>
                </div>
                """, unsafe_allow_html=True)

def main():
    """
    Hàm chính của trang Multi-Agent System
    """
    # Hiển thị kiến trúc hệ thống
    display_system_architecture()

    # Hiển thị các tác nhân
    display_agents()
    
    # Hiển thị các thành phần hệ thống
    display_system_components()
    
    # Hiển thị quy trình hoạt động
    display_workflow_details()
    
    # Hiển thị tính năng kỹ thuật
    display_technical_features()
    
    # Hiển thị lợi ích
    display_benefits()
    
    # Footer
    st.markdown("---")
    st.markdown("""
    <div style='text-align: center; 
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
                padding: 2rem; 
                border-radius: 15px; 
                margin-top: 2rem;'>
        <h3 style='color: white; margin-bottom: 1rem;'>
            🚀 Trải nghiệm Hệ thống Multi-Agent ngay hôm nay!
        </h3>
        <p style='color: #f0f0f0; font-size: 1.1rem; margin-bottom: 0;'>
            Hệ thống gia sư AI thông minh với kiến trúc đa tác nhân tiên tiến, 
            mang đến trải nghiệm học tập cá nhân hóa và hiệu quả nhất.
        </p>
    </div>
    """, unsafe_allow_html=True)

if __name__ == "__main__":
    main()