feat(ai): separate generated model data (#6765)

This commit is contained in:
Armin Ronacher
2026-07-17 11:08:48 +02:00
committed by GitHub
parent b0c2a90e51
commit a9f6a3159a
44 changed files with 4455 additions and 19265 deletions
+20 -2
View File
@@ -1,10 +1,27 @@
import { writeFileSync } from "node:fs";
import { existsSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { dirname, join, resolve } from "node:path";
import { build } from "esbuild";
const outputPath = join(tmpdir(), "pi-browser-smoke.js");
const errorLogPath = join(tmpdir(), "pi-browser-smoke-errors.log");
const generatedCatalogDataDir = join(process.cwd(), "packages/ai/src/providers/data");
// Fresh checkouts do not materialize provider JSON until npm run build.
const generatedCatalogDataPlugin = {
name: "generated-model-catalog",
setup(build) {
build.onResolve({ filter: /^\.\/data\/[^/]+\.json$/ }, (args) => {
const path = resolve(dirname(args.importer), args.path);
if (dirname(path) !== generatedCatalogDataDir || existsSync(path)) return;
return { path, namespace: "empty-generated-model-catalog" };
});
build.onLoad({ filter: /.*/, namespace: "empty-generated-model-catalog" }, () => ({
contents: "{}",
loader: "json",
}));
},
};
try {
await build({
@@ -14,6 +31,7 @@ try {
format: "esm",
logLevel: "silent",
outfile: outputPath,
plugins: [generatedCatalogDataPlugin],
});
process.exit(0);
} catch (error) {
+4
View File
@@ -209,6 +209,10 @@ const bunInstallDirectory = join(outDir, "bun-install");
const binaryDirectory = join(outDir, "bun");
mkdirSync(tarballDirectory, { recursive: true });
if (!options.skipCheck || !options.skipTest) {
run("npm", ["--prefix", "packages/ai", "run", "generate-models"], { cwd: repoRoot });
}
if (!options.skipCheck) {
run("npm", ["run", "check"], { cwd: repoRoot });
}