-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup-models.html
More file actions
345 lines (313 loc) · 13.1 KB
/
Copy pathsetup-models.html
File metadata and controls
345 lines (313 loc) · 13.1 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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Model Configuration — Pantheon</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
background: #020617;
color: #e2e8f0;
min-height: 100vh;
display: flex;
flex-direction: column;
}
header {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
border-bottom: 1px solid #1e293b;
padding: 2rem 2rem 1.5rem;
text-align: center;
}
header h1 { font-size: 2rem; font-weight: 700; color: #22d3ee; letter-spacing: -0.025em; }
header p { color: #94a3b8; margin-top: 0.4rem; font-size: 1rem; }
.container { max-width: 740px; margin: 0 auto; padding: 2rem; flex: 1; }
.card {
background: #0f172a;
border: 1px solid #1e293b;
border-radius: 12px;
padding: 1.25rem 1.5rem;
margin-bottom: 0.75rem;
}
.card-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.5rem; }
.card-desc { color: #64748b; font-size: 0.85rem; line-height: 1.5; }
.model-option {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem 0;
border-bottom: 1px solid #1e293b;
gap: 1rem;
}
.model-option:last-child { border-bottom: none; }
.model-label { flex: 1; }
.model-name { font-weight: 500; font-size: 0.9rem; }
.model-desc { color: #64748b; font-size: 0.8rem; margin-top: 0.15rem; }
.model-select {
background: #1e293b;
color: #e2e8f0;
border: 1px solid #334155;
border-radius: 8px;
padding: 0.5rem 0.7rem;
font-size: 0.85rem;
outline: none;
cursor: pointer;
min-width: 200px;
}
.model-select:focus { border-color: #22d3ee; }
.auto-badge {
display: inline-block;
background: #065f46;
color: #6ee7b7;
padding: 0.15rem 0.5rem;
border-radius: 4px;
font-size: 0.7rem;
font-weight: 600;
margin-left: 0.4rem;
}
.summary-card {
background: linear-gradient(135deg, rgba(6, 78, 59, 0.3), rgba(8, 51, 68, 0.3));
border: 1px solid #0d9488;
border-radius: 12px;
padding: 1.5rem;
margin-top: 1.5rem;
text-align: center;
}
.summary-card h2 { color: #22d3ee; font-size: 1.2rem; margin-bottom: 0.5rem; }
.summary-card p { color: #94a3b8; font-size: 0.9rem; margin-bottom: 1rem; }
.btn {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.6rem 1.2rem;
border-radius: 8px;
font-size: 0.9rem;
font-weight: 600;
border: none;
cursor: pointer;
text-decoration: none;
transition: all 0.15s;
}
.btn-primary { background: #0e7490; color: white; }
.btn-primary:hover { background: #0891b2; box-shadow: 0 0 12px rgba(34,211,238,0.3); }
.btn-secondary { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
.btn-secondary:hover { background: #334155; color: #e2e8f0; }
.btn-success { background: #065f46; color: #6ee7b7; }
.btn-success:hover { background: #0d9488; }
.action-buttons { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }
.status-msg {
display: none;
padding: 0.6rem 0.8rem;
border-radius: 8px;
font-size: 0.85rem;
margin-bottom: 0.75rem;
}
.status-msg.success { display: block; background: #065f46; border: 1px solid #0d9488; color: #6ee7b7; }
.status-msg.error { display: block; background: #7f1d1d; border: 1px solid #b91c1c; color: #fca5a5; }
.status-msg.loading { display: block; background: #0e7490; border: 1px solid #0891b2; color: #22d3ee; }
.loading-spinner { text-align: center; padding: 3rem; color: #64748b; }
footer { text-align: center; padding: 2rem; color: #475569; font-size: 0.8rem; border-top: 1px solid #1e293b; }
footer a { color: #22d3ee; text-decoration: none; }
.provider-tag {
display: inline-block;
background: #1e293b;
padding: 0.2rem 0.6rem;
border-radius: 4px;
font-size: 0.75rem;
color: #94a3b8;
}
</style>
</head>
<body>
<header>
<h1>⚙️ Model Configuration</h1>
<p>Choose the models your Pantheon Gods will use.</p>
</header>
<div class="container">
<div id="loading" class="loading-spinner">Loading recommendations...</div>
<div id="content" style="display:none;"></div>
</div>
<footer>
<a href="http://localhost:9876/welcome.html">← Back to Welcome Wizard</a> ·
<a href="http://localhost:8787">Open Web UI →</a>
</footer>
<script>
const API = 'http://localhost:9876';
// ── Load recommendations on page load ──
document.addEventListener('DOMContentLoaded', loadRecommendations);
async function loadRecommendations() {
try {
const res = await fetch(`${API}/api/env/models/recommend`);
const data = await res.json();
render(data);
} catch (e) {
document.getElementById('loading').textContent = 'Could not reach setup server. Make sure the installer is running.';
}
}
function render(data) {
const loading = document.getElementById('loading');
const content = document.getElementById('content');
loading.style.display = 'none';
content.style.display = 'block';
const recs = data.recommendations || {};
const provider = recs.label || 'Unknown';
const autoConfig = recs.auto_configure || false;
const models = recs.models || {};
const common = recs.common || {};
let html = '';
// Provider card
html += `<div class="card">
<div class="card-title">🔌 Provider: <span style="color:#22d3ee;">${provider}</span></div>
<div class="card-desc">
${data.primary_provider
? `Using ${provider} for chat, extraction, and vision models.`
: 'No provider configured yet — set up an API key first.'}
</div>
</div>`;
// Auto-configure message for OpenCode Go
if (autoConfig && data.primary_provider) {
html += `<div class="summary-card">
<h2>✅ Using Recommended Defaults</h2>
<p>OpenCode Go has a curated model lineup — we've picked the best defaults for each role.</p>
<table style="width:100%;border-collapse:collapse;font-size:0.85rem;text-align:left;margin:0 auto;max-width:400px;">
<tr style="border-bottom:1px solid #1e293b;">
<th style="padding:0.4rem 0.5rem;color:#94a3b8;">Role</th>
<th style="padding:0.4rem 0.5rem;color:#94a3b8;">Model</th>
</tr>`;
for (const [role, cfg] of Object.entries(models)) {
if (!cfg.default && role === 'vision') continue;
const label = {chat:'💬 Chat', extraction:'🔍 Extraction', extraction_fallback:'🔁 Extraction Fallback', vision:'👁️ Vision'}[role] || role;
html += `<tr><td style="padding:0.3rem 0.5rem;color:#e2e8f0;">${label}</td><td style="padding:0.3rem 0.5rem;color:#6ee7b7;">${cfg.default}</td></tr>`;
}
html += `</table>
<p style="margin-top:1rem;color:#94a3b8;font-size:0.8rem;">You can change these anytime in ~/pantheon/.env</p>
</div>`;
}
// Manual config for non-OpenCode Go providers
if (!autoConfig && data.primary_provider) {
html += `<div class="card">
<div class="card-title">🎯 Model Selection</div>
<div class="card-desc" style="margin-bottom:0.5rem;">Pick the best models for each role. Defaults are recommended for your provider.</div>
<div id="model-list"></div>
<div style="margin-top:1rem;">
<button class="btn btn-primary" onclick="saveModels()">💾 Save Model Config</button>
<span id="save-status"></span>
</div>
</div>`;
}
// Embedding provider section
const embedInfo = data.embedding || {};
const embedProviders = recs.embedding_providers || {};
html += `<div class="card" style="border-color:#334155;">
<div class="card-title" style="display:flex;align-items:center;gap:0.5rem;">
<span>🧠 Embedding (Vector Search)</span>
<span style="font-size:0.7rem;padding:0.15rem 0.5rem;border-radius:4px;font-weight:600;"
id="embed-status-badge">${embedInfo.configured
? '<span style="background:#065f46;color:#6ee7b7;padding:0.15rem 0.5rem;border-radius:4px;">✓ Configured</span>'
: '<span style="background:#7f1d1d;color:#fca5a5;padding:0.15rem 0.5rem;border-radius:4px;">⚠ Not Set</span>'}</span>
</div>
<div class="card-desc" style="margin-bottom:0.75rem;">
${embedInfo.configured
? `Using <strong>${embedInfo.current.label}</strong> — model: <code style="background:#1e293b;padding:1px 5px;border-radius:3px;font-size:0.75rem;">${embedInfo.current.model}</code>`
: 'No embedding provider configured. Vector search and Athenaeum ingestion will not work.'}
</div>`;
if (!embedInfo.configured) {
html += `<div style="background:#1e293b;border-radius:8px;padding:0.75rem;font-size:0.85rem;">
<div style="color:#94a3b8;margin-bottom:0.5rem;font-weight:600;">Choose an embedding provider:</div>
<div style="display:flex;flex-direction:column;gap:0.4rem;">`;
for (const [key, prov] of Object.entries(embedProviders)) {
html += `<div style="display:flex;align-items:center;gap:0.5rem;padding:0.3rem 0;">
<span style="color:#22d3ee;font-weight:500;">${prov.label}</span>
<code style="background:#0f172a;padding:1px 6px;border-radius:4px;font-size:0.75rem;color:#6ee7b7;">${prov.model}</code>
<span style="color:#64748b;font-size:0.75rem;flex:1;">${prov.note}</span>
</div>`;
}
html += `</div>
<div style="margin-top:0.5rem;"><a class="btn btn-primary" href="http://localhost:9876/welcome.html" style="font-size:0.8rem;padding:0.4rem 0.8rem;">🔑 Configure Embedding →</a></div>
</div>`;
}
if (embedInfo.configured) {
html += `<div style="margin-top:0.5rem;display:flex;gap:0.5rem;flex-wrap:wrap;">`;
for (const [key, prov] of Object.entries(embedProviders)) {
if (prov.label === embedInfo.current.label) continue;
html += `<span style="background:#0f172a;border:1px solid #1e293b;border-radius:6px;padding:0.3rem 0.6rem;font-size:0.75rem;color:#64748b;">
${prov.label}: <code style="color:#94a3b8;">${prov.model}</code></span>`;
}
html += `</div>`;
}
html += `</div>`;
// Summary (context compression)
const summaryCfg = common && common.summary;
if (summaryCfg) {
html += `<div class="card" style="border-color:#334155;">
<div class="card-title">📝 Summary (Context Compression)</div>
<div class="card-desc">${summaryCfg.note}</div>
<div style="margin-top:0.4rem;"><code style="background:#1e293b;padding:0.3rem 0.6rem;border-radius:4px;font-size:0.8rem;color:#22d3ee;">${summaryCfg.default}</code> <span class="provider-tag">${summaryCfg.provider}</span></div>
</div>`;
}
// Action buttons
html += `<div class="action-buttons">
<a class="btn btn-success" href="http://localhost:8787" target="_blank">🚀 Open Web UI</a>
<a class="btn btn-secondary" href="http://localhost:9876/welcome.html">← Back to Setup</a>
</div>`;
content.innerHTML = html;
// If manual config, populate the model dropdowns
if (!autoConfig && data.primary_provider) {
const list = document.getElementById('model-list');
let listHtml = '';
for (const [role, cfg] of Object.entries(models)) {
if (!cfg.options || cfg.options.length === 0) continue;
const label = {
chat:'💬 Chat Model',
extraction:'🔍 Entity Extraction',
extraction_fallback:'🔁 Extraction Fallback',
vision:'👁️ Vision Model'
}[role] || role;
const desc = cfg.note || '';
listHtml += `<div class="model-option">
<div class="model-label">
<div class="model-name">${label}</div>
<div class="model-desc">${desc}</div>
</div>
<select class="model-select" data-role="${role}">
${cfg.options.map(m => `<option value="${m}"${m === cfg.default ? ' selected' : ''}>${m}</option>`).join('')}
</select>
</div>`;
}
list.innerHTML = listHtml;
}
}
async function saveModels() {
const selects = document.querySelectorAll('[data-role]');
const models = {};
selects.forEach(sel => {
const role = sel.getAttribute('data-role');
models[role] = sel.value;
});
const status = document.getElementById('save-status');
status.className = 'status-msg loading';
status.textContent = 'Saving...';
try {
const res = await fetch(`${API}/api/env/models/save`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ models }),
});
const data = await res.json();
if (data.status === 'ok') {
status.className = 'status-msg success';
status.textContent = '✅ Model configuration saved!';
setTimeout(() => { status.className = 'status-msg'; }, 3000);
} else {
status.className = 'status-msg error';
status.textContent = '❌ ' + (data.error || 'Save failed');
}
} catch (e) {
status.className = 'status-msg error';
status.textContent = '❌ Could not reach setup server';
}
}
</script>
</body>
</html>