@opennodes/registry 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/importers.js +7 -1
- package/src/search.js +37 -2
- package/src/server.js +3 -2
- package/src/web/index.html +271 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opennodes/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "OpenNodes (ONP) reference registry: node registration with proof-of-resource qualification (Stage A/B/C), transparent ranking, enforceable estimates, catalog importers (OpenRouter, Hugging Face, models.dev, Ollama), MCP surface, and the web app (catalog, chat, advisor, Node Builder)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@opennodes/core": "0.1.
|
|
46
|
+
"@opennodes/core": "0.1.17",
|
|
47
47
|
"pg": "^8.13.1"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/importers.js
CHANGED
|
@@ -247,6 +247,11 @@ export async function importHuggingFace(store, router, hub = []) {
|
|
|
247
247
|
|
|
248
248
|
export const OLLAMA_LIBRARY_URL = 'https://ollama.com/library';
|
|
249
249
|
|
|
250
|
+
/** Text of an HTML fragment: the library page escapes apostrophes and ampersands (' &). */
|
|
251
|
+
const decodeEntities = (t) => t.replace(/&(#(\d+)|#x([0-9a-f]+)|amp|lt|gt|quot|apos);/gi, (m, _, dec, hex) =>
|
|
252
|
+
dec ? String.fromCodePoint(Number(dec)) : hex ? String.fromCodePoint(parseInt(hex, 16))
|
|
253
|
+
: { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'" }[m.slice(1, -1).toLowerCase()]);
|
|
254
|
+
|
|
250
255
|
/** Parse ollama.com/library HTML into entries. Resilient to styling churn:
|
|
251
256
|
* anchors on /library/{name}, spans classified by content (sizes look like "27b"/"270m"). */
|
|
252
257
|
export function parseOllamaLibrary(html) {
|
|
@@ -256,7 +261,8 @@ export function parseOllamaLibrary(html) {
|
|
|
256
261
|
const name = block.match(/^([a-z0-9._-]+)"/)?.[1];
|
|
257
262
|
if (!name) continue;
|
|
258
263
|
const chunk = block.slice(0, 6000);
|
|
259
|
-
const
|
|
264
|
+
const rawDescription = chunk.match(/<p[^>]*class="[^"]*max-w-lg[^"]*"[^>]*>\s*([^<]{1,400}?)\s*<\/p>/)?.[1]?.trim();
|
|
265
|
+
const description = rawDescription ? decodeEntities(rawDescription) : null;
|
|
260
266
|
const spans = [...chunk.matchAll(/<span[^>]*class="[^"]*inline-flex[^"]*"[^>]*>\s*([^<]{1,40}?)\s*<\/span>/g)].map((m) => m[1].trim());
|
|
261
267
|
const sizes = spans.filter((s) => /^\d+(\.\d+)?[mb]$/i.test(s));
|
|
262
268
|
const capabilities = spans.filter((s) => !/^\d+(\.\d+)?[mb]$/i.test(s));
|
package/src/search.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Offering search + transparent ranking (ONP-3 §5–6).
|
|
2
|
-
import { inJurisdiction } from '@opennodes/core';
|
|
2
|
+
import { inJurisdiction, localSizes, pullsOf, specialtyOf, isEmbedder } from '@opennodes/core';
|
|
3
3
|
|
|
4
4
|
export const RANK_COMPONENTS = { price: 0.35, tier: 0.35, probe_success: 0.30 };
|
|
5
5
|
const TIER_SCORE = { unverified: 0, community: 0.4, verified: 0.8, attested: 1.0 };
|
|
@@ -155,6 +155,21 @@ export async function searchOfferingsPaged(store, query) {
|
|
|
155
155
|
items = items.filter((o) => JSON.stringify(o.model).toLowerCase().includes(needle)
|
|
156
156
|
|| o.offering_id.includes(needle) || o.node_id.includes(needle));
|
|
157
157
|
}
|
|
158
|
+
// Local models (the Ollama library) have no server: they run on the visitor's own machine and are
|
|
159
|
+
// listed apart from hosted offerings. `memory_gb` keeps the local models with a size that fits.
|
|
160
|
+
if (q('memory_gb')) {
|
|
161
|
+
const gb = Number(q('memory_gb'));
|
|
162
|
+
items = items.filter((o) => !o.local || !localSizes(o).length || localSizes(o)[0].memory_gb <= gb);
|
|
163
|
+
}
|
|
164
|
+
const counts = { hosted: items.filter((o) => !o.local).length, local: items.filter((o) => o.local).length };
|
|
165
|
+
if (q('local') === 'true') items = items.filter((o) => o.local);
|
|
166
|
+
if (q('local') === 'false') items = items.filter((o) => !o.local);
|
|
167
|
+
// `ids`: offering or model ids, comma-separated (the registry UI sends the models installed in the
|
|
168
|
+
// visitor's own Ollama, which the browser read from it directly)
|
|
169
|
+
if (q('ids') != null) {
|
|
170
|
+
const ids = new Set(q('ids').split(',').map((s) => s.trim()).filter(Boolean));
|
|
171
|
+
items = items.filter((o) => ids.has(o.offering_id) || ids.has(o.binding?.model_id));
|
|
172
|
+
}
|
|
158
173
|
|
|
159
174
|
// Rank depends on the filtered set: annotate copies, never the shared cached offerings.
|
|
160
175
|
items = items.map((o) => ({ ...o }));
|
|
@@ -162,7 +177,19 @@ export async function searchOfferingsPaged(store, query) {
|
|
|
162
177
|
// most expensive offering: one outlier made almost everything "cheap" and every import tie.
|
|
163
178
|
const prices = items.map((o) => o.pricing.input_per_mtok).filter((p) => p != null).sort((a, b) => a - b);
|
|
164
179
|
const cheaperThan = (p) => { let lo = 0, hi = prices.length; while (lo < hi) { const m = (lo + hi) >> 1; if (prices[m] < p) lo = m + 1; else hi = m; } return lo; };
|
|
180
|
+
// Local models rank by popularity among the listed local models (log of Ollama pulls): price, trust
|
|
181
|
+
// tier and checks describe a server, and a local model has none.
|
|
182
|
+
const maxPulls = Math.max(1, ...items.filter((o) => o.local).map(pullsOf));
|
|
165
183
|
for (const o of items) {
|
|
184
|
+
if (o.local) {
|
|
185
|
+
const sizes = localSizes(o);
|
|
186
|
+
o.local = { ...o.local, sizes_memory: sizes.map(({ tag, memory_gb }) => ({ tag, memory_gb })) };
|
|
187
|
+
o.specialty = isEmbedder(o) ? 'embedding' : specialtyOf(o);
|
|
188
|
+
const popularity = pullsOf(o) > 1 ? Math.log10(pullsOf(o)) / Math.log10(Math.max(10, maxPulls)) : 0;
|
|
189
|
+
o.rank = round2(popularity);
|
|
190
|
+
o.rank_explanation = { basis: 'local', weights: { popularity: 1 }, components: { popularity: round2(popularity) }, pulls: o.local.pulls ?? null };
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
166
193
|
const p = o.pricing.input_per_mtok;
|
|
167
194
|
const components = {
|
|
168
195
|
price: p == null ? 0 : prices.length > 1 ? 1 - cheaperThan(p) / (prices.length - 1) : 1,
|
|
@@ -178,7 +205,15 @@ export async function searchOfferingsPaged(store, query) {
|
|
|
178
205
|
const ttftOf = (o) => o.observed.ttft_ms?.p50 ?? o.serving?.expected_ttft_ms?.p50 ?? Infinity;
|
|
179
206
|
const tpsOf = (o) => (o.observed.tps > 0 ? o.observed.tps : null) ?? o.serving?.expected_tps?.p50 ?? -Infinity;
|
|
180
207
|
const sort = q('sort') ?? 'rank';
|
|
208
|
+
const minMemory = (o) => o.local?.sizes_memory?.[0]?.memory_gb ?? Infinity;
|
|
181
209
|
items.sort((a, b) => {
|
|
210
|
+
// hosted before local in a mixed list: their scores measure different things
|
|
211
|
+
if (Boolean(a.local) !== Boolean(b.local)) return Number(Boolean(a.local)) - Number(Boolean(b.local));
|
|
212
|
+
if (a.local) {
|
|
213
|
+
if (sort === 'size') return minMemory(a) - minMemory(b) || b.rank - a.rank || a.offering_id.localeCompare(b.offering_id);
|
|
214
|
+
if (sort === 'name') return a.offering_id.localeCompare(b.offering_id);
|
|
215
|
+
return b.rank - a.rank || pullsOf(b) - pullsOf(a) || a.offering_id.localeCompare(b.offering_id);
|
|
216
|
+
}
|
|
182
217
|
if (sort === 'price') return (a.pricing.input_per_mtok ?? Infinity) - (b.pricing.input_per_mtok ?? Infinity);
|
|
183
218
|
if (sort === 'ttft') return ttftOf(a) - ttftOf(b);
|
|
184
219
|
if (sort === 'tps') return tpsOf(b) - tpsOf(a);
|
|
@@ -192,7 +227,7 @@ export async function searchOfferingsPaged(store, query) {
|
|
|
192
227
|
|
|
193
228
|
const limit = Math.min(Number(q('limit') ?? 50), 200);
|
|
194
229
|
const offset = Math.max(0, Math.floor(Number(q('offset') ?? 0)) || 0);
|
|
195
|
-
return { offerings: items.slice(offset, offset + limit), total: items.length, offset };
|
|
230
|
+
return { offerings: items.slice(offset, offset + limit), total: items.length, offset, counts };
|
|
196
231
|
}
|
|
197
232
|
|
|
198
233
|
export async function searchOfferings(store, query) {
|
package/src/server.js
CHANGED
|
@@ -350,8 +350,9 @@ export async function startRegistry({
|
|
|
350
350
|
}],
|
|
351
351
|
|
|
352
352
|
['GET', '/v0/offerings', async (req, res, { query }) => {
|
|
353
|
-
const { offerings, total, offset } = await searchOfferingsPaged(store, query);
|
|
354
|
-
|
|
353
|
+
const { offerings, total, offset, counts } = await searchOfferingsPaged(store, query);
|
|
354
|
+
// total = matches before `offset`/`limit`; counts = hosted/local matches before the `local` filter
|
|
355
|
+
sendJson(res, 200, { offerings, total, offset, counts });
|
|
355
356
|
}],
|
|
356
357
|
|
|
357
358
|
['GET', '/v0/offerings/:nodeId/:offeringId', async (req, res, { params }) => {
|
package/src/web/index.html
CHANGED
|
@@ -138,6 +138,20 @@
|
|
|
138
138
|
background: var(--panel); color: var(--muted); cursor: pointer; font-family: inherit; }
|
|
139
139
|
.toggle.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
|
|
140
140
|
.switchrow { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; }
|
|
141
|
+
.kindtabs { display: flex; gap: 1.4rem; border-bottom: 1px solid var(--line); margin: 0.6rem 0 0.7rem; }
|
|
142
|
+
.kindtabs button { font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--muted); background: none; border: none;
|
|
143
|
+
border-bottom: 2px solid transparent; padding: 0.35rem 0 0.5rem; margin-bottom: -1px; cursor: pointer; }
|
|
144
|
+
.kindtabs button:hover { color: var(--ink); }
|
|
145
|
+
.kindtabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
|
|
146
|
+
.kindtabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
147
|
+
.kindtabs .counts { font-weight: 400; margin-left: 0.25rem; }
|
|
148
|
+
.runrow code { font-size: 0.78rem; }
|
|
149
|
+
.olbox { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; font-size: 0.82rem; margin: 0 0 0.7rem; }
|
|
150
|
+
.olbox input { font: inherit; font-size: 0.78rem; width: 12.5rem; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 0.3rem 0.5rem; }
|
|
151
|
+
.olbox .ok { color: var(--accent); font-weight: 600; }
|
|
152
|
+
.olhelp { font-size: 0.8rem; margin: 0 0 0.8rem; }
|
|
153
|
+
.olhelp pre { font-size: 0.74rem; overflow-x: auto; margin: 0.3rem 0 0.6rem; }
|
|
154
|
+
.chip.inst { color: var(--on-accent, #fff); background: var(--accent); border-color: var(--accent); }
|
|
141
155
|
.switch { width: 30px; height: 17px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; flex: none; }
|
|
142
156
|
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); transition: left 0.15s; }
|
|
143
157
|
.switchrow.on .switch { background: var(--accent); } .switchrow.on .switch::after { left: 15px; }
|
|
@@ -247,20 +261,36 @@
|
|
|
247
261
|
<h1>Models</h1>
|
|
248
262
|
<span class="counts" id="m-counts"></span>
|
|
249
263
|
</div>
|
|
250
|
-
<
|
|
264
|
+
<div class="kindtabs" id="m-kind" role="tablist" aria-label="Kind of listing">
|
|
265
|
+
<button role="tab" data-kind="hosted" aria-selected="true">Hosted <span class="counts" id="m-n-hosted"></span></button>
|
|
266
|
+
<button role="tab" data-kind="local" aria-selected="false">Runs on your machine <span class="counts" id="m-n-local"></span></button>
|
|
267
|
+
</div>
|
|
268
|
+
<p class="sub hostedonly">Search across registered AI nodes and imported catalogs — pick a model on the left, its full card is on the right. Claimed values are never blended with measured ones.</p>
|
|
269
|
+
<p class="sub localonly" hidden>Models you download and run yourself with Ollama: no server, no account, and your data stays on your machine. There is nothing to verify remotely, so they are ranked by popularity (Ollama pulls); memory needs are 4-bit estimates.</p>
|
|
270
|
+
<div class="olbox localonly" id="ol-box" hidden>
|
|
271
|
+
<button class="btn sec" id="ol-check" type="button">Check my Ollama</button>
|
|
272
|
+
<input id="ol-base" aria-label="Your Ollama address" spellcheck="false">
|
|
273
|
+
<span id="ol-status" class="sub">Asks the Ollama on your own computer which models you have. The answer stays in your browser; nothing is sent to this registry.</span>
|
|
274
|
+
<span class="switchrow" id="f-installed" hidden><span class="switch"></span><b style="font-size:0.78rem">Installed only</b></span>
|
|
275
|
+
</div>
|
|
276
|
+
<div class="olhelp localonly" id="ol-help" hidden></div>
|
|
251
277
|
<div class="toolbar">
|
|
252
278
|
<input type="text" id="f-q" placeholder="Search models, families, nodes…">
|
|
253
|
-
<span class="switchrow" id="f-verified" title="identity-fingerprinted · context-verified · continuously probed"><span class="switch"></span><b style="font-size:0.78rem">Verified only</b></span>
|
|
254
|
-
<span class="switchrow" id="f-eea" title="operators in the EU, Iceland, Liechtenstein or Norway — declared by registered nodes, inferred for imported listings of known European providers"><span class="switch"></span><b style="font-size:0.78rem">EU/EEA</b></span>
|
|
279
|
+
<span class="switchrow hostedonly" id="f-verified" title="identity-fingerprinted · context-verified · continuously probed"><span class="switch"></span><b style="font-size:0.78rem">Verified only</b></span>
|
|
280
|
+
<span class="switchrow hostedonly" id="f-eea" title="operators in the EU, Iceland, Liechtenstein or Norway — declared by registered nodes, inferred for imported listings of known European providers"><span class="switch"></span><b style="font-size:0.78rem">EU/EEA</b></span>
|
|
255
281
|
<select id="f-modality">
|
|
256
282
|
<option value="">any modality</option>
|
|
257
283
|
<option>text</option><option>multimodal</option><option>image</option>
|
|
258
284
|
<option>audio</option><option>video</option><option>embedding</option>
|
|
259
285
|
</select>
|
|
260
|
-
<button class="toggle" data-sup="tool_calls">tools</button>
|
|
261
|
-
<button class="toggle" data-sup="vision">vision</button>
|
|
262
|
-
<button class="toggle" data-sup="json_mode">json</button>
|
|
263
|
-
<input type="number" id="f-price" placeholder="max $/MTok in" min="0" step="0.05">
|
|
286
|
+
<button class="toggle hostedonly" data-sup="tool_calls">tools</button>
|
|
287
|
+
<button class="toggle hostedonly" data-sup="vision">vision</button>
|
|
288
|
+
<button class="toggle hostedonly" data-sup="json_mode">json</button>
|
|
289
|
+
<input type="number" class="hostedonly" id="f-price" placeholder="max $/MTok in" min="0" step="0.05">
|
|
290
|
+
<select id="f-mem" class="localonly" hidden title="RAM (or GPU VRAM) you can give the model — keeps the models with a size that fits">
|
|
291
|
+
<option value="">fits: any memory</option><option value="4">fits in 4 GB</option><option value="8">fits in 8 GB</option>
|
|
292
|
+
<option value="16">fits in 16 GB</option><option value="24">fits in 24 GB</option><option value="32">fits in 32 GB</option><option value="64">fits in 64 GB</option>
|
|
293
|
+
</select>
|
|
264
294
|
<select id="f-sort"><option value="rank">sort: rank</option><option value="price">sort: price</option><option value="ttft">sort: fastest first token</option><option value="tps">sort: throughput</option></select>
|
|
265
295
|
</div>
|
|
266
296
|
<details class="panel pad" id="advisor" style="margin:0.2rem 0 0.8rem">
|
|
@@ -295,7 +325,7 @@
|
|
|
295
325
|
<div class="statstrip" id="md-stats"></div>
|
|
296
326
|
<div id="md-score"></div>
|
|
297
327
|
<div class="secnav" id="md-nav"></div>
|
|
298
|
-
<h2 id="sec-offerings">Offerings <span class="counts" id="md-count"></span></h2>
|
|
328
|
+
<h2 id="sec-offerings"><span id="md-offtitle">Offerings</span> <span class="counts" id="md-count"></span></h2>
|
|
299
329
|
<div class="panel tablewrap" id="md-offerings"></div>
|
|
300
330
|
<h2 id="sec-play">Playground <span class="counts">runs in your browser — your prompt goes straight to the node, never through this registry</span></h2>
|
|
301
331
|
<div class="panel pad" style="max-width:56rem">
|
|
@@ -594,6 +624,130 @@ function route() {
|
|
|
594
624
|
window.addEventListener('hashchange', route);
|
|
595
625
|
|
|
596
626
|
/* ---------- catalog ---------- */
|
|
627
|
+
// Hosted offerings and local models (no server: they run on the visitor's machine) are listed apart.
|
|
628
|
+
let listKind = 'hosted';
|
|
629
|
+
try { if (localStorage.getItem('onp-list-kind') === 'local') listKind = 'local'; } catch { /* storage blocked */ }
|
|
630
|
+
const SORTS = {
|
|
631
|
+
hosted: [['rank', 'sort: rank'], ['price', 'sort: price'], ['ttft', 'sort: fastest first token'], ['tps', 'sort: throughput']],
|
|
632
|
+
local: [['rank', 'sort: most pulled'], ['size', 'sort: smallest first'], ['name', 'sort: name']],
|
|
633
|
+
};
|
|
634
|
+
function applyKind() {
|
|
635
|
+
document.querySelectorAll('#m-kind [data-kind]').forEach((b) => b.setAttribute('aria-selected', String(b.dataset.kind === listKind)));
|
|
636
|
+
document.querySelectorAll('#view-models .hostedonly').forEach((el) => { el.hidden = listKind !== 'hosted'; });
|
|
637
|
+
document.querySelectorAll('#view-models .localonly').forEach((el) => { el.hidden = listKind !== 'local'; });
|
|
638
|
+
const sel = $('#f-sort'), cur = sel.value;
|
|
639
|
+
sel.innerHTML = SORTS[listKind].map(([v, l]) => `<option value="${v}">${l}</option>`).join('');
|
|
640
|
+
if (SORTS[listKind].some(([v]) => v === cur)) sel.value = cur;
|
|
641
|
+
}
|
|
642
|
+
applyKind();
|
|
643
|
+
document.querySelectorAll('#m-kind [data-kind]').forEach((b) => b.addEventListener('click', () => {
|
|
644
|
+
if (b.dataset.kind === listKind) return;
|
|
645
|
+
listKind = b.dataset.kind;
|
|
646
|
+
try { localStorage.setItem('onp-list-kind', listKind); } catch { /* storage blocked */ }
|
|
647
|
+
applyKind();
|
|
648
|
+
search();
|
|
649
|
+
if (listKind === 'local') autoCheckOllama();
|
|
650
|
+
}));
|
|
651
|
+
|
|
652
|
+
/* ---------- your Ollama: which local models are installed ----------
|
|
653
|
+
The browser asks the visitor's own Ollama (/api/tags) directly — only after a click, or on later
|
|
654
|
+
visits once a check has succeeded. The list of models never reaches this registry, except as the
|
|
655
|
+
ids of an "installed only" search. */
|
|
656
|
+
const OLLAMA_DEFAULT = 'http://127.0.0.1:11434';
|
|
657
|
+
const ollama = { base: OLLAMA_DEFAULT, installed: null, state: 'unknown', count: 0 };
|
|
658
|
+
try { ollama.base = localStorage.getItem('onp-ollama-base') || OLLAMA_DEFAULT; } catch { /* storage blocked */ }
|
|
659
|
+
$('#ol-base').value = ollama.base;
|
|
660
|
+
const olHost = () => { try { return new URL(ollama.base).host; } catch { return ollama.base; } };
|
|
661
|
+
/** Tags of this local model installed in the visitor's Ollama ("3b", "latest"), or null. */
|
|
662
|
+
function installedTags(o) {
|
|
663
|
+
if (!ollama.installed || !o?.local) return null;
|
|
664
|
+
return ollama.installed.get(String(o.binding?.model_id ?? o.offering_id).split(':')[0].toLowerCase()) ?? null;
|
|
665
|
+
}
|
|
666
|
+
async function checkOllama() {
|
|
667
|
+
ollama.base = ($('#ol-base').value.trim() || OLLAMA_DEFAULT).replace(/\/+$/, '');
|
|
668
|
+
try { localStorage.setItem('onp-ollama-base', ollama.base); } catch { /* storage blocked */ }
|
|
669
|
+
$('#ol-check').disabled = true;
|
|
670
|
+
$('#ol-status').textContent = 'asking your Ollama…';
|
|
671
|
+
try {
|
|
672
|
+
const r = await fetch(ollama.base + '/api/tags', { signal: AbortSignal.timeout(5000) });
|
|
673
|
+
if (!r.ok) throw new Error('status ' + r.status);
|
|
674
|
+
const { models = [] } = await r.json();
|
|
675
|
+
ollama.installed = new Map();
|
|
676
|
+
for (const m of models) {
|
|
677
|
+
const [base, tag = 'latest'] = String(m.name ?? m.model ?? '').toLowerCase().split(':');
|
|
678
|
+
if (!base) continue;
|
|
679
|
+
if (!ollama.installed.has(base)) ollama.installed.set(base, []);
|
|
680
|
+
ollama.installed.get(base).push(tag);
|
|
681
|
+
}
|
|
682
|
+
ollama.count = models.length;
|
|
683
|
+
ollama.state = 'ok';
|
|
684
|
+
try { localStorage.setItem('onp-ollama-ok', '1'); } catch { /* storage blocked */ }
|
|
685
|
+
} catch {
|
|
686
|
+
ollama.installed = null;
|
|
687
|
+
// A no-cors request still reaches a running server: if it goes through, Ollama is up and only
|
|
688
|
+
// refuses this page's origin (OLLAMA_ORIGINS); if it fails too, nothing answered.
|
|
689
|
+
let reachable = false;
|
|
690
|
+
try { await fetch(ollama.base + '/api/version', { mode: 'no-cors', signal: AbortSignal.timeout(4000) }); reachable = true; } catch { /* not running */ }
|
|
691
|
+
ollama.state = reachable ? 'blocked' : 'down';
|
|
692
|
+
} finally { $('#ol-check').disabled = false; }
|
|
693
|
+
const filtered = $('#f-installed').classList.contains('on');
|
|
694
|
+
renderOllamaStatus();
|
|
695
|
+
markInstalled();
|
|
696
|
+
if (filtered) search(); // re-filter by the new answer, or drop the filter if Ollama no longer answers
|
|
697
|
+
}
|
|
698
|
+
function autoCheckOllama() {
|
|
699
|
+
let remembered = false;
|
|
700
|
+
try { remembered = localStorage.getItem('onp-ollama-ok') === '1'; } catch { /* storage blocked */ }
|
|
701
|
+
if (remembered && ollama.state === 'unknown') checkOllama();
|
|
702
|
+
}
|
|
703
|
+
function renderOllamaStatus() {
|
|
704
|
+
const status = $('#ol-status'), help = $('#ol-help');
|
|
705
|
+
$('#f-installed').hidden = ollama.state !== 'ok';
|
|
706
|
+
if (ollama.state !== 'ok') $('#f-installed').classList.remove('on');
|
|
707
|
+
help.hidden = true;
|
|
708
|
+
if (ollama.state === 'ok') {
|
|
709
|
+
status.innerHTML = `<span class="ok">✓ Your Ollama at ${esc(olHost())}</span> has ${ollama.count} model${ollama.count === 1 ? '' : 's'} — installed ones are marked.`;
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
const origin = location.origin;
|
|
713
|
+
if (ollama.state === 'blocked') {
|
|
714
|
+
status.innerHTML = `<b>Ollama is running at ${esc(olHost())} but does not allow this page.</b> Allow it once, then quit and restart Ollama:`;
|
|
715
|
+
help.innerHTML = `<b>Windows</b> (PowerShell or cmd)<pre><code>setx OLLAMA_ORIGINS "${esc(origin)}"</code></pre>
|
|
716
|
+
<b>macOS</b><pre><code>launchctl setenv OLLAMA_ORIGINS "${esc(origin)}"</code></pre>
|
|
717
|
+
<b>Linux</b> (systemd): <code>sudo systemctl edit ollama</code>, add the two lines below, then <code>sudo systemctl restart ollama</code><pre><code>[Service]
|
|
718
|
+
Environment="OLLAMA_ORIGINS=${esc(origin)}"</code></pre>
|
|
719
|
+
<span class="sub">This lets this page read which models you have and use the playground; other sites stay blocked. To allow more origins, separate them with commas.</span>`;
|
|
720
|
+
help.hidden = false;
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
status.innerHTML = `<b>No Ollama answered at ${esc(olHost())}.</b> Start it, or install it from <a href="https://ollama.com/download" target="_blank" rel="noopener">ollama.com</a>, then check again. If your browser asked whether this page may reach devices on your network, allow it.`;
|
|
724
|
+
}
|
|
725
|
+
/** Mark installed models in the list, on the open card and in the playground note. */
|
|
726
|
+
function markInstalled() {
|
|
727
|
+
document.querySelectorAll('.mitem').forEach((el) => {
|
|
728
|
+
const o = lastResults.find((x) => `${x.node_id}/${x.offering_id}` === el.dataset.key);
|
|
729
|
+
if (!o?.local) return;
|
|
730
|
+
const tags = installedTags(o);
|
|
731
|
+
const chip = el.querySelector('.chip.loc, .chip.inst');
|
|
732
|
+
if (!chip) return;
|
|
733
|
+
chip.className = tags ? 'chip inst' : 'chip loc';
|
|
734
|
+
chip.textContent = tags ? 'INSTALLED' : 'LOCAL';
|
|
735
|
+
chip.title = tags ? 'installed in your Ollama: ' + tags.join(', ') : '';
|
|
736
|
+
});
|
|
737
|
+
const inst = $('#md-inst');
|
|
738
|
+
if (inst) {
|
|
739
|
+
const o = pgOfferings.find((x) => x.local);
|
|
740
|
+
const tags = installedTags(o);
|
|
741
|
+
inst.hidden = ollama.state !== 'ok' || !o;
|
|
742
|
+
inst.className = tags ? 'chip inst' : 'chip';
|
|
743
|
+
inst.textContent = tags ? `INSTALLED: ${tags.join(', ')}` : 'NOT INSTALLED';
|
|
744
|
+
}
|
|
745
|
+
pgUpdateNote();
|
|
746
|
+
}
|
|
747
|
+
$('#ol-check').addEventListener('click', checkOllama);
|
|
748
|
+
$('#ol-base').addEventListener('keydown', (e) => { if (e.key === 'Enter') checkOllama(); });
|
|
749
|
+
$('#f-installed').addEventListener('click', () => { $('#f-installed').classList.toggle('on'); search(); });
|
|
750
|
+
if (listKind === 'local') autoCheckOllama();
|
|
597
751
|
const sup = new Set();
|
|
598
752
|
document.querySelectorAll('.toggle').forEach((b) => b.addEventListener('click', () => {
|
|
599
753
|
b.classList.toggle('on'); b.classList.contains('on') ? sup.add(b.dataset.sup) : sup.delete(b.dataset.sup); search();
|
|
@@ -602,7 +756,7 @@ $('#f-verified').addEventListener('click', () => { $('#f-verified').classList.to
|
|
|
602
756
|
$('#f-eea').addEventListener('click', () => { $('#f-eea').classList.toggle('on'); search(); });
|
|
603
757
|
let debounce;
|
|
604
758
|
for (const id of ['f-q', 'f-price']) $('#' + id).addEventListener('input', () => { clearTimeout(debounce); debounce = setTimeout(search, 250); });
|
|
605
|
-
for (const id of ['f-modality', 'f-sort']) $('#' + id).addEventListener('change', search);
|
|
759
|
+
for (const id of ['f-modality', 'f-sort', 'f-mem']) $('#' + id).addEventListener('change', search);
|
|
606
760
|
|
|
607
761
|
function measuredBits(o) {
|
|
608
762
|
const obs = o.observed || {};
|
|
@@ -663,7 +817,7 @@ let listQuery = '', listTotal = 0, listPage = 0;
|
|
|
663
817
|
function updatePager() {
|
|
664
818
|
const pages = Math.max(1, Math.ceil(listTotal / PAGE));
|
|
665
819
|
const from = listTotal ? listPage * PAGE + 1 : 0, to = Math.min(listTotal, (listPage + 1) * PAGE);
|
|
666
|
-
$('#m-counts').textContent = fmtInt(listTotal) + ' offerings' + (pages > 1 ? ` · ${fmtInt(from)}–${fmtInt(to)}` : '');
|
|
820
|
+
$('#m-counts').textContent = fmtInt(listTotal) + (listKind === 'local' ? ' local models' : ' offerings') + (pages > 1 ? ` · ${fmtInt(from)}–${fmtInt(to)}` : '');
|
|
667
821
|
const pager = $('#m-pager');
|
|
668
822
|
if (pages <= 1) { pager.innerHTML = ''; return; }
|
|
669
823
|
const btn = (label, page, title) => `<button class="pgbtn" data-page="${page}" title="${title}"${page < 0 || page >= pages || page === listPage ? ' disabled' : ''}>${label}</button>`;
|
|
@@ -704,15 +858,22 @@ async function search() {
|
|
|
704
858
|
const p = new URLSearchParams({ limit: PAGE });
|
|
705
859
|
if ($('#f-q').value) p.set('q', $('#f-q').value);
|
|
706
860
|
if ($('#f-modality').value) p.set('modality', $('#f-modality').value);
|
|
707
|
-
|
|
708
|
-
if (
|
|
709
|
-
|
|
710
|
-
|
|
861
|
+
p.set('local', String(listKind === 'local'));
|
|
862
|
+
if (listKind === 'hosted') { // trust, location, price and capabilities describe a server
|
|
863
|
+
if ($('#f-verified').classList.contains('on')) p.set('tier', 'verified');
|
|
864
|
+
if ($('#f-eea').classList.contains('on')) p.set('jurisdiction', 'eea');
|
|
865
|
+
if ($('#f-price').value) p.set('max_input_price', $('#f-price').value);
|
|
866
|
+
if (sup.size) p.set('supports', [...sup].join(','));
|
|
867
|
+
} else {
|
|
868
|
+
if ($('#f-mem').value) p.set('memory_gb', $('#f-mem').value);
|
|
869
|
+
if ($('#f-installed').classList.contains('on') && ollama.installed) p.set('ids', [...ollama.installed.keys()].join(','));
|
|
870
|
+
}
|
|
711
871
|
p.set('sort', $('#f-sort').value);
|
|
712
872
|
listQuery = p.toString();
|
|
713
873
|
try {
|
|
714
|
-
const { offerings, total } = await api('/v0/offerings?' + p);
|
|
874
|
+
const { offerings, total, counts } = await api('/v0/offerings?' + p);
|
|
715
875
|
if (listQuery !== p.toString()) return; // a newer search is under way
|
|
876
|
+
if (counts) { $('#m-n-hosted').textContent = fmtInt(counts.hosted); $('#m-n-local').textContent = fmtInt(counts.local); }
|
|
716
877
|
lastResults = offerings;
|
|
717
878
|
listTotal = total ?? offerings.length;
|
|
718
879
|
listPage = 0;
|
|
@@ -780,7 +941,28 @@ function selectModel(el) {
|
|
|
780
941
|
}
|
|
781
942
|
|
|
782
943
|
let lastResults = [];
|
|
944
|
+
/** "1b–27b · from ~1.6 GB" for a local model's sizes (4-bit memory estimates from the registry). */
|
|
945
|
+
function sizesBit(o) {
|
|
946
|
+
const sz = o.local?.sizes_memory ?? [];
|
|
947
|
+
if (!sz.length) return '';
|
|
948
|
+
return (sz.length > 1 ? `${sz[0].tag}–${sz.at(-1).tag}` : sz[0].tag) + ` · from ~${sz[0].memory_gb} GB`;
|
|
949
|
+
}
|
|
950
|
+
function renderLocalItem(o) {
|
|
951
|
+
const tags = installedTags(o);
|
|
952
|
+
return `<div class="mitem" data-artifact="${esc(o.model.artifact)}" data-key="${esc(o.node_id + '/' + o.offering_id)}">
|
|
953
|
+
<div class="t">
|
|
954
|
+
<span class="nm">${esc(o.model.name)}</span>
|
|
955
|
+
${o.specialty ? `<span class="chip">${esc(o.specialty)}</span>` : ''}
|
|
956
|
+
${tags ? `<span class="chip inst" title="installed in your Ollama: ${esc(tags.join(', '))}">INSTALLED</span>` : '<span class="chip loc">LOCAL</span>'}
|
|
957
|
+
</div>
|
|
958
|
+
<div class="b">
|
|
959
|
+
${sizesBit(o) ? `<span>${esc(sizesBit(o))}</span>` : ''}
|
|
960
|
+
${o.local.pulls ? `<span>${esc(o.local.pulls)} pulls</span>` : ''}
|
|
961
|
+
</div>
|
|
962
|
+
</div>`;
|
|
963
|
+
}
|
|
783
964
|
function renderItem(o) {
|
|
965
|
+
if (o.local) return renderLocalItem(o);
|
|
784
966
|
const obs = o.observed || {};
|
|
785
967
|
return `<div class="mitem" data-artifact="${esc(o.model.artifact)}" data-key="${esc(o.node_id + '/' + o.offering_id)}">
|
|
786
968
|
<div class="t">
|
|
@@ -890,6 +1072,15 @@ function renderScore(artifact) {
|
|
|
890
1072
|
const host = $('#md-score');
|
|
891
1073
|
const o = listedOffering;
|
|
892
1074
|
if (!o?.rank_explanation || o.model.artifact !== artifact) { host.innerHTML = ''; return; }
|
|
1075
|
+
if (o.rank_explanation.basis === 'local') {
|
|
1076
|
+
host.innerHTML = `<details class="scorebox" open>
|
|
1077
|
+
<summary>Popularity <b class="mono">${fmt(o.rank)}</b> <span class="sub">among the local models in the current list</span></summary>
|
|
1078
|
+
<table><tr><td>Ollama pulls</td><td class="num mono">${esc(o.rank_explanation.pulls ?? '—')}</td><td class="num mono"><b>${fmt(o.rank)}</b></td>
|
|
1079
|
+
<td class="sub">log scale against the most-pulled local model listed (1.00)</td></tr></table>
|
|
1080
|
+
<p class="sub" style="margin:0.5rem 0 0; font-size:0.78rem">Local models are not scored on price, trust tier or checks: there is no server behind them, and they cost nothing per token. How well one runs depends on your machine.</p>
|
|
1081
|
+
</details>`;
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
893
1084
|
const { weights, components } = o.rank_explanation;
|
|
894
1085
|
const obs = o.observed || {};
|
|
895
1086
|
const why = {
|
|
@@ -931,6 +1122,7 @@ async function loadModel(artifact) {
|
|
|
931
1122
|
const tierOrder = { verified: 3, community: 2, unverified: 1 };
|
|
932
1123
|
list.sort((a, b) => (tierOrder[b.tier] ?? 0) - (tierOrder[a.tier] ?? 0) || (a.pricing.input_per_mtok ?? Infinity) - (b.pricing.input_per_mtok ?? Infinity));
|
|
933
1124
|
const first = list[0];
|
|
1125
|
+
const isLocal = list.every((o) => o.local); // an Ollama library model: no server, runs on the visitor's machine
|
|
934
1126
|
$('#md-title').textContent = first.model.name;
|
|
935
1127
|
// the artifact chip links to its authoritative home: Hugging Face for hf: artifacts
|
|
936
1128
|
$('#md-artifact').innerHTML = artifact.startsWith('hf:')
|
|
@@ -947,9 +1139,13 @@ async function loadModel(artifact) {
|
|
|
947
1139
|
first.model.params_b ? `<span class="chip">${first.model.params_b}B</span>` : '',
|
|
948
1140
|
`<span class="chip">${esc(first.modality)}</span>`,
|
|
949
1141
|
first.model.family ? `<span class="chip">${esc(first.model.family)}</span>` : '',
|
|
1142
|
+
isLocal && first.specialty && first.specialty !== first.modality ? `<span class="chip">${esc(first.specialty)}</span>` : '',
|
|
1143
|
+
isLocal ? '<span class="chip loc">LOCAL</span><span class="chip" id="md-inst" hidden></span>' : '',
|
|
950
1144
|
...extLinks,
|
|
951
1145
|
].join('');
|
|
952
|
-
$('#md-
|
|
1146
|
+
$('#md-offtitle').textContent = isLocal ? 'Run it' : 'Offerings';
|
|
1147
|
+
if (isLocal) autoCheckOllama();
|
|
1148
|
+
$('#md-count').textContent = isLocal ? 'with Ollama, on your own machine' : list.length + ' node' + (list.length === 1 ? '' : 's');
|
|
953
1149
|
|
|
954
1150
|
// description (imported catalogs carry one; absent otherwise)
|
|
955
1151
|
const desc = list.map((o) => o.model.description).find(Boolean);
|
|
@@ -963,7 +1159,14 @@ async function loadModel(artifact) {
|
|
|
963
1159
|
const verified = list.filter((o) => o.tier === 'verified').length;
|
|
964
1160
|
const released = list.map((o) => o.model.released).find(Boolean);
|
|
965
1161
|
const stat = (v, l) => `<span class="stat"><span class="sv">${v}</span><span class="sl">${l}</span></span>`;
|
|
966
|
-
|
|
1162
|
+
const sizes = first.local?.sizes_memory ?? [];
|
|
1163
|
+
if (isLocal) $('#md-stats').innerHTML = [
|
|
1164
|
+
stat('free', 'RUNS ON YOUR MACHINE'),
|
|
1165
|
+
sizes.length ? stat(esc(sizes.map((x) => x.tag).join(' · ')), sizes.length === 1 ? 'SIZE' : 'SIZES') : '',
|
|
1166
|
+
sizes.length ? stat(`~${sizes[0].memory_gb} GB`, 'SMALLEST NEEDS (4-BIT EST.)') : '',
|
|
1167
|
+
first.local.pulls ? stat(esc(first.local.pulls), 'OLLAMA PULLS') : '',
|
|
1168
|
+
].filter(Boolean).join('');
|
|
1169
|
+
else $('#md-stats').innerHTML = [
|
|
967
1170
|
stat(!prices.length ? priceStr(first.pricing, first.node_id) : minP === 0 && maxP === 0 ? 'free' : (minP === maxP ? '$' + fmt(minP) : '$' + fmt(minP) + '–' + fmt(maxP)), '$/MTOK IN ACROSS NODES'),
|
|
968
1171
|
ctxMax ? stat(fmtInt(ctxMax), 'MAX CONTEXT') : '',
|
|
969
1172
|
stat(`${verified}/${list.length}`, 'VERIFIED NODES'),
|
|
@@ -974,7 +1177,7 @@ async function loadModel(artifact) {
|
|
|
974
1177
|
renderScore(artifact);
|
|
975
1178
|
|
|
976
1179
|
// section nav (anchors appear only for sections that render)
|
|
977
|
-
const navBits = [['#sec-offerings', 'OFFERINGS'], ['#sec-play', 'PLAYGROUND']];
|
|
1180
|
+
const navBits = [['#sec-offerings', isLocal ? 'RUN IT' : 'OFFERINGS'], ['#sec-play', 'PLAYGROUND']];
|
|
978
1181
|
|
|
979
1182
|
// playground targets: hosted offerings first, then the ones that run on the visitor's own computer,
|
|
980
1183
|
// then a custom endpoint
|
|
@@ -984,10 +1187,17 @@ async function loadModel(artifact) {
|
|
|
984
1187
|
$('#pg-customrow').hidden = pgOfferings.length > 0; // listing-only offerings leave just the custom endpoint
|
|
985
1188
|
$('#pg-out').textContent = '';
|
|
986
1189
|
$('#pg-meta').textContent = '';
|
|
987
|
-
|
|
1190
|
+
markInstalled();
|
|
988
1191
|
$('#pg-hosted').innerHTML = '';
|
|
989
1192
|
if (pgOfferings.length && pgOfferings.every(runsLocally)) showHostedAlternatives(first, artifact);
|
|
990
|
-
|
|
1193
|
+
const runName = first.binding?.model_id ?? first.model.name;
|
|
1194
|
+
const verb = first.modality === 'embedding' ? 'pull' : 'run'; // embedding models answer the API, not a chat prompt
|
|
1195
|
+
if (isLocal) $('#md-offerings').innerHTML = `<table class="grid num"><thead><tr><th>SIZE</th><th>MEMORY NEEDED</th><th>COMMAND</th></tr></thead><tbody>`
|
|
1196
|
+
+ (sizes.length ? sizes.map((x) => `<tr class="runrow"><td><b>${esc(x.tag)}</b></td><td>~${x.memory_gb} GB <span class="micro m-claimed">4-BIT EST.</span></td>
|
|
1197
|
+
<td><code class="mono">ollama ${verb} ${esc(runName)}:${esc(x.tag)}</code></td></tr>`).join('')
|
|
1198
|
+
: `<tr class="runrow"><td>—</td><td>—</td><td><code class="mono">ollama ${verb} ${esc(runName)}</code></td></tr>`)
|
|
1199
|
+
+ `</tbody></table><p class="sub" style="margin:0.6rem 0.8rem; font-size:0.8rem">Install Ollama from <a href="https://ollama.com/download" target="_blank" rel="noopener">ollama.com</a>, then run one command. Pick the largest size that fits the RAM (or GPU VRAM) you can spare; real use grows with the context length.</p>`;
|
|
1200
|
+
else $('#md-offerings').innerHTML = `<table class="grid num"><thead><tr>
|
|
991
1201
|
<th>NODE</th><th>PRICE IN/OUT</th><th>HARDWARE</th><th>CONTEXT</th><th>TTFT</th><th>TOK/S</th><th>UP</th><th>CAPABILITIES</th><th>REVISION</th>
|
|
992
1202
|
</tr></thead><tbody>` + list.map((o) => {
|
|
993
1203
|
const obs = o.observed || {};
|
|
@@ -1055,7 +1265,12 @@ async function loadModel(artifact) {
|
|
|
1055
1265
|
// FAQ — generated strictly from the data on this page
|
|
1056
1266
|
const supports = [...new Set(list.flatMap((o) => o.serving?.supports || []))].filter((s) => s !== 'streaming');
|
|
1057
1267
|
const capped = list.filter((o) => o.serving?.context_capped_from);
|
|
1058
|
-
const faqs = [
|
|
1268
|
+
const faqs = isLocal ? [
|
|
1269
|
+
['What is ' + first.model.name + '?', desc || `A ${first.modality} model from the Ollama library${first.model.family ? ` in the ${first.model.family} family` : ''}.`],
|
|
1270
|
+
['What does it cost?', 'Nothing per token: it runs on your own hardware with Ollama. The cost is your memory, compute and electricity.'],
|
|
1271
|
+
['How do I run it?', `Install Ollama, then run ${sizes.length ? `"ollama ${verb} ${runName}:${sizes.at(-1).tag}"${sizes.length > 1 ? ` (or a smaller size: ${sizes.map((x) => x.tag).join(', ')})` : ''}` : `"ollama ${verb} ${runName}"`}.${sizes.length ? ` The smallest size needs about ${sizes[0].memory_gb} GB at 4-bit.` : ''}${verb === 'pull' ? ' Embedding models are called through the API (as the playground below does), not chatted with.' : ''}`],
|
|
1272
|
+
['Is it verified?', 'There is no server to verify: the model runs on your machine, so how fast and how well depends on your hardware. The listing comes from the Ollama library. The playground on this page sends to your own Ollama and shows whether it answers.'],
|
|
1273
|
+
] : [
|
|
1059
1274
|
['What is ' + first.model.name + '?', desc
|
|
1060
1275
|
? desc
|
|
1061
1276
|
: `A ${first.modality} model${first.model.params_b ? ` (${first.model.params_b}B parameters)` : ''}${first.model.family ? ` in the ${first.model.family} family` : ''}, served by ${list.length} node${list.length === 1 ? '' : 's'} listed in this registry. Artifact: ${artifact}.`],
|
|
@@ -1082,17 +1297,31 @@ function pgLabel(o) {
|
|
|
1082
1297
|
if (!runsLocally(o)) return `${esc(o.node_id)} — ${priceStr(o.pricing, o.node_id)} [${esc(o.tier)}]`;
|
|
1083
1298
|
return `your computer — ${esc(o.local?.runtime === 'ollama' ? 'Ollama' : 'local app')} at ${esc(localHost(o))} (no hosted server for this listing)`;
|
|
1084
1299
|
}
|
|
1300
|
+
/** Embedding models answer /embeddings with a vector, not /chat/completions with text. */
|
|
1301
|
+
const isEmbedOffering = (o) => Boolean(o) && (o.modality === 'embedding' || /embeddings/.test(o.binding?.profile ?? ''));
|
|
1085
1302
|
/** Says plainly where Send goes when the target is the visitor's own machine. */
|
|
1086
1303
|
function pgUpdateNote() {
|
|
1087
1304
|
const note = $('#pg-note');
|
|
1088
1305
|
const v = $('#pg-target').value;
|
|
1089
1306
|
const o = v === 'custom' ? null : pgOfferings[Number(v)];
|
|
1307
|
+
const embed = isEmbedOffering(o);
|
|
1308
|
+
$('#pg-prompt').placeholder = embed ? 'Text to embed — the answer is a vector of numbers…' : 'Try the model…';
|
|
1309
|
+
$('#pg-send').textContent = embed ? 'Embed' : 'Send';
|
|
1090
1310
|
note.hidden = !o || !runsLocally(o);
|
|
1091
1311
|
if (note.hidden) return;
|
|
1092
1312
|
const app = o.local?.runtime === 'ollama' ? 'Ollama' : 'the local app';
|
|
1093
1313
|
note.innerHTML = `This listing has no server behind it: Send goes to ${app} on <b>your own computer</b> (${esc(localHost(o))}), `
|
|
1094
1314
|
+ `and answers only if ${app} is running with this model installed${o.local?.run ? ` (<code class="mono">${esc(o.local.run)}</code>)` : ''}. `
|
|
1095
1315
|
+ 'It tests your machine, not a node.';
|
|
1316
|
+
if (o.local && ollama.state === 'ok') {
|
|
1317
|
+
const tags = installedTags(o);
|
|
1318
|
+
const id = o.binding?.model_id ?? o.offering_id;
|
|
1319
|
+
note.innerHTML += tags
|
|
1320
|
+
? ` <b>Installed in your Ollama</b> (${esc(tags.map((t) => id + ':' + t).join(', '))}), so ${embed ? 'Embed' : 'Send'} should answer.`
|
|
1321
|
+
: ` <b>Not installed in your Ollama yet:</b> <code class="mono">ollama pull ${esc(id)}</code> first.`;
|
|
1322
|
+
} else if (o.local && ollama.state === 'blocked') {
|
|
1323
|
+
note.innerHTML += ' <b>Your Ollama does not allow this page yet</b> — see "Check my Ollama" on the local models list.';
|
|
1324
|
+
}
|
|
1096
1325
|
}
|
|
1097
1326
|
/** On a local-only model page: hosted listings of the same model, so it can be tried without installing anything. */
|
|
1098
1327
|
async function showHostedAlternatives(first, artifact) {
|
|
@@ -1146,6 +1375,27 @@ $('#pg-send').addEventListener('click', async () => {
|
|
|
1146
1375
|
out.textContent = '…';
|
|
1147
1376
|
meta.textContent = '';
|
|
1148
1377
|
const t0 = performance.now();
|
|
1378
|
+
if (isEmbedOffering(offering)) {
|
|
1379
|
+
try {
|
|
1380
|
+
const res = await fetch(base + '/embeddings', {
|
|
1381
|
+
method: 'POST',
|
|
1382
|
+
headers: { 'content-type': 'application/json', ...(useKey ? { authorization: 'Bearer ' + useKey } : {}) },
|
|
1383
|
+
body: JSON.stringify({ model, input: prompt }),
|
|
1384
|
+
});
|
|
1385
|
+
const body = await res.json();
|
|
1386
|
+
if (!res.ok) throw new Error(body?.detail ?? body?.error?.message ?? ('status ' + res.status));
|
|
1387
|
+
const vec = body.data?.[0]?.embedding;
|
|
1388
|
+
if (!Array.isArray(vec)) throw new Error('no embedding in the answer');
|
|
1389
|
+
out.textContent = `A vector of ${vec.length} numbers: the text's position in the model's meaning space. Similar texts get nearby vectors; that is what document search (RAG) compares.\n\n[${vec.slice(0, 8).map((x) => Number(x).toFixed(4)).join(', ')}, …]`;
|
|
1390
|
+
meta.textContent = [Math.round(performance.now() - t0) + 'ms', body.usage?.prompt_tokens != null ? `${body.usage.prompt_tokens} tokens in` : null, `${vec.length} dimensions`].filter(Boolean).join(' · ');
|
|
1391
|
+
} catch (err) {
|
|
1392
|
+
const notPulled = offering && runsLocally(offering) && /not found/i.test(err.message);
|
|
1393
|
+
out.innerHTML = '<span class="err">' + esc(err.message) + '</span><br><span class="prov">' + (notPulled
|
|
1394
|
+
? `Your Ollama is running but does not have this model yet: <code class="mono">ollama pull ${esc(model)}</code>, then Embed again.`
|
|
1395
|
+
: 'If this is a network/CORS error: for local Ollama set OLLAMA_ORIGINS to include this page's origin.') + '</span>';
|
|
1396
|
+
} finally { $('#pg-send').disabled = false; }
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1149
1399
|
try {
|
|
1150
1400
|
const res = await fetch(base + '/chat/completions', {
|
|
1151
1401
|
method: 'POST',
|