Skip to content

Commit 4bd8337

Browse files
authored
Merge pull request #574 from friendliai/feat/add-friendli-provider
fix: correct friendli model file structure for API IDs with slashes
2 parents cb2c762 + 7a55ce4 commit 4bd8337

File tree

10 files changed

+16
-17
lines changed

10 files changed

+16
-17
lines changed

packages/core/script/generate-friendli.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bun
22

3-
import { readdir } from "node:fs/promises";
3+
import { mkdir } from "node:fs/promises";
44
import path from "node:path";
55
import { z } from "zod";
66

@@ -410,14 +410,14 @@ async function main() {
410410

411411
const apiModels = parsed.data.data;
412412

413-
// Get existing files
413+
// Get existing files (recursively)
414414
const existingFiles = new Set<string>();
415415
try {
416-
const files = await readdir(modelsDir);
417-
for (const file of files) {
418-
if (file.endsWith(".toml")) {
419-
existingFiles.add(file);
420-
}
416+
for await (const file of new Bun.Glob("**/*.toml").scan({
417+
cwd: modelsDir,
418+
absolute: false,
419+
})) {
420+
existingFiles.add(file);
421421
}
422422
} catch {
423423
// Directory might not exist yet
@@ -435,41 +435,40 @@ async function main() {
435435
let unchanged = 0;
436436

437437
for (const apiModel of apiModels) {
438-
const safeId = apiModel.id.replace(/\//g, "-");
439-
const filename = `${safeId}.toml`;
440-
const filePath = path.join(modelsDir, filename);
438+
const relativePath = `${apiModel.id}.toml`;
439+
const filePath = path.join(modelsDir, relativePath);
440+
const dirPath = path.dirname(filePath);
441441

442-
apiModelIds.add(filename);
442+
apiModelIds.add(relativePath);
443443

444444
const existing = await loadExistingModel(filePath);
445445
const merged = mergeModel(apiModel, existing);
446446
const tomlContent = formatToml(merged);
447447

448448
if (existing === null) {
449-
// New file
450449
created++;
451450
if (dryRun) {
452-
console.log(`[DRY RUN] Would create: ${filename}`);
451+
console.log(`[DRY RUN] Would create: ${relativePath}`);
453452
console.log(` name = "${merged.name}"`);
454453
if (merged.family) {
455454
console.log(` family = "${merged.family}" (inferred)`);
456455
}
457456
console.log("");
458457
} else {
458+
await mkdir(dirPath, { recursive: true });
459459
await Bun.write(filePath, tomlContent);
460-
console.log(`Created: ${filename}`);
460+
console.log(`Created: ${relativePath}`);
461461
}
462462
} else {
463-
// Check for changes
464463
const changes = detectChanges(existing, merged);
465464

466465
if (changes.length > 0) {
467466
updated++;
468467
if (dryRun) {
469-
console.log(`[DRY RUN] Would update: ${filename}`);
468+
console.log(`[DRY RUN] Would update: ${relativePath}`);
470469
} else {
471470
await Bun.write(filePath, tomlContent);
472-
console.log(`Updated: ${filename}`);
471+
console.log(`Updated: ${relativePath}`);
473472
}
474473
for (const change of changes) {
475474
console.log(` ${change.field}: ${change.oldValue}${change.newValue}`);

providers/friendli/models/LGAI-EXAONE-EXAONE-4.0.1-32B.toml renamed to providers/friendli/models/LGAI-EXAONE/EXAONE-4.0.1-32B.toml

File renamed without changes.

providers/friendli/models/Qwen-Qwen3-235B-A22B-Instruct-2507.toml renamed to providers/friendli/models/Qwen/Qwen3-235B-A22B-Instruct-2507.toml

File renamed without changes.

providers/friendli/models/Qwen-Qwen3-235B-A22B-Thinking-2507.toml renamed to providers/friendli/models/Qwen/Qwen3-235B-A22B-Thinking-2507.toml

File renamed without changes.
File renamed without changes.
File renamed without changes.

providers/friendli/models/deepseek-ai-DeepSeek-R1-0528.toml renamed to providers/friendli/models/deepseek-ai/DeepSeek-R1-0528.toml

File renamed without changes.

providers/friendli/models/meta-llama-Llama-4-Maverick-17B-128E-Instruct.toml renamed to providers/friendli/models/meta-llama/Llama-4-Maverick-17B-128E-Instruct.toml

File renamed without changes.

providers/friendli/models/meta-llama-Llama-4-Scout-17B-16E-Instruct.toml renamed to providers/friendli/models/meta-llama/Llama-4-Scout-17B-16E-Instruct.toml

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)