From 7a55ce44e753b765880fef1f2e1724ffa90a7341 Mon Sep 17 00:00:00 2001 From: minpeter Date: Fri, 26 Dec 2025 04:19:24 +0900 Subject: [PATCH] fix: restructure friendli model files to match API IDs with slashes - Change model file structure to use directories for IDs containing '/' - Update generate-friendli.ts to create directory structure instead of replacing '/' with '-' - Fixes 404 errors caused by model ID mismatch (e.g., Qwen/Qwen3-30B-A3B vs Qwen-Qwen3-30B-A3B) --- packages/core/script/generate-friendli.ts | 33 +++++++++---------- .../EXAONE-4.0.1-32B.toml} | 0 .../Qwen3-235B-A22B-Instruct-2507.toml} | 0 .../Qwen3-235B-A22B-Thinking-2507.toml} | 0 .../Qwen3-30B-A3B.toml} | 0 .../Qwen3-32B.toml} | 0 .../DeepSeek-R1-0528.toml} | 0 .../Llama-4-Maverick-17B-128E-Instruct.toml} | 0 .../Llama-4-Scout-17B-16E-Instruct.toml} | 0 .../GLM-4.6.toml} | 0 10 files changed, 16 insertions(+), 17 deletions(-) rename providers/friendli/models/{LGAI-EXAONE-EXAONE-4.0.1-32B.toml => LGAI-EXAONE/EXAONE-4.0.1-32B.toml} (100%) rename providers/friendli/models/{Qwen-Qwen3-235B-A22B-Instruct-2507.toml => Qwen/Qwen3-235B-A22B-Instruct-2507.toml} (100%) rename providers/friendli/models/{Qwen-Qwen3-235B-A22B-Thinking-2507.toml => Qwen/Qwen3-235B-A22B-Thinking-2507.toml} (100%) rename providers/friendli/models/{Qwen-Qwen3-30B-A3B.toml => Qwen/Qwen3-30B-A3B.toml} (100%) rename providers/friendli/models/{Qwen-Qwen3-32B.toml => Qwen/Qwen3-32B.toml} (100%) rename providers/friendli/models/{deepseek-ai-DeepSeek-R1-0528.toml => deepseek-ai/DeepSeek-R1-0528.toml} (100%) rename providers/friendli/models/{meta-llama-Llama-4-Maverick-17B-128E-Instruct.toml => meta-llama/Llama-4-Maverick-17B-128E-Instruct.toml} (100%) rename providers/friendli/models/{meta-llama-Llama-4-Scout-17B-16E-Instruct.toml => meta-llama/Llama-4-Scout-17B-16E-Instruct.toml} (100%) rename providers/friendli/models/{zai-org-GLM-4.6.toml => zai-org/GLM-4.6.toml} (100%) 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