Compare commits
4
Commits
dev
...
model-variants
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77f42b5912 | ||
|
|
e644b5de83 | ||
|
|
41414897a3 | ||
|
|
56686cdda6 |
No files matched your search
@@ -105,10 +105,24 @@ items are **hard blockers**; the last two are **strongly recommended** but not b
|
||||
- Plain objects from metadata and provider TOML (`[limit]`, `[modalities]`, …) are **deep-merged**
|
||||
- Arrays (e.g. `modalities.input`) and primitives are **replaced** wholesale by the child
|
||||
- Any provider field omitted is inherited verbatim from model metadata
|
||||
- `cost`, `provider`, `experimental`, `reasoning_options`, `interleaved`, and `status` are provider-specific and must be declared in provider TOMLs when needed
|
||||
- `cost`, `provider`, `experimental`, `reasoning_options`, `variants`, `interleaved`, and `status` are provider-specific and must be declared in provider TOMLs when needed
|
||||
- `base_model_omit` runs **after** the merge and deletes each dot-path from the result. Missing paths are ignored. Ancestor tables that become empty as a result are also pruned.
|
||||
- The base model metadata file must exist; `base_model` pointing at a missing `models/` entry is an error
|
||||
|
||||
### Provider request variants
|
||||
|
||||
- Provider model TOMLs may declare exact request bodies under `variants.<id>` when semantic `reasoning_options` are insufficient to describe the provider's wire format.
|
||||
- Variant values are copied unchanged into clients' ordinary model variants; do not use them for client-specific transformations.
|
||||
- Select an ordinary default variant with `provider.variant`. Use `provider.body` only for defaults shared by every variant.
|
||||
- Example:
|
||||
```toml
|
||||
[variants.none.chat_template_kwargs]
|
||||
thinking_mode = "disabled"
|
||||
|
||||
[variants.thinking.chat_template_kwargs]
|
||||
thinking_mode = "enabled"
|
||||
```
|
||||
|
||||
### Bedrock Naming Patterns
|
||||
- Dated models: `-v1:0` suffix (`anthropic.claude-3-5-sonnet-20241022-v1:0.toml`)
|
||||
- Latest/undated models: bare `-v1` (`anthropic.claude-opus-4-6-v1.toml`)
|
||||
|
||||
@@ -3,12 +3,7 @@ import { z } from "zod";
|
||||
import { ModelFamily } from "./family";
|
||||
|
||||
type JsonValue =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| { [key: string]: JsonValue }
|
||||
| JsonValue[];
|
||||
string | number | boolean | null | { [key: string]: JsonValue } | JsonValue[];
|
||||
|
||||
const JsonValue: z.ZodType<JsonValue> = z.lazy(() =>
|
||||
z.union([
|
||||
@@ -25,7 +20,16 @@ const ReasoningEffortValue = z.preprocess(
|
||||
(value) => (value === "null" ? null : value),
|
||||
z.union([
|
||||
z.null(),
|
||||
z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"]),
|
||||
z.enum([
|
||||
"none",
|
||||
"minimal",
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
"xhigh",
|
||||
"max",
|
||||
"default",
|
||||
]),
|
||||
]),
|
||||
);
|
||||
|
||||
@@ -219,6 +223,7 @@ const ModelBase = z.object({
|
||||
attachment: z.boolean(),
|
||||
reasoning: z.boolean(),
|
||||
reasoning_options: z.array(ReasoningOption).optional(),
|
||||
variants: z.record(z.record(JsonValue)).optional(),
|
||||
tool_call: z.boolean(),
|
||||
interleaved: z
|
||||
.union([
|
||||
@@ -266,6 +271,7 @@ const ModelBase = z.object({
|
||||
npm: z.string().optional(),
|
||||
api: z.string().optional(),
|
||||
shape: z.enum(["responses", "completions"]).optional(),
|
||||
variant: z.string().optional(),
|
||||
body: z.record(JsonValue).optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
})
|
||||
@@ -273,7 +279,8 @@ const ModelBase = z.object({
|
||||
});
|
||||
|
||||
function refineModel<
|
||||
Output extends z.infer<typeof ModelShape> | z.infer<typeof AuthoredModelShape>,
|
||||
Output extends
|
||||
z.infer<typeof ModelShape> | z.infer<typeof AuthoredModelShape>,
|
||||
Def extends z.ZodTypeDef,
|
||||
Input,
|
||||
>(schema: z.ZodType<Output, Def, Input>) {
|
||||
@@ -296,6 +303,18 @@ function refineModel<
|
||||
path: ["reasoning_options"],
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
return (
|
||||
data.provider?.variant === undefined ||
|
||||
data.variants?.[data.provider.variant] !== undefined
|
||||
);
|
||||
},
|
||||
{
|
||||
message: "Provider default variant must reference a declared variant",
|
||||
path: ["provider", "variant"],
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
return !(
|
||||
|
||||
@@ -37,8 +37,16 @@ function stable(value: unknown): string {
|
||||
describe("catalog generation", () => {
|
||||
test("base_model can factor metadata without changing provider JSON", async () => {
|
||||
await withFixture(async (root) => {
|
||||
await write(root, "providers/direct/provider.toml", providerToml("Direct"));
|
||||
await write(root, "providers/factored/provider.toml", providerToml("Factored"));
|
||||
await write(
|
||||
root,
|
||||
"providers/direct/provider.toml",
|
||||
providerToml("Direct"),
|
||||
);
|
||||
await write(
|
||||
root,
|
||||
"providers/factored/provider.toml",
|
||||
providerToml("Factored"),
|
||||
);
|
||||
await write(root, "models/lab/model.toml", modelMetadataToml());
|
||||
await write(
|
||||
root,
|
||||
@@ -100,7 +108,11 @@ cache_read = 0.125
|
||||
|
||||
test("base_model_omit removes inherited metadata fields", async () => {
|
||||
await withFixture(async (root) => {
|
||||
await write(root, "providers/provider/provider.toml", providerToml("Provider"));
|
||||
await write(
|
||||
root,
|
||||
"providers/provider/provider.toml",
|
||||
providerToml("Provider"),
|
||||
);
|
||||
await write(root, "models/lab/model.toml", modelMetadataToml());
|
||||
await write(
|
||||
root,
|
||||
@@ -132,7 +144,11 @@ 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,
|
||||
"providers/provider/provider.toml",
|
||||
providerToml("Provider"),
|
||||
);
|
||||
await write(root, "models/lab/model.toml", modelMetadataToml());
|
||||
await write(
|
||||
root,
|
||||
@@ -169,6 +185,49 @@ input = ["text"]
|
||||
});
|
||||
});
|
||||
|
||||
test("provider request defaults and variants are emitted unchanged", async () => {
|
||||
await withFixture(async (root) => {
|
||||
await write(
|
||||
root,
|
||||
"providers/provider/provider.toml",
|
||||
providerToml("Provider"),
|
||||
);
|
||||
await write(
|
||||
root,
|
||||
"providers/provider/models/model.toml",
|
||||
`${providerFieldsToml()}
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[provider]
|
||||
variant = "thinking"
|
||||
body = { thinking = { type = "adaptive" } }
|
||||
|
||||
[cost]
|
||||
input = 1.25
|
||||
output = 2.50
|
||||
`,
|
||||
);
|
||||
|
||||
const providers = await generate(path.join(root, "providers"));
|
||||
|
||||
expect(providers.provider?.models.model).toMatchObject({
|
||||
variants: {
|
||||
none: { thinking: { type: "disabled" } },
|
||||
thinking: { thinking: { type: "adaptive" } },
|
||||
},
|
||||
provider: {
|
||||
variant: "thinking",
|
||||
body: { thinking: { type: "adaptive" } },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("repository provider TOMLs do not use legacy extends tables", async () => {
|
||||
const root = path.join(import.meta.dirname, "..", "..", "..");
|
||||
const matches: string[] = [];
|
||||
@@ -191,7 +250,10 @@ input = ["text"]
|
||||
for (const [providerID, provider] of Object.entries(providers)) {
|
||||
for (const [modelID, model] of Object.entries(provider.models)) {
|
||||
const encoded = stable(model);
|
||||
if (encoded.includes("base_model") || encoded.includes("base_model_omit")) {
|
||||
if (
|
||||
encoded.includes("base_model") ||
|
||||
encoded.includes("base_model_omit")
|
||||
) {
|
||||
leaked.push(`${providerID}/${modelID}`);
|
||||
}
|
||||
}
|
||||
@@ -228,7 +290,7 @@ input = ["text"]
|
||||
"zai",
|
||||
];
|
||||
const namespaceDirs = providerNamespaces.filter((namespace) =>
|
||||
existsSync(path.join(root, "models", namespace))
|
||||
existsSync(path.join(root, "models", namespace)),
|
||||
);
|
||||
const baseModelRefs: string[] = [];
|
||||
|
||||
|
||||
@@ -29,6 +29,33 @@ describe("model schema", () => {
|
||||
|
||||
expect(AuthoredModel.safeParse(model).success).toBe(false);
|
||||
});
|
||||
|
||||
test("accepts provider request variants", () => {
|
||||
const model = baseModel({
|
||||
reasoning: true,
|
||||
reasoning_options: [{ type: "toggle" }],
|
||||
variants: {
|
||||
none: { chat_template_kwargs: { thinking_mode: "disabled" } },
|
||||
thinking: { chat_template_kwargs: { thinking_mode: "enabled" } },
|
||||
},
|
||||
});
|
||||
|
||||
expect(AuthoredModel.parse(model).variants).toEqual({
|
||||
none: { chat_template_kwargs: { thinking_mode: "disabled" } },
|
||||
thinking: { chat_template_kwargs: { thinking_mode: "enabled" } },
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects an undeclared provider default variant", () => {
|
||||
const model = baseModel({
|
||||
reasoning: true,
|
||||
reasoning_options: [{ type: "toggle" }],
|
||||
variants: { none: { thinking: { type: "disabled" } } },
|
||||
provider: { variant: "thinking" },
|
||||
});
|
||||
|
||||
expect(AuthoredModel.safeParse(model).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
function baseModel(overrides: Partial<AuthoredModelData>) {
|
||||
|
||||
@@ -192,6 +192,8 @@ export interface ModelProviderConfig {
|
||||
api?: string
|
||||
/** API shape when the npm package supports multiple. */
|
||||
shape?: "responses" | "completions"
|
||||
/** Variant selected when a request does not choose one explicitly. */
|
||||
variant?: string
|
||||
/** Extra request body fields required by this model. */
|
||||
body?: Record<string, JsonValue>
|
||||
/** Extra request headers required by this model. */
|
||||
@@ -214,6 +216,8 @@ export interface Model {
|
||||
reasoning: boolean
|
||||
/** Present exactly when `reasoning` is true. */
|
||||
reasoning_options?: ReasoningOption[]
|
||||
/** Provider-authored request body variants keyed by variant ID. */
|
||||
variants?: Record<string, Record<string, JsonValue>>
|
||||
/** Supports tool/function calling. */
|
||||
tool_call: boolean
|
||||
/** Supports interleaved thinking between tool calls. */
|
||||
|
||||
@@ -3,6 +3,12 @@ base_model = "minimax/MiniMax-M3"
|
||||
[[reasoning_options]]
|
||||
type = "toggle"
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0.33
|
||||
output = 1.32
|
||||
|
||||
@@ -3,6 +3,12 @@ name = "MiniMax: MiniMax M3"
|
||||
last_updated = "2026-06-30"
|
||||
reasoning_options = [{ type = "toggle" }]
|
||||
|
||||
[variants.none.reasoning]
|
||||
enabled = false
|
||||
|
||||
[variants.thinking.reasoning]
|
||||
enabled = true
|
||||
|
||||
[cost]
|
||||
input = 0.3
|
||||
output = 1.2
|
||||
|
||||
@@ -7,6 +7,12 @@ family = "minimax-m3"
|
||||
reasoning_options = [{ type = "toggle" }]
|
||||
structured_output = true
|
||||
|
||||
[variants.none.chat_template_kwargs]
|
||||
thinking_mode = "disabled"
|
||||
|
||||
[variants.thinking.chat_template_kwargs]
|
||||
thinking_mode = "enabled"
|
||||
|
||||
[cost]
|
||||
input = 0.28
|
||||
output = 1.1
|
||||
|
||||
@@ -12,6 +12,12 @@ open_weights = true
|
||||
[[reasoning_options]]
|
||||
type = "toggle"
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
@@ -25,3 +31,6 @@ output = 128_000
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
|
||||
[provider]
|
||||
variant = "thinking"
|
||||
@@ -12,6 +12,12 @@ open_weights = true
|
||||
[[reasoning_options]]
|
||||
type = "toggle"
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0.30
|
||||
output = 1.20
|
||||
@@ -30,3 +36,6 @@ output = 128_000
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
|
||||
[provider]
|
||||
variant = "thinking"
|
||||
@@ -12,6 +12,12 @@ open_weights = true
|
||||
[[reasoning_options]]
|
||||
type = "toggle"
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
@@ -25,3 +31,6 @@ output = 128_000
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
|
||||
[provider]
|
||||
variant = "thinking"
|
||||
@@ -12,6 +12,12 @@ open_weights = true
|
||||
[[reasoning_options]]
|
||||
type = "toggle"
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0.30
|
||||
output = 1.20
|
||||
@@ -30,3 +36,6 @@ output = 128_000
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
|
||||
[provider]
|
||||
variant = "thinking"
|
||||
@@ -1,6 +1,12 @@
|
||||
base_model = "minimax/MiniMax-M3"
|
||||
reasoning_options = [{ type = "toggle" }]
|
||||
|
||||
[variants.none.chat_template_kwargs]
|
||||
thinking_mode = "disabled"
|
||||
|
||||
[variants.thinking.chat_template_kwargs]
|
||||
thinking_mode = "enabled"
|
||||
|
||||
[cost]
|
||||
input = 0.0
|
||||
output = 0.0
|
||||
|
||||
@@ -11,6 +11,12 @@ tool_call = true
|
||||
knowledge = "2025-01"
|
||||
open_weights = true
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0.3
|
||||
output = 1.2
|
||||
@@ -32,3 +38,4 @@ output = ["text"]
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/anthropic"
|
||||
variant = "thinking"
|
||||
@@ -12,6 +12,12 @@ knowledge = "2025-01"
|
||||
open_weights = true
|
||||
status = "deprecated"
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
@@ -27,3 +33,4 @@ output = ["text"]
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/anthropic"
|
||||
variant = "thinking"
|
||||
@@ -1,6 +1,12 @@
|
||||
base_model = "minimax/MiniMax-M3"
|
||||
reasoning_options = [{ type = "toggle" }]
|
||||
|
||||
[variants.none.thinking]
|
||||
type = "disabled"
|
||||
|
||||
[variants.thinking.thinking]
|
||||
type = "adaptive"
|
||||
|
||||
[cost]
|
||||
input = 0.60
|
||||
output = 2.40
|
||||
@@ -8,3 +14,4 @@ output = 2.40
|
||||
[provider]
|
||||
npm = "@ai-sdk/anthropic"
|
||||
api = "https://zenmux.ai/api/anthropic/v1"
|
||||
variant = "thinking"
|
||||
Reference in new issue
Block a user