Compare commits

...

1 Commits

Author SHA1 Message Date
Adam e1d75f89bc Normalize base-model inheritance 2026-06-04 12:52:03 -05:00
163 changed files with 53 additions and 264 deletions
+3 -2
View File
@@ -12,7 +12,7 @@ import {
} from "./schema.js";
const BaseModel = AuthoredModelShape
.partial()
.deepPartial()
.extend({
id: z.string(),
base_model: z.string().min(1, "Base model cannot be empty"),
@@ -211,7 +211,8 @@ function applyOmit(target: Record<string, unknown>, paths: string[]) {
for (let index = parents.length - 1; index >= 0; index--) {
const parent = parents[index];
const value = parent?.value[parent.key];
if (parent === undefined) continue;
const value = parent.value[parent.key];
if (
value === null ||
value === undefined ||
+12 -5
View File
@@ -10,14 +10,21 @@ import { openrouter } from "./providers/openrouter.js";
import { ovhcloud } from "./providers/ovhcloud.js";
import { xai } from "./providers/xai.js";
const ExistingModel = AuthoredModelShape.partial()
const ExistingModelType = AuthoredModelShape.partial()
.extend({
base_model: z.string().optional(),
base_model_omit: z.array(z.string()).optional(),
})
.strict();
const SyncedBaseModel = AuthoredModelShape.partial()
const ExistingModel = AuthoredModelShape.deepPartial()
.extend({
base_model: z.string().optional(),
base_model_omit: z.array(z.string()).optional(),
})
.strict();
const SyncedBaseModel = AuthoredModelShape.deepPartial()
.extend({
id: z.string(),
base_model: z.string(),
@@ -27,7 +34,7 @@ const SyncedBaseModel = AuthoredModelShape.partial()
const SyncedAuthoredModel = z.union([AuthoredModel, SyncedBaseModel]);
export type ExistingModel = z.infer<typeof ExistingModel>;
export type ExistingModel = z.infer<typeof ExistingModelType>;
export type SyncedFullModel = Omit<z.infer<typeof AuthoredModelShape>, "id">;
export type SyncedBaseModel = Omit<z.infer<typeof SyncedBaseModel>, "id">;
export type SyncedModel = SyncedFullModel | SyncedBaseModel;
@@ -240,7 +247,7 @@ async function readExisting(modelsDir: string) {
throw parsed.error;
}
const authored = parsed.data;
const authored = parsed.data as ExistingModel;
if (authored.base_model !== undefined && modelMetadata === undefined) {
modelMetadata = await readModelMetadata(modelsDir);
}
@@ -304,7 +311,7 @@ function resolveBaseModel(
parsed.error.cause = { modelPath, toml: merged };
throw parsed.error;
}
return parsed.data;
return parsed.data as ExistingModel;
}
function inheritableModelMetadata(model: Record<string, unknown>) {
+38
View File
@@ -128,6 +128,44 @@ output = 32_000
});
});
test("base_model can inherit sibling fields from partial object overrides", async () => {
await withFixture(async (root) => {
await write(root, "providers/provider/provider.toml", providerToml("Provider"));
await write(root, "models/lab/model.toml", modelMetadataToml());
await write(
root,
"providers/provider/models/model.toml",
`base_model = "lab/model"
open_weights = true
[cost]
input = 1.25
output = 2.50
[limit]
context = 200_000
[modalities]
input = ["text"]
`,
);
const providers = await generate(path.join(root, "providers"));
const model = providers.provider?.models.model;
expect(model?.open_weights).toBe(true);
expect(model?.limit).toEqual({
context: 200_000,
input: 272_000,
output: 128_000,
});
expect(model?.modalities).toEqual({
input: ["text"],
output: ["text"],
});
});
});
test("repository provider TOMLs do not use legacy extends tables", async () => {
const root = path.join(import.meta.dirname, "..", "..", "..");
const matches: string[] = [];
@@ -14,5 +14,4 @@ cache_read = 0
cache_write = 0
[limit]
context = 262_144
output = 32_768
@@ -12,5 +12,4 @@ cache_read = 0
cache_write = 0
[limit]
context = 262_144
output = 16_384
@@ -11,4 +11,3 @@ cache_write = 0
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -11,4 +11,3 @@ cache_write = 0
[limit]
context = 202_752
output = 131_072
@@ -8,4 +8,3 @@ cache_read = 0.075
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -8,4 +8,3 @@ cache_read = 0.02
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
-1
View File
@@ -8,4 +8,3 @@ cache_read = 0.1
[modalities]
input = ["text", "image"]
output = ["text"]
-1
View File
@@ -8,4 +8,3 @@ cache_read = 0.5
[modalities]
input = ["text", "image"]
output = ["text"]
-1
View File
@@ -8,4 +8,3 @@ cache_read = 0.075
[modalities]
input = ["text", "image"]
output = ["text"]
-1
View File
@@ -8,4 +8,3 @@ cache_read = 1.25
[modalities]
input = ["text", "image"]
output = ["text"]
-4
View File
@@ -4,7 +4,3 @@ base_model_omit = ["limit.input"]
[cost]
input = 15
output = 120
[limit]
context = 400_000
output = 272_000
@@ -5,7 +5,3 @@ base_model_omit = ["limit.input"]
input = 1.25
output = 10
cache_read = 0.125
[limit]
context = 400_000
output = 128_000
-1
View File
@@ -8,4 +8,3 @@ cache_read = 0.075
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
-1
View File
@@ -8,4 +8,3 @@ cache_read = 0.02
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
-1
View File
@@ -8,4 +8,3 @@ cache_read = 0.5
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -11,10 +11,5 @@ input = 0.39
output = 2.34
cache_read = 0.195
[limit]
context = 262_144
output = 65_536
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -8,10 +8,5 @@ input = 0.195
output = 1.56
cache_read = 0.0975
[limit]
context = 262_144
output = 65_536
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -9,7 +9,3 @@ structured_output = true
input = 0.09
output = 0.29
cache_read = 0.045
[limit]
context = 262_144
output = 65_536
@@ -3,7 +3,6 @@
base_model = "deepseek/deepseek-r1"
name = "DeepSeek R1 0528 TEE"
structured_output = true
open_weights = true
[interleaved]
field = "reasoning_content"
@@ -15,5 +15,4 @@ output = 2
cache_read = 0.22
[limit]
context = 262_144
output = 65_535
@@ -13,5 +13,4 @@ output = 4
cache_read = 0.475
[limit]
context = 262_144
output = 65_535
@@ -2,7 +2,6 @@
# Manual overrides preserved on re-run: name, family, knowledge, interleaved, status
base_model = "zai/glm-5.1"
name = "GLM 5.1 TEE"
open_weights = true
[interleaved]
field = "reasoning_content"
@@ -9,4 +9,3 @@ output = 4
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -11,4 +11,3 @@ cache_read = 0.0028
[limit]
context = 1_048_576
output = 384_000
@@ -11,4 +11,3 @@ cache_read = 0.003625
[limit]
context = 1_048_576
output = 384_000
@@ -11,9 +11,7 @@ input = 0.444
output = 3.106
[limit]
context = 262_144
output = 262_144
[modalities]
input = ["text"]
output = ["text"]
@@ -16,4 +16,3 @@ output = 250_000
[modalities]
input = ["text"]
output = ["text"]
@@ -9,7 +9,6 @@ output = 0.21
cache_read = 0.003
[limit]
context = 1_000_000
output = 131_072
[provider]
@@ -9,7 +9,6 @@ output = 1.6
cache_read = 0.02
[limit]
context = 1_000_000
output = 131_072
[provider]
@@ -9,7 +9,6 @@ output = 0.8
cache_read = 0.003
[limit]
context = 1_000_000
output = 131_072
[provider]
@@ -6,7 +6,6 @@ output = 0.3
cache_read = 0.02
[limit]
context = 262_144
output = 262_144
[provider]
-1
View File
@@ -8,7 +8,6 @@ cache_write = 0
[limit]
context = 202_752
output = 131_072
[provider]
npm = "@ai-sdk/openai-compatible"
@@ -6,7 +6,6 @@ output = 1.75
cache_read = 0.07
[limit]
context = 262_144
output = 262_144
[provider]
-1
View File
@@ -6,7 +6,6 @@ output = 1.5
cache_read = 0.04
[limit]
context = 262_144
output = 262_144
[provider]
@@ -15,5 +15,4 @@ output = 6
cache_read = 0.4
[limit]
context = 1_048_576
output = 16_384
-1
View File
@@ -8,5 +8,4 @@ input = 1.25
output = 3.89
[limit]
context = 200_000
output = 128_000
@@ -8,4 +8,3 @@ cache_read = 0.5
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -7,6 +7,4 @@ cache_read = 0.1
cache_write = 1.25
[limit]
context = 200_000
input = 136_000
output = 64_000
@@ -7,6 +7,5 @@ cache_read = 0.5
cache_write = 6.25
[limit]
context = 200_000
input = 168_000
output = 32_000
@@ -7,6 +7,5 @@ cache_read = 0.3
cache_write = 3.75
[limit]
context = 200_000
input = 168_000
output = 32_000
@@ -14,7 +14,6 @@ cache_read = 0.5
[limit]
context = 400_000
input = 272_000
output = 128_000
[experimental.modes.fast]
cost = { input = 5, output = 30, cache_read = 0.5 }
@@ -14,7 +14,6 @@ cache_read = 1
[limit]
context = 400_000
input = 272_000
output = 128_000
[experimental.modes.fast]
cost = { input = 12.5, output = 75, cache_read = 1.25 }
@@ -7,8 +7,6 @@ cache_read = 0.5
[limit]
context = 409_600
output = 128_000
[modalities]
input = ["text"]
output = ["text"]
@@ -7,11 +7,9 @@ cache_read = 0.45
[limit]
context = 409_600
output = 128_000
[modalities]
input = ["text"]
output = ["text"]
[experimental.modes.fast]
cost = { input = 30, output = 150, cache_read = 3, cache_write = 37.5 }
@@ -7,8 +7,6 @@ cache_read = 0.3
[limit]
context = 409_600
output = 64_000
[modalities]
input = ["text"]
output = ["text"]
@@ -10,4 +10,3 @@ cache_read = 0.022
[limit]
context = 1_048_575
output = 384_000
@@ -10,4 +10,3 @@ cache_read = 0.116
[limit]
context = 1_048_576
output = 384_000
@@ -14,4 +14,3 @@ output = 65_536
[modalities]
input = ["text"]
output = ["text"]
@@ -10,4 +10,3 @@ cache_read = 0.12
[limit]
context = 202_752
output = 131_072
@@ -10,4 +10,3 @@ cache_read = 0.182
[limit]
context = 202_752
output = 131_072
@@ -14,5 +14,4 @@ cache_read = 0.6
cache_write = 7.5
[limit]
context = 1_000_000
output = 128_000
@@ -14,7 +14,6 @@ cache_read = 0.6
cache_write = 7.5
[limit]
context = 1_000_000
output = 128_000
[provider]
@@ -11,4 +11,3 @@ cache_write = 0
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -7,5 +7,4 @@ output = 2
cache_read = 0.08
[limit]
context = 262_144
output = 65_536
@@ -14,4 +14,3 @@ output = 262_100
[modalities]
input = ["text", "image", "video"]
output = ["text"]
@@ -12,5 +12,4 @@ output = 1.2
cache_read = 0.055
[limit]
context = 204_800
output = 204_800
@@ -10,4 +10,3 @@ cache_read = 0.2
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -1,7 +1,6 @@
base_model = "zai/glm-5.1"
name = "GLM 5.1"
knowledge = "2025-04"
open_weights = true
[interleaved]
field = "reasoning_content"
@@ -13,4 +12,3 @@ cache_read = 0.27
[limit]
context = 202_800
output = 131_072
@@ -10,4 +10,3 @@ output = 32_768
[modalities]
input = ["text"]
output = ["text"]
@@ -7,9 +7,7 @@ output = 1.1
cache_read = 0.056
[limit]
context = 262_144
output = 32_768
[modalities]
input = ["text"]
output = ["text"]
@@ -8,4 +8,3 @@ cache_write = 6.25
[limit]
context = 200_000
output = 128_000
@@ -7,4 +7,3 @@ cache_read = 0.026
[modalities]
input = ["text"]
output = ["text"]
@@ -16,4 +16,3 @@ cache_write = 7.5
[limit]
context = 1_000_000
output = 64_000
@@ -15,5 +15,4 @@ cache_read = 0.6
cache_write = 7.5
[limit]
context = 1_000_000
output = 128_000
@@ -10,4 +10,3 @@ cache_read = 0.003625
[limit]
context = 1_048_576
output = 384_000
@@ -8,5 +8,4 @@ cache_read = 0.01
cache_write = 0.083333
[limit]
context = 1_048_576
output = 65_535
@@ -8,5 +8,4 @@ cache_read = 0.03
cache_write = 0.083333
[limit]
context = 1_048_576
output = 65_535
@@ -5,9 +5,7 @@ input = 0.06
output = 0.33
[limit]
context = 262_144
output = 262_144
[modalities]
input = ["image", "text", "video"]
output = ["text"]
@@ -8,4 +8,3 @@ output = 0
[modalities]
input = ["image", "text", "video"]
output = ["text"]
@@ -5,9 +5,7 @@ input = 0.12
output = 0.37
[limit]
context = 262_144
output = 16_384
[modalities]
input = ["image", "text", "video"]
output = ["text"]
@@ -8,4 +8,3 @@ output = 0
[modalities]
input = ["image", "text", "video"]
output = ["text"]
@@ -7,4 +7,3 @@ output = 1.2
[limit]
context = 196_608
output = 131_072
@@ -10,5 +10,4 @@ output = 1
cache_read = 0.03
[limit]
context = 196_608
output = 196_608
@@ -10,4 +10,3 @@ cache_read = 0.04
[modalities]
input = ["text", "pdf"]
output = ["text"]
@@ -8,4 +8,3 @@ cache_read = 0.05
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -12,4 +12,3 @@ cache_read = 0.09
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -10,4 +10,3 @@ cache_read = 0.144
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -12,4 +12,3 @@ output = 0
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -7,4 +7,3 @@ cache_read = 0.025
[modalities]
input = ["image", "text", "pdf"]
output = ["text"]
@@ -6,4 +6,3 @@ output = 15
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -7,4 +7,3 @@ cache_read = 1.25
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -7,4 +7,3 @@ cache_read = 1.25
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -6,7 +6,3 @@ attachment = true
input = 1.25
output = 10
cache_read = 0.125
[limit]
context = 400_000
output = 128_000
@@ -6,10 +6,5 @@ input = 0.25
output = 2
cache_read = 0.025
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -6,10 +6,5 @@ input = 0.05
output = 0.4
cache_read = 0.01
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]
@@ -6,9 +6,7 @@ input = 15
output = 120
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["image", "text", "pdf"]
output = ["text"]
@@ -5,7 +5,3 @@ base_model_omit = ["limit.input"]
input = 1.25
output = 10
cache_read = 0.125
[limit]
context = 400_000
output = 128_000
@@ -7,5 +7,4 @@ output = 2
cache_read = 0.025
[limit]
context = 400_000
output = 100_000
@@ -5,7 +5,3 @@ base_model_omit = ["limit.input"]
input = 1.25
output = 10
cache_read = 0.13
[limit]
context = 400_000
output = 128_000
@@ -6,10 +6,5 @@ input = 1.25
output = 10
cache_read = 0.13
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["image", "text", "pdf"]
output = ["text"]
@@ -6,10 +6,5 @@ input = 1.75
output = 14
cache_read = 0.175
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["text", "image"]
output = ["text"]
@@ -6,10 +6,5 @@ structured_output = true
input = 21
output = 168
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["image", "text", "pdf"]
output = ["text"]
@@ -6,10 +6,5 @@ input = 1.75
output = 14
cache_read = 0.175
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["pdf", "image", "text"]
output = ["text"]
@@ -5,7 +5,3 @@ base_model_omit = ["limit.input"]
input = 1.75
output = 14
cache_read = 0.175
[limit]
context = 400_000
output = 128_000
@@ -6,10 +6,5 @@ input = 0.75
output = 4.5
cache_read = 0.075
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["pdf", "image", "text"]
output = ["text"]
@@ -6,10 +6,5 @@ input = 0.2
output = 1.25
cache_read = 0.02
[limit]
context = 400_000
output = 128_000
[modalities]
input = ["pdf", "image", "text"]
output = ["text"]
@@ -7,4 +7,3 @@ output = 180
[modalities]
input = ["text", "image", "pdf"]
output = ["text"]

Some files were not shown because too many files have changed in this diff Show More