-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModelList.svelte
More file actions
177 lines (162 loc) · 5.47 KB
/
ModelList.svelte
File metadata and controls
177 lines (162 loc) · 5.47 KB
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
<script>
import { onMount } from "svelte";
import ModelCard from "./ModelCard.svelte";
import { getApiUrl } from "../../lib/config";
import { getModelTier } from "../../lib/modelMetrics";
export let chatAppUrl;
let models = [];
let modelCount = 0;
let loading = true;
let error = null;
let search = "";
let activeFilter = "all"; // "all" | "24/7" | "slurm"
onMount(async () => {
try {
const response = await fetch(`${getApiUrl()}/v1/models_detailed`);
const data = await response.json();
const rawModels = data.data;
const modelsMap = new Map();
for (const model of rawModels) {
if (!modelsMap.has(model.id)) {
modelsMap.set(model.id, {
id: model.id,
devices: new Set(),
count: 0,
});
}
const existing = modelsMap.get(model.id);
existing.devices.add(model.device);
existing.count++;
}
modelCount = modelsMap.size;
models = Array.from(modelsMap.values()).map(groupedModel => ({
data: {
title: groupedModel.id,
description: groupedModel.id,
devices: Array.from(groupedModel.devices),
instanceCount: groupedModel.count,
},
}));
} catch (err) {
console.error("Error fetching models:", err);
error = err.message;
}
finally {
loading = false;
}
});
$: filteredModels = models.filter((m) => {
const title = m.data.title;
if (search.trim()) {
const q = search.trim().toLowerCase();
const haystack = (title + " " + m.data.devices.join(" ")).toLowerCase();
if (!haystack.includes(q)) return false;
}
if (activeFilter === "24/7") return getModelTier(title) === "L2";
if (activeFilter === "slurm") return getModelTier(title) === "slurm";
return true;
});
</script>
<div>
<div class="text-center mb-8">
<h2 class="text-3xl font-bold text-slate-900 dark:text-white mb-4">
Available Models
{#if !loading && !error}
<span style="display:inline-flex;align-items:center;justify-content:center;font-size:0.65em;font-weight:bold;line-height:1;padding:0.15em 0.5em;border-radius:4px;background-color:#6366f1;color:#fff;vertical-align:middle;margin-left:0.3em">{modelCount}</span>
{/if}
</h2>
<p class="text-lg text-slate-600 dark:text-slate-400 max-w-2xl mx-auto">
Access state-of-the-art language models from leading AI research organizations
</p>
</div>
{#if !loading && !error}
<div class="mb-6 flex flex-col sm:flex-row gap-3 sm:items-center sm:justify-between">
<div class="flex flex-wrap gap-2">
<button
class="pill"
class:active={activeFilter === "all"}
on:click={() => (activeFilter = "all")}
>All</button>
<button
class="pill"
class:active={activeFilter === "24/7"}
on:click={() => (activeFilter = "24/7")}
>24/7</button>
<button
class="pill"
class:active={activeFilter === "slurm"}
on:click={() => (activeFilter = "slurm")}
>Slurm</button>
</div>
<input
type="text"
bind:value={search}
placeholder="Search by model name or GPU..."
class="search-input"
/>
</div>
{/if}
{#if loading}
<div class="loading">Loading...</div>
{:else if error}
<div class="error">
Error loading: {error}
</div>
{:else}
<div class="model-list space-y-2">
{#each filteredModels as model (model.data.title)}
<ModelCard entry={model} {chatAppUrl} />
{/each}
{#if filteredModels.length === 0}
<div class="text-center text-slate-500 dark:text-slate-400 py-6">
No models match your filters.
</div>
{/if}
</div>
{/if}
</div>
<style>
.search-input {
width: 100%;
max-width: 420px;
padding: 0.5rem 0.75rem;
border-radius: 6px;
border: 1px solid rgba(0, 0, 0, 0.15);
background-color: transparent;
color: inherit;
font-size: 0.875rem;
outline: none;
transition: border-color 0.15s ease;
}
:global(.dark) .search-input {
border-color: rgba(255, 255, 255, 0.2);
}
.search-input:focus {
border-color: #6366f1;
}
.pill {
padding: 0.3rem 0.75rem;
border-radius: 9999px;
font-size: 0.8rem;
font-weight: 600;
border: 1px solid rgba(0, 0, 0, 0.15);
background-color: transparent;
color: inherit;
cursor: pointer;
transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
:global(.dark) .pill {
border-color: rgba(255, 255, 255, 0.2);
}
.pill:hover {
background-color: rgba(0, 0, 0, 0.05);
}
:global(.dark) .pill:hover {
background-color: rgba(255, 255, 255, 0.08);
}
.pill.active {
background-color: #6366f1;
border-color: #6366f1;
color: white;
}
</style>