Loading AI models data from GitHub...
Unable to load AI models data
Please check your internet connection and try again.
Overview
Provider: ${model.provider}
Type: ${model.type ? model.type.join(', ') : 'Unknown'}
Modalities: ${model.modalities ? model.modalities.join(', ') : 'Unknown'}
License: ${model.license || 'Unknown'}
${model.context_window ? `
Context Window: ${model.context_window.toLocaleString()} tokens
` : ''}
${model.description_long ? `
Description
${model.description_long}
` : ''}
${model.pricing ? `
Pricing
Input: ${formatPrice(model.pricing)}
${model.pricing.output_per_million ? `
Output: $${model.pricing.output_per_million}/1M tokens
` : ''}
${model.pricing.notes ? `
Notes: ${model.pricing.notes}
` : ''}
` : ''}
${model.strengths ? `
Strengths
${model.strengths.map(s => `- ${s}
`).join('')}
` : ''}
${model.limitations ? `
Limitations
${model.limitations.map(l => `- ${l}
`).join('')}
` : ''}
`;
}
function updateStats() {
document.getElementById('companies-count').textContent = AppState.filteredCompanies.length;
document.getElementById('models-count').textContent = AppState.models.length;
}
// ==================== SEARCH & FILTERING ====================
function handleSearch(event) {
const query = event.target.value.toLowerCase();
AppState.searchQuery = query;
document.getElementById('clearSearch').style.display = query ? 'block' : 'none';
if (AppState.currentView === 'companies') {
filterCompanies(query);
}
debouncedSearch();
}
const debouncedSearch = debounce(() => {
// Additional search logic can go here
}, 300);
function filterCompanies(query) {
if (!query) {
AppState.filteredCompanies = [...AppState.companies];
} else {
AppState.filteredCompanies = AppState.companies.filter(company => {
const searchText = [
company.name,
...company.models.map(m => [m.name, m.type, m.description_short, m.purpose].filter(Boolean).join(' '))
].join(' ').toLowerCase();
return searchText.includes(query);
});
}
if (AppState.currentView === 'companies') {
renderCompaniesGrid();
}
}
function clearSearch() {
document.getElementById('searchInput').value = '';
AppState.searchQuery = '';
document.getElementById('clearSearch').style.display = 'none';
filterCompanies('');
}
// ==================== THEME MANAGEMENT ====================
function toggleTheme() {
AppState.theme = AppState.theme === 'light' ? 'dark' : 'light';
localStorage.setItem('ai-dashboard-theme', AppState.theme);
document.documentElement.setAttribute('data-theme', AppState.theme);
document.getElementById('theme-icon').textContent = AppState.theme === 'light' ? '🌙' : '☀️';
document.getElementById('theme-text').textContent = AppState.theme === 'light' ? 'Dark' : 'Light';
}
// ==================== INITIALIZATION ====================
function initializeDashboard() {
console.log('🚀 Initializing AI Models Dashboard...');
// Set initial theme
document.documentElement.setAttribute('data-theme', AppState.theme);
document.getElementById('theme-icon').textContent = AppState.theme === 'light' ? '🌙' : '☀️';
document.getElementById('theme-text').textContent = AppState.theme === 'light' ? 'Dark' : 'Light';
// Load data
loadData();
}
// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeDashboard);
} else {
initializeDashboard();
}
// ==================== GLOBAL ERROR HANDLING ====================
window.addEventListener('error', (event) => {
console.error('🚨 Global error:', event.error);
});
window.addEventListener('unhandledrejection', (event) => {
console.error('🚨 Unhandled promise rejection:', event.reason);
});
// ==================== EXPORT FOR TESTING ====================
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
AppState,
loadData,
showCompanies,
showCompanyModels,
showModelDetail,
toggleTheme
};
}