mirror of
https://github.com/hanzoai/site.git
synced 2026-11-21 00:51:59 +00:00
- lib/liveSources.mjs (new, shared): the api.hanzo.ai research-runs, models and pricing endpoints hanzo.ai's own home calls, and their readers. scripts/live.mjs (build time) and components/home/useFigures.js (page load) both use it, so the two can never drift apart; live.test.mjs copies it into its sandbox. - components/home/figures.js: the same calculations, now figuresOf(runs, models); SNAPSHOT is the build's read. - useFigures(): one read per page load shared by Race, Cheaper and Pareto; the snapshot paints first and stays if the read fails. api.hanzo.ai sends CORS only to https://hanzo.ai, so the read runs there (or with localStorage hz-live=1 for testing) and nowhere else, rather than log a refused request. - Checked in Chrome: localhost makes no API call; with hz-live=1 the five requests go to the same endpoints and the figures render from them (an injected price change shows as $6.50); a 503 keeps the snapshot; 0 console errors in all. - Refreshed content/live from the live sources. copycheck / missing 0 of 228; unique OK; live.test.mjs passes. Not read at page load: the per-org commits and contributors. hanzo.ai itself shows those from a snapshot built into its own page (no request is made for them), which is what content/live/_oss.json is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBdvdmGVS8p6FhaTwzh4
27 lines
2.2 KiB
JavaScript
27 lines
2.2 KiB
JavaScript
// The live sources behind the home page's race, cost and frontier figures: the same endpoints hanzo.ai's own home
|
|
// fetches when it opens (api.hanzo.ai research runs, models and pricing). scripts/live.mjs reads them at build time into
|
|
// content/live/_research.json and _models.json; components/home/useFigures.js reads them again at page load. Each reader
|
|
// returns exactly the shape of those files and throws if a source answers with something unexpected.
|
|
export const RUNS = 'https://api.hanzo.ai/v1/research/runs?org=hanzo';
|
|
export const MODELS = 'https://api.hanzo.ai/v1/models?id=anthropic/claude-fable-5.1,anthropic/claude-opus-5,anthropic/claude-sonnet-5.5,enso,enso-flash,enso-pro,enso-ultra,kai,openai/gpt-5.5,openai/gpt-6-astra,zen6,zen6-coder,zen6-flash';
|
|
export const PRICES = 'https://api.hanzo.ai/v1/pricing/models?id=anthropic/claude-fable-5,anthropic/claude-fable-5.1,anthropic/claude-haiku-5.5,anthropic/claude-opus-4.8,anthropic/claude-opus-5.5,anthropic/claude-sonnet-5,anthropic/claude-sonnet-5.5,deepseek/deepseek-v4-pro,openai/gpt-4o,openai/gpt-5.5,openai/gpt-5.6-sol,openai/gpt-6-sol,moonshotai/kimi-k3,x-ai/grok-4.7,z-ai/glm-5.3,enso,enso-flash,enso-ultra,kai';
|
|
|
|
const need = (ok, what) => { if (!ok) throw new Error('unexpected data: ' + what); };
|
|
|
|
export async function readResearch(get) {
|
|
const one = async (q) => { const d = await get(`${RUNS}&${q}&view=summary&limit=200`); need(Array.isArray(d.data) && d.data.length > 0, q); return d.data; };
|
|
const [repair, latency, gpqa] = await Promise.all([
|
|
one('benchmark=coding.repair&category=all,vs-claude-code'),
|
|
one('benchmark=decision.latency&metric=p50ms'),
|
|
one('benchmark=enso.gpqa_diamond&category=all,vs-claude-code'),
|
|
]);
|
|
return { repair, latency, gpqa };
|
|
}
|
|
|
|
export async function readModels(get) {
|
|
const [m, p] = await Promise.all([get(MODELS), get(PRICES)]);
|
|
need(Array.isArray(m.data) && m.data.some((x) => x.id === 'kai' && x.pricing?.input_per_million > 0), 'models with prices');
|
|
need(Array.isArray(p.models) && p.models.length > 0, 'pricing models');
|
|
return { models: m.data.map((x) => ({ id: x.id, name: x.name, pricing: x.pricing })), names: Object.fromEntries(p.models.map((x) => [x.id ?? x.name, x.fullName ?? x.name])) };
|
|
}
|