-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllms.html
289 lines (259 loc) · 11.7 KB
/
llms.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LiteLLM's Model Prices</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.loading {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.sort-icon::after {
content: '↕';
margin-left: 4px;
}
.sort-asc::after {
content: '↑';
}
.sort-desc::after {
content: '↓';
}
th {
user-select: none;
}
.table-wrapper {
max-width: 95vw;
margin: 0 auto;
overflow-x: auto;
}
table {
table-layout: fixed;
width: 100%;
min-width: 1200px; /* Minimum width to accommodate all columns */
}
/* Add specific column widths */
th[data-sort="id"] {
width: 20%;
}
th[data-sort="litellm_provider"] {
width: 12%;
}
th[data-sort="mode"] {
width: 10%;
}
th[data-sort="max_input_tokens"],
th[data-sort="max_output_tokens"] {
width: 10%;
}
th[data-sort="input_cost_per_token"],
th[data-sort="output_cost_per_token"] {
width: 10%;
}
/* Features column takes remaining space */
th:last-child {
width: 18%;
}
</style>
</head>
<body class="bg-gray-50">
<div id="app" class="p-4">
<div class="table-wrapper">
<div class="mb-8">
<h1 class="text-2xl font-bold mb-2">LiteLLM's Model Prices</h1>
<p class="text-sm text-gray-600 mb-4">
Data sourced from
<a href="https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json"
class="text-blue-600 hover:underline" target="_blank">BerriAI/litellm GitHub repository</a> |
<a href="https://github.com/BerriAI/litellm/blob/main/LICENSE" class="text-blue-600 hover:underline">License</a> |
<a href="https://github.com/oaustegard/oaustegard.github.io/blob/main/llms.html" class="text-blue-600 hover:underline">Code</a>
</p>
<div class="relative">
<input type="text"
id="search"
placeholder="Search models, providers, or modes..."
class="w-full px-4 py-2 border rounded-lg">
</div>
</div>
<div id="loading" class="loading">Loading model data...</div>
<div id="content" class="hidden">
<table class="bg-white border rounded-lg">
<thead>
<tr class="bg-gray-50">
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="id" data-type="string">Model</th>
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="litellm_provider" data-type="string">Provider</th>
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="mode" data-type="string">Mode</th>
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="max_input_tokens" data-type="number">Input Ctx</th>
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="max_output_tokens" data-type="number">Output Ctx</th>
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="input_cost_per_token" data-type="number">Input Cost</th>
<th class="px-4 py-3 border-b cursor-pointer sort-icon" data-sort="output_cost_per_token" data-type="number">Output Cost</th>
<th class="px-4 py-3 border-b">Features</th>
</tr>
</thead>
<tbody id="modelTable"></tbody>
</table>
<div id="modelCount" class="mt-4 text-sm text-gray-600"></div>
</div>
</div>
</div>
<script>
let models = [];
let sortConfig = { key: 'id', direction: 'asc', type: 'string' };
/* Element Access Helper */
function getElement(id) {
const element = document.getElementById(id);
if (!element) {
console.error(`Element with id '${id}' not found`);
return null;
}
return element;
}
function getSearchFromUrl() {
const queryParams = new URLSearchParams(window.location.search);
return queryParams.get('search') || '';
}
function updateUrl(searchTerm) {
try {
const newUrl = new URL(window.location.href);
if (searchTerm) {
newUrl.searchParams.set('search', searchTerm);
} else {
newUrl.searchParams.delete('search');
}
window.history.replaceState({}, '', newUrl.toString());
} catch (e) {
console.error('Error updating URL:', e);
}
}
function formatCost(cost) {
if (cost === undefined || cost === null) return 'N/A';
return '$' + (cost * 1000000).toFixed(2);
}
function renderFeatureBadge(feature, bgColor, textColor, label) {
return feature ?
`<span class="inline-block px-2 py-1 text-xs font-medium ${bgColor} ${textColor} rounded-full mr-1">
${label}
</span>` : '';
}
function filterAndSortModels(updateUrlFlag = true) {
const searchTerm = document.getElementById('search').value.toLowerCase();
const filteredModels = models.filter(model =>
model.id.toLowerCase().includes(searchTerm) ||
(model.litellm_provider && model.litellm_provider.toLowerCase().includes(searchTerm)) ||
(model.mode && model.mode.toLowerCase().includes(searchTerm))
);
if (updateUrlFlag) {
updateUrl(searchTerm);
}
filteredModels.sort((a, b) => {
let aValue = a[sortConfig.key];
let bValue = b[sortConfig.key];
if (aValue === undefined || aValue === null) aValue = '';
if (bValue === undefined || bValue === null) bValue = '';
if (sortConfig.type === 'number') {
return sortConfig.direction === 'asc' ? aValue - bValue : bValue - aValue;
} else {
return sortConfig.direction === 'asc'
? aValue.toString().localeCompare(bValue.toString())
: bValue.toString().localeCompare(aValue.toString());
}
});
renderModels(filteredModels);
}
function renderModels(filteredModels) {
const modelTable = document.getElementById('modelTable');
const modelCount = document.getElementById('modelCount');
if (!modelTable || !modelCount) return;
modelTable.innerHTML = filteredModels.map((model, index) => `
<tr class="${index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}">
<td class="px-4 py-4 border-b font-medium">${model.id}</td>
<td class="px-4 py-4 border-b">${model.litellm_provider || 'N/A'}</td>
<td class="px-4 py-4 border-b">${model.mode || 'N/A'}</td>
<td class="px-4 py-4 border-b text-right">
${model.max_input_tokens ? `${model.max_input_tokens.toLocaleString()}` : (model.max_tokens ? `${model.max_tokens.toLocaleString()}` : 'N/A')}
</td>
<td class="px-4 py-4 border-b text-right">
${model.max_output_tokens ? `${model.max_output_tokens.toLocaleString()}` : (model.max_tokens ? `${model.max_tokens.toLocaleString()}` : 'N/A')}
</td>
<td class="px-4 py-4 border-b text-right">${formatCost(model.input_cost_per_token)}</td>
<td class="px-4 py-4 border-b text-right">${formatCost(model.output_cost_per_token)}</td>
<td class="px-4 py-4 border-b">
<div class="flex flex-wrap gap-1">
${renderFeatureBadge(model.supports_function_calling, 'bg-blue-100', 'text-blue-800', 'Function')}
${renderFeatureBadge(model.supports_parallel_function_calling, 'bg-blue-100', 'text-blue-800', 'Parallel')}
${renderFeatureBadge(model.supports_vision, 'bg-green-100', 'text-green-800', 'Vision')}
${renderFeatureBadge(model.supports_audio_input, 'bg-yellow-100', 'text-yellow-800', 'Audio In')}
${renderFeatureBadge(model.supports_audio_output, 'bg-yellow-100', 'text-yellow-800', 'Audio Out')}
${renderFeatureBadge(model.supports_prompt_caching, 'bg-purple-100', 'text-purple-800', 'Cache')}
</div>
</td>
</tr>
`).join('');
modelCount.textContent = `Showing ${filteredModels.length} of ${models.length} models`;
}
function handleSort(key, type) {
if (sortConfig.key === key) {
sortConfig.direction = sortConfig.direction === 'asc' ? 'desc' : 'asc';
} else {
sortConfig.key = key;
sortConfig.direction = 'asc';
sortConfig.type = type;
}
document.querySelectorAll('th').forEach(th => {
th.classList.remove('sort-asc', 'sort-desc');
if (th.dataset.sort === sortConfig.key) {
th.classList.add(`sort-${sortConfig.direction}`);
}
});
filterAndSortModels();
}
function initializeApp() {
const searchInput = getElement('search');
const modelTable = getElement('modelTable');
const modelCount = getElement('modelCount');
const loading = getElement('loading');
const content = getElement('content');
if (!searchInput || !modelTable || !modelCount || !loading || !content) {
console.error('Required elements not found');
return;
}
searchInput.addEventListener('input', () => filterAndSortModels(true));
document.querySelectorAll('th[data-sort]').forEach(th => {
th.addEventListener('click', () => {
const key = th.dataset.sort;
const type = th.dataset.type;
handleSort(key, type);
});
});
fetch('https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json')
.then(response => response.json())
.then(data => {
// Filter out the sample_spec entry
models = Object.entries(data)
.filter(([id]) => id !== 'sample_spec') // Exclude sample_spec
.map(([id, details]) => ({
id,
...details
}));
loading.classList.add('hidden');
content.classList.remove('hidden');
const initialSearch = getSearchFromUrl();
if (initialSearch) {
searchInput.value = initialSearch;
}
filterAndSortModels(false);
})
.catch(error => {
if (loading) {
loading.innerHTML = 'Error loading model data. Please try again later.';
}
console.error('Error:', error);
});
}
document.addEventListener('DOMContentLoaded', initializeApp);
</script>
</body>
</html>