(modelsDir: string)
| 449 | } |
| 450 | |
| 451 | async function readModelMetadata(modelsDir: string) { |
| 452 | const metadataDir = modelMetadataDir(modelsDir); |
| 453 | const result: Record<string, Record<string, unknown>> = {}; |
| 454 | |
| 455 | for await (const modelPath of new Bun.Glob("**/*.toml").scan({ |
| 456 | cwd: metadataDir, |
| 457 | absolute: true, |
| 458 | followSymlinks: true, |
| 459 | })) { |
| 460 | const modelID = path.relative(metadataDir, modelPath).split(path.sep).join("/").slice(0, -5); |
| 461 | const toml = Bun.TOML.parse( |
| 462 | await Bun.file(modelPath).text(), |
| 463 | ) as Record<string, unknown>; |
| 464 | result[modelID] = inheritableModelMetadata(toml); |
| 465 | } |
| 466 | |
| 467 | return result; |
| 468 | } |
| 469 | |
| 470 | function modelMetadataDir(modelsDir: string) { |
| 471 | return path.join(path.dirname(path.dirname(path.dirname(modelsDir))), "models"); |
no test coverage detected