File size: 3,368 Bytes
2252f98
 
 
 
5d8876d
 
 
 
2252f98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d8876d
 
 
2252f98
5d8876d
2252f98
 
 
 
 
5d8876d
 
2252f98
5d8876d
 
 
 
 
 
 
 
 
 
 
2252f98
 
 
 
 
 
 
5d8876d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2252f98
 
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
var dagcomponentfuncs = window.dashAgGridComponentFunctions = window.dashAgGridComponentFunctions || {};
// Store original data globally
window.gridOriginalData = null;

// Global store for pinned model IDs
window.pinnedModelIds = new Set(JSON.parse(localStorage.getItem('pinnedModelIds') || '[]'));


dagcomponentfuncs.ModelLink = function(props) {
    if (!props.data.Model_Link) {
        return props.value;  // Just return text if no link
    }
    return React.createElement(
        'a',
        {
            href: props.data.Model_Link,
            target: '_blank',
            style: {
                color: '#007bff',
                textDecoration: 'none'
            }
        },
        props.value
    );
};

if (!localStorage.getItem('pinnedModelIds')) {
    localStorage.setItem('pinnedModelIds', '[]');
}

dagcomponentfuncs.PinRenderer = function(props) {
    return React.createElement(
        'div',
        {
            onClick: function() {
                const api = props.api;
                const modelId = props.data.Model_Display;
                const isPinned = props.data.pinned || false;
                
                if (isPinned) {
                    // Unpin
                    const currentPinned = api.getGridOption('pinnedTopRowData') || [];
                    const newPinnedRows = currentPinned.filter(row => row.Model_Display !== modelId);
                    api.setGridOption('pinnedTopRowData', newPinnedRows);
                } else {
                    // Pin
                    const currentPinned = api.getGridOption('pinnedTopRowData') || [];
                    const pinnedRow = {...props.data, pinned: true};
                    api.setGridOption('pinnedTopRowData', [...currentPinned, pinnedRow]);
                }
            },
            style: {
                cursor: 'pointer',
                textAlign: 'center',
                fontSize: '16px'
            }
        },
        props.data.pinned ? '📌' : '☐'
    );
};

dagcomponentfuncs.TypeRenderer = function(props) {
    const typeMap = {
        'Base': ['B', '#71de5f'],
        'Finetune': ['F', '#f6b10b'], 
        'Merge': ['M', '#f08aff'],
        'Proprietary': ['P', '#19cdce']
    };
    
    // Determine type from raw flags
    let type = 'Unknown';
    if (props.data['Total Parameters'] === null) {
        type = 'Proprietary';
    } else if (props.data['Is Foundation'] && !props.data['Is Merged']) {
        type = 'Base';
    } else if (props.data['Is Merged']) {
        type = 'Merge';
    } else if (props.data['Is Finetuned'] && !props.data['Is Merged']) {
        type = 'Finetune';
    }
    
    const [letter, color] = typeMap[type] || ['?', '#999'];
    
    return React.createElement('div', {
        style: {
            display: 'flex',
            alignItems: 'center',
            height: '100%',
            position: 'absolute',
            top: 0,
            bottom: 0,
            left: '12px'
        }
    }, 
        React.createElement('div', {
            style: {
                color: color,
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                fontWeight: 'bold',
                fontSize: '14px',
                lineHeight: '1',
                textAlign: 'center'
            }
        }, letter)
    );
};