From bfc7135a18e7c40a168409fa2d2eb98227aac778 Mon Sep 17 00:00:00 2001 From: Guillaume Gay Date: Tue, 4 Aug 2026 17:03:12 +0200 Subject: [PATCH] feat: add Python package install commands --- src/build/render-api.ts | 2 +- src/build/structured-data.ts | 3 ++- src/client/main.ts | 34 ++++++++++++++++++---------------- src/data/llms.ts | 21 ++++++++++++++++++++- src/views/api.ejs | 13 ++++++++++++- src/views/index.ejs | 30 ++++++++++++++++++++++++------ src/views/partials/footer.ejs | 1 + 7 files changed, 78 insertions(+), 26 deletions(-) diff --git a/src/build/render-api.ts b/src/build/render-api.ts index 4a5797c..5201356 100644 --- a/src/build/render-api.ts +++ b/src/build/render-api.ts @@ -8,7 +8,7 @@ import { hubLinks, renderShell, viewHelpers } from "./render.js"; const API_TITLE = `API documentation · ${SITE_NAME}`; const API_DESCRIPTION = - "How to use the modelparams.dev JSON API, npm package, and provider logos. Static, CORS-enabled, served from the edge."; + "How to use the modelparams.dev JSON API, npm and Python packages, and provider logos. Static, CORS-enabled, served from the edge."; export async function renderApiPage(allModels: Model[]): Promise { const body = await ejs.renderFile(path.join(VIEWS_DIR, "api.ejs"), { diff --git a/src/build/structured-data.ts b/src/build/structured-data.ts index f49ce28..07094ec 100644 --- a/src/build/structured-data.ts +++ b/src/build/structured-data.ts @@ -18,6 +18,7 @@ import { type Model } from "../schema/model.js"; const REPO_URL = "https://github.com/mnfst/modelparams.dev"; const NPM_URL = "https://www.npmjs.com/package/modelparams"; +const PYPI_URL = "https://pypi.org/project/modelparams/"; interface Crumb { name: string; @@ -47,7 +48,7 @@ function organizationNode(siteUrl: string) { name: SITE_NAME, url: `${siteUrl}/`, description: SITE_DESCRIPTION, - sameAs: [REPO_URL, NPM_URL], + sameAs: [REPO_URL, NPM_URL, PYPI_URL], }; } diff --git a/src/client/main.ts b/src/client/main.ts index d117537..6e678a1 100644 --- a/src/client/main.ts +++ b/src/client/main.ts @@ -99,21 +99,23 @@ function setupCopyHowToUse(): void { }); } -function setupCopyNpm(): void { - const btn = document.querySelector("[data-copy-npm]"); - if (!btn) return; - const idle = btn.querySelector("[data-copy-npm-idle]"); - const done = btn.querySelector("[data-copy-npm-done]"); - let timer = 0; - btn.addEventListener("click", async () => { - await copyText("npm i modelparams"); - idle?.classList.add("hidden"); - done?.classList.remove("hidden"); - window.clearTimeout(timer); - timer = window.setTimeout(() => { - idle?.classList.remove("hidden"); - done?.classList.add("hidden"); - }, 2000); +function setupCopyInstallCommands(): void { + document.querySelectorAll("[data-copy-install]").forEach((btn) => { + const command = btn.dataset.copyInstall; + if (!command) return; + const idle = btn.querySelector("[data-copy-install-idle]"); + const done = btn.querySelector("[data-copy-install-done]"); + let timer = 0; + btn.addEventListener("click", async () => { + await copyText(command); + idle?.classList.add("hidden"); + done?.classList.remove("hidden"); + window.clearTimeout(timer); + timer = window.setTimeout(() => { + idle?.classList.remove("hidden"); + done?.classList.add("hidden"); + }, 2000); + }); }); } @@ -533,7 +535,7 @@ function setupMobileMenu(): void { document.addEventListener("DOMContentLoaded", () => { setupThemeToggle(); - setupCopyNpm(); + setupCopyInstallCommands(); setupHowToUseModal(); setupCopyHowToUse(); setupProvidersMenu(); diff --git a/src/data/llms.ts b/src/data/llms.ts index 3fa2078..6f6419d 100644 --- a/src/data/llms.ts +++ b/src/data/llms.ts @@ -89,6 +89,20 @@ function guideApi(siteUrl: string): string[] { ]; } +function guidePackages(): string[] { + return [ + "## Packages", + "", + "Install the typed catalog package for your language:", + "", + "```bash", + "npm install modelparams", + "pip install modelparams", + "```", + "", + ]; +} + function guideAgents(siteUrl: string): string[] { return [ "## Contribute", @@ -112,7 +126,12 @@ function guideAgents(siteUrl: string): string[] { * it backs the modal's Copy button and the body of /llms-full.txt. */ export function usageGuideMarkdown(siteUrl: string): string { - return [...guideIntro(siteUrl), ...guideApi(siteUrl), ...guideAgents(siteUrl)].join("\n"); + return [ + ...guideIntro(siteUrl), + ...guidePackages(), + ...guideApi(siteUrl), + ...guideAgents(siteUrl), + ].join("\n"); } function fmtValue(value: unknown): string { diff --git a/src/views/api.ejs b/src/views/api.ejs index 047b6ca..496b22d 100644 --- a/src/views/api.ejs +++ b/src/views/api.ejs @@ -7,7 +7,7 @@

How to use the API

The full catalog is available as static JSON, CORS-enabled, served from the edge. - You can also install the npm package or point your AI agent at /llms.txt. + You can also install the npm or Python package, or point your AI agent at /llms.txt.

@@ -101,6 +101,17 @@
+ +
+

Python package

+

+ Install the package to use typed model parameters and the bundled catalog in Python. +

+
+
pip install modelparams
+
+
+

Logos

diff --git a/src/views/index.ejs b/src/views/index.ejs index 0658985..56be840 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -5,24 +5,42 @@

An open, community-maintained catalog of model parameters. - Browse the UI below, query the API, or install the npm package. + Browse the UI below, query the API, or install the npm or Python package.

- +
$ npm i modelparams +
+ +
+ $ pip install modelparams + diff --git a/src/views/partials/footer.ejs b/src/views/partials/footer.ejs index 50ca8d9..b5affdb 100644 --- a/src/views/partials/footer.ejs +++ b/src/views/partials/footer.ejs @@ -30,6 +30,7 @@