diff --git a/packages/core/script/generate-friendli.ts b/packages/core/script/generate-friendli.ts index 1e33339f..1b073558 100644 --- a/packages/core/script/generate-friendli.ts +++ b/packages/core/script/generate-friendli.ts @@ -1,6 +1,6 @@ #!/usr/bin/env bun -import { readdir } from "node:fs/promises"; +import { mkdir } from "node:fs/promises"; import path from "node:path"; import { z } from "zod"; @@ -410,14 +410,14 @@ async function main() { const apiModels = parsed.data.data; - // Get existing files + // Get existing files (recursively) const existingFiles = new Set(); try { - const files = await readdir(modelsDir); - for (const file of files) { - if (file.endsWith(".toml")) { - existingFiles.add(file); - } + for await (const file of new Bun.Glob("**/*.toml").scan({ + cwd: modelsDir, + absolute: false, + })) { + existingFiles.add(file); } } catch { // Directory might not exist yet @@ -435,41 +435,40 @@ async function main() { let unchanged = 0; for (const apiModel of apiModels) { - const safeId = apiModel.id.replace(/\//g, "-"); - const filename = `${safeId}.toml`; - const filePath = path.join(modelsDir, filename); + const relativePath = `${apiModel.id}.toml`; + const filePath = path.join(modelsDir, relativePath); + const dirPath = path.dirname(filePath); - apiModelIds.add(filename); + apiModelIds.add(relativePath); const existing = await loadExistingModel(filePath); const merged = mergeModel(apiModel, existing); const tomlContent = formatToml(merged); if (existing === null) { - // New file created++; if (dryRun) { - console.log(`[DRY RUN] Would create: ${filename}`); + console.log(`[DRY RUN] Would create: ${relativePath}`); console.log(` name = "${merged.name}"`); if (merged.family) { console.log(` family = "${merged.family}" (inferred)`); } console.log(""); } else { + await mkdir(dirPath, { recursive: true }); await Bun.write(filePath, tomlContent); - console.log(`Created: ${filename}`); + console.log(`Created: ${relativePath}`); } } else { - // Check for changes const changes = detectChanges(existing, merged); if (changes.length > 0) { updated++; if (dryRun) { - console.log(`[DRY RUN] Would update: ${filename}`); + console.log(`[DRY RUN] Would update: ${relativePath}`); } else { await Bun.write(filePath, tomlContent); - console.log(`Updated: ${filename}`); + console.log(`Updated: ${relativePath}`); } for (const change of changes) { console.log(` ${change.field}: ${change.oldValue} → ${change.newValue}`); diff --git a/providers/friendli/models/LGAI-EXAONE-EXAONE-4.0.1-32B.toml b/providers/friendli/models/LGAI-EXAONE/EXAONE-4.0.1-32B.toml similarity index 100% rename from providers/friendli/models/LGAI-EXAONE-EXAONE-4.0.1-32B.toml rename to providers/friendli/models/LGAI-EXAONE/EXAONE-4.0.1-32B.toml diff --git a/providers/friendli/models/Qwen-Qwen3-235B-A22B-Instruct-2507.toml b/providers/friendli/models/Qwen/Qwen3-235B-A22B-Instruct-2507.toml similarity index 100% rename from providers/friendli/models/Qwen-Qwen3-235B-A22B-Instruct-2507.toml rename to providers/friendli/models/Qwen/Qwen3-235B-A22B-Instruct-2507.toml diff --git a/providers/friendli/models/Qwen-Qwen3-235B-A22B-Thinking-2507.toml b/providers/friendli/models/Qwen/Qwen3-235B-A22B-Thinking-2507.toml similarity index 100% rename from providers/friendli/models/Qwen-Qwen3-235B-A22B-Thinking-2507.toml rename to providers/friendli/models/Qwen/Qwen3-235B-A22B-Thinking-2507.toml diff --git a/providers/friendli/models/Qwen-Qwen3-30B-A3B.toml b/providers/friendli/models/Qwen/Qwen3-30B-A3B.toml similarity index 100% rename from providers/friendli/models/Qwen-Qwen3-30B-A3B.toml rename to providers/friendli/models/Qwen/Qwen3-30B-A3B.toml diff --git a/providers/friendli/models/Qwen-Qwen3-32B.toml b/providers/friendli/models/Qwen/Qwen3-32B.toml similarity index 100% rename from providers/friendli/models/Qwen-Qwen3-32B.toml rename to providers/friendli/models/Qwen/Qwen3-32B.toml diff --git a/providers/friendli/models/deepseek-ai-DeepSeek-R1-0528.toml b/providers/friendli/models/deepseek-ai/DeepSeek-R1-0528.toml similarity index 100% rename from providers/friendli/models/deepseek-ai-DeepSeek-R1-0528.toml rename to providers/friendli/models/deepseek-ai/DeepSeek-R1-0528.toml diff --git a/providers/friendli/models/meta-llama-Llama-4-Maverick-17B-128E-Instruct.toml b/providers/friendli/models/meta-llama/Llama-4-Maverick-17B-128E-Instruct.toml similarity index 100% rename from providers/friendli/models/meta-llama-Llama-4-Maverick-17B-128E-Instruct.toml rename to providers/friendli/models/meta-llama/Llama-4-Maverick-17B-128E-Instruct.toml diff --git a/providers/friendli/models/meta-llama-Llama-4-Scout-17B-16E-Instruct.toml b/providers/friendli/models/meta-llama/Llama-4-Scout-17B-16E-Instruct.toml similarity index 100% rename from providers/friendli/models/meta-llama-Llama-4-Scout-17B-16E-Instruct.toml rename to providers/friendli/models/meta-llama/Llama-4-Scout-17B-16E-Instruct.toml diff --git a/providers/friendli/models/zai-org-GLM-4.6.toml b/providers/friendli/models/zai-org/GLM-4.6.toml similarity index 100% rename from providers/friendli/models/zai-org-GLM-4.6.toml rename to providers/friendli/models/zai-org/GLM-4.6.toml