-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodelList.html
More file actions
192 lines (157 loc) · 5.89 KB
/
Copy pathmodelList.html
File metadata and controls
192 lines (157 loc) · 5.89 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OpenRouter Models - Live Filter</title>
<style>
body {
background-color: #121212;
color: #e0ffe0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
padding: 20px;
}
h1 {
color: #00ff88;
}
input, button {
margin: 5px;
padding: 8px;
background-color: #1e1e1e;
color: #e0ffe0;
border: 2px solid #00ff88;
border-radius: 4px;
outline: none;
}
input:focus, button:hover {
background-color: #2a2a2a;
box-shadow: 0 0 10px #00ff88;
}
button {
cursor: pointer;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
background-color: #1e1e1e;
}
th, td {
border: 1px solid #00ff88;
padding: 10px;
text-align: left;
}
th {
background-color: #181818;
color: #00ff88;
}
tr:hover {
background-color: #222;
}
::placeholder {
color: #88ffcc;
opacity: 0.7;
}
</style>
</head>
<body>
<h1>OpenRouter Models - Live Filter</h1>
<label for="promptPrice">Max Prompt Price ($/token):</label>
<input type="number" id="promptPrice" step="0.000001" value="0.1" oninput="filterModels()">
<label for="completionPrice">Max Completion Price ($/token):</label>
<input type="number" id="completionPrice" step="0.000001" value="0.1" oninput="filterModels()">
<br>
<label for="nameFilter">Filter by Name:</label>
<input type="text" id="nameFilter" placeholder="Type model name..." oninput="filterModels()">
<br>
<button onclick="initialLoad()">Load Models</button>
<button onclick="showAllModels()">Show All Models</button>
<button onclick="resetFilters()">Reset Filters</button>
<table id="modelsTable">
<thead>
<tr>
<th>Model ID</th>
<th>Name</th>
<th>Context Length</th>
<th>Prompt Price ($/token)</th>
<th>Completion Price ($/token)</th>
<th>Quantization</th>
</tr>
</thead>
<tbody>
<!-- Models will be inserted here -->
</tbody>
</table>
<script>
let allModels = []; // Cached list
let showingAll = false; // Toggle to show all or filtered
async function fetchModels() {
const endpoint = 'https://openrouter.ai/api/v1/models';
try {
const response = await fetch(endpoint, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
});
if (!response.ok) {
throw new Error(`Failed to fetch models: ${response.status}`);
}
const data = await response.json();
return data.data.map(model => ({
id: model.id,
name: model.name || model.id,
contextLength: model.context_length || 'Unknown',
promptPrice: model.pricing?.prompt ? parseFloat(model.pricing.prompt) : null,
completionPrice: model.pricing?.completion ? parseFloat(model.pricing.completion) : null,
quantization: model.quantization || 'Unknown'
}));
} catch (error) {
console.error('Error fetching models:', error);
return [];
}
}
async function initialLoad() {
allModels = await fetchModels();
showingAll = false;
filterModels();
}
function filterModels() {
const promptPriceInput = parseFloat(document.getElementById('promptPrice').value) || Infinity;
const completionPriceInput = parseFloat(document.getElementById('completionPrice').value) || Infinity;
const nameFilter = document.getElementById('nameFilter').value.toLowerCase();
const filtered = allModels.filter(model => {
const isPromptOk = model.promptPrice !== null && model.promptPrice <= promptPriceInput;
const isCompletionOk = model.completionPrice !== null && model.completionPrice <= completionPriceInput;
const isNameOk = model.name.toLowerCase().includes(nameFilter);
return (!showingAll && (isPromptOk && isCompletionOk) || showingAll) && isNameOk;
});
renderTable(filtered);
}
function showAllModels() {
showingAll = true;
filterModels();
}
function resetFilters() {
document.getElementById('promptPrice').value = 0.1;
document.getElementById('completionPrice').value = 0.1;
document.getElementById('nameFilter').value = '';
showingAll = false;
filterModels();
}
function renderTable(models) {
const tbody = document.getElementById('modelsTable').querySelector('tbody');
tbody.innerHTML = '';
models.forEach(model => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${model.id}</td>
<td>${model.name}</td>
<td>${model.contextLength}</td>
<td>${model.promptPrice !== null ? model.promptPrice.toFixed(6) : 'N/A'}</td>
<td>${model.completionPrice !== null ? model.completionPrice.toFixed(6) : 'N/A'}</td>
<td>${model.quantization}</td>
`;
tbody.appendChild(row);
});
}
</script>
</body>
</html>