File size: 15,886 Bytes
c452959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// AI Dashboard Application
class AIDashboard {
    constructor() {
        this.data = {
            "approaches": [
                {
                    "name": "LLM Workflow",
                    "functionality": "Прогнозування наступного токена",
                    "bestCase": "Генерація тексту, саммаризація",
                    "strengths": "Швидкість, простота, легкість впровадження",
                    "weaknesses": "Обмежений контекст, відсутність зовнішніх знань",
                    "examples": "Чат-боти, email-генерація",
                    "workflow": "Користувач → Тригер на основі правил → LLM → Вихід",
                    "description": "Найпростіший підхід, що використовує LLM для генерації тексту на основі промпту користувача",
                    "complexity": "Низька",
                    "icon": "🔗"
                },
                {
                    "name": "RAG",
                    "functionality": "Розумний пошук знань",
                    "bestCase": "Точні Q&A з різних джерел",
                    "strengths": "Точність завдяки зовнішнім даним",
                    "weaknesses": "Чутливість до якості даних",
                    "examples": "Graph RAG, Advanced RAG, Modular RAG",
                    "workflow": "Користувач → Векторизація → Пошук у базі → LLM (збагачений даними) → Вихід",
                    "description": "Покращений підхід, що додає зовнішні знання до процесу генерації відповідей",
                    "complexity": "Середня",
                    "icon": "🔍"
                },
                {
                    "name": "AI Agent",
                    "functionality": "Автономні дії з використанням компонентів",
                    "bestCase": "Воркфлоу з інструментами та міркуванням",
                    "strengths": "Планування + міркування, виконання складних задач",
                    "weaknesses": "Потребує чітких цілей та доступу до інструментів",
                    "examples": "ReACT Agent, Rewoo Agent",
                    "workflow": "Користувач → Системний промпт → Планування → База даних/Пам'ять/Інструменти → Вихід",
                    "description": "Автономний агент, здатний планувати та виконувати складні задачі з використанням інструментів",
                    "complexity": "Висока",
                    "icon": "🤖"
                },
                {
                    "name": "Agentic AI",
                    "functionality": "Мультиагентна автономна система",
                    "bestCase": "Масштабні задачі, що потребують розподілу ролей",
                    "strengths": "Гнучкість, розподіл задач між агентами",
                    "weaknesses": "Складність розробки та контролю",
                    "examples": "CUA, Embodied Agents",
                    "workflow": "Користувач → Пам'ять/Міркування/Зворотний зв'язок → Кілька агентів → Інструменти/Дані → Вихід",
                    "description": "Найскладніша система з кількома агентами, що працюють разом для вирішення масштабних задач",
                    "complexity": "Дуже висока",
                    "icon": "🌐"
                }
            ],
            "criteria": [
                "Функціональність",
                "Найкращий кейс",
                "Сильні сторони",
                "Слабкі сторони",
                "Приклади"
            ],
            "complexityLevels": ["Низька", "Середня", "Висока", "Дуже висока"],
            "recommendations": [
                {
                    "scenario": "Прості задачі генерації тексту",
                    "recommendation": "LLM Workflow",
                    "reason": "Найпростіший у впровадженні та налаштуванні"
                },
                {
                    "scenario": "Потреба в точних відповідях з великої бази знань",
                    "recommendation": "RAG",
                    "reason": "Забезпечує високу точність завдяки зовнішнім даним"
                },
                {
                    "scenario": "Складні задачі з використанням інструментів",
                    "recommendation": "AI Agent",
                    "reason": "Може планувати та виконувати багатоетапні процеси"
                },
                {
                    "scenario": "Масштабні проекти з розподіленими ролями",
                    "recommendation": "Agentic AI",
                    "reason": "Найгнучкіший для складних багатоагентних систем"
                }
            ]
        };
        
        this.currentFilters = {
            approach: '',
            complexity: '',
            criteria: ''
        };
        
        this.init();
    }
    
    init() {
        this.setupEventListeners();
        this.renderComparisonTable();
        this.renderWorkflows();
        this.renderDetails();
        this.renderRecommendations();
    }
    
    setupEventListeners() {
        // Filter event listeners
        document.getElementById('approach-filter').addEventListener('change', (e) => {
            this.currentFilters.approach = e.target.value;
            this.applyFilters();
        });
        
        document.getElementById('complexity-filter').addEventListener('change', (e) => {
            this.currentFilters.complexity = e.target.value;
            this.applyFilters();
        });
        
        document.getElementById('criteria-filter').addEventListener('change', (e) => {
            this.currentFilters.criteria = e.target.value;
            this.applyFilters();
        });
        
        // Reset filters button
        document.getElementById('reset-filters').addEventListener('click', () => {
            this.resetFilters();
        });
    }
    
    applyFilters() {
        this.renderComparisonTable();
        this.renderWorkflows();
        this.renderDetails();
    }
    
    resetFilters() {
        this.currentFilters = {
            approach: '',
            complexity: '',
            criteria: ''
        };
        
        // Reset select elements
        document.getElementById('approach-filter').value = '';
        document.getElementById('complexity-filter').value = '';
        document.getElementById('criteria-filter').value = '';
        
        this.applyFilters();
    }
    
    getFilteredApproaches() {
        return this.data.approaches.filter(approach => {
            const matchesApproach = !this.currentFilters.approach || 
                                  approach.name === this.currentFilters.approach;
            const matchesComplexity = !this.currentFilters.complexity || 
                                     approach.complexity === this.currentFilters.complexity;
            
            return matchesApproach && matchesComplexity;
        });
    }
    
    renderComparisonTable() {
        const tableBody = document.getElementById('comparison-table-body');
        const filteredApproaches = this.getFilteredApproaches();
        
        tableBody.innerHTML = filteredApproaches.map(approach => `
            <tr class="fade-in">
                <td>
                    <div class="approach-name">
                        <span class="approach-icon">${approach.icon}</span>
                        <strong>${approach.name}</strong>
                    </div>
                </td>
                <td>${approach.functionality}</td>
                <td>${approach.bestCase}</td>
                <td>${approach.strengths}</td>
                <td>${approach.weaknesses}</td>
                <td>
                    <span class="complexity-badge ${this.getComplexityClass(approach.complexity)}">
                        ${approach.complexity}
                    </span>
                </td>
            </tr>
        `).join('');
    }
    
    getComplexityClass(complexity) {
        const classMap = {
            'Низька': 'complexity-low',
            'Середня': 'complexity-medium',
            'Висока': 'complexity-high',
            'Дуже висока': 'complexity-very-high'
        };
        return classMap[complexity] || 'complexity-low';
    }
    
    getApproachClass(name) {
        const classMap = {
            'LLM Workflow': 'llm-workflow',
            'RAG': 'rag',
            'AI Agent': 'ai-agent',
            'Agentic AI': 'agentic-ai'
        };
        return classMap[name] || 'llm-workflow';
    }
    
    renderWorkflows() {
        const workflowsGrid = document.getElementById('workflows-grid');
        const filteredApproaches = this.getFilteredApproaches();
        
        workflowsGrid.innerHTML = filteredApproaches.map(approach => {
            const steps = approach.workflow.split(' → ');
            const stepsHtml = steps.map((step, index) => {
                const isLast = index === steps.length - 1;
                return `
                    <div class="workflow-step">${step}</div>
                    ${!isLast ? '<div class="workflow-arrow">→</div>' : ''}
                `;
            }).join('');
            
            return `
                <div class="workflow-card fade-in">
                    <div class="workflow-header ${this.getApproachClass(approach.name)}">
                        <span class="approach-icon">${approach.icon}</span>
                        <h4>${approach.name}</h4>
                    </div>
                    <div class="workflow-body">
                        <div class="workflow-steps">
                            ${stepsHtml}
                        </div>
                    </div>
                </div>
            `;
        }).join('');
    }
    
    renderDetails() {
        const detailsGrid = document.getElementById('details-grid');
        const filteredApproaches = this.getFilteredApproaches();
        
        detailsGrid.innerHTML = filteredApproaches.map(approach => `
            <div class="detail-card fade-in">
                <div class="detail-header ${this.getApproachClass(approach.name)}">
                    <span class="approach-icon">${approach.icon}</span>
                    <h4>${approach.name}</h4>
                </div>
                <div class="detail-body">
                    <div class="detail-section">
                        <h5>Опис</h5>
                        <p>${approach.description}</p>
                    </div>
                    
                    <div class="detail-section">
                        <h5>Функціональність</h5>
                        <p>${approach.functionality}</p>
                    </div>
                    
                    <div class="detail-section">
                        <h5>Найкращий кейс</h5>
                        <p>${approach.bestCase}</p>
                    </div>
                    
                    <div class="detail-section">
                        <h5>Сильні сторони</h5>
                        <p>${approach.strengths}</p>
                    </div>
                    
                    <div class="detail-section">
                        <h5>Слабкі сторони</h5>
                        <p>${approach.weaknesses}</p>
                    </div>
                    
                    <div class="detail-section">
                        <h5>Приклади</h5>
                        <p>${approach.examples}</p>
                    </div>
                    
                    <div class="detail-section">
                        <h5>Складність</h5>
                        <span class="complexity-badge ${this.getComplexityClass(approach.complexity)}">
                            ${approach.complexity}
                        </span>
                    </div>
                </div>
            </div>
        `).join('');
    }
    
    renderRecommendations() {
        const recommendationsGrid = document.getElementById('recommendations-grid');
        
        recommendationsGrid.innerHTML = this.data.recommendations.map(rec => {
            const approach = this.data.approaches.find(a => a.name === rec.recommendation);
            const approachIcon = approach ? approach.icon : '💡';
            
            return `
                <div class="recommendation-card fade-in">
                    <div class="recommendation-scenario">
                        <strong>Сценарій:</strong> ${rec.scenario}
                    </div>
                    <div class="recommendation-approach">
                        ${approachIcon} ${rec.recommendation}
                    </div>
                    <div class="recommendation-reason">
                        <strong>Причина:</strong> ${rec.reason}
                    </div>
                </div>
            `;
        }).join('');
    }
}

// Initialize the dashboard when the DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
    new AIDashboard();
    
    // Add smooth scrolling for anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            const target = document.querySelector(this.getAttribute('href'));
            if (target) {
                target.scrollIntoView({
                    behavior: 'smooth',
                    block: 'start'
                });
            }
        });
    });
    
    // Add intersection observer for fade-in animations
    const observerOptions = {
        threshold: 0.1,
        rootMargin: '0px 0px -50px 0px'
    };
    
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('fade-in');
                observer.unobserve(entry.target);
            }
        });
    }, observerOptions);
    
    // Observe all cards for animation
    const observeCards = () => {
        document.querySelectorAll('.card, .workflow-card, .detail-card, .recommendation-card').forEach(card => {
            observer.observe(card);
        });
    };
    
    // Initial observation
    setTimeout(observeCards, 100);
    
    // Re-observe after filter changes
    const originalApplyFilters = AIDashboard.prototype.applyFilters;
    AIDashboard.prototype.applyFilters = function() {
        originalApplyFilters.call(this);
        setTimeout(observeCards, 100);
    };
});