@stablekernel/pi-bifrost 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/datasheet.test.ts +55 -0
- package/src/datasheet.ts +26 -3
- package/src/index.ts +8 -1
- package/src/plugin.test.ts +20 -0
package/package.json
CHANGED
package/src/datasheet.test.ts
CHANGED
|
@@ -54,6 +54,60 @@ describe("parseDatasheet", () => {
|
|
|
54
54
|
} satisfies SupplementalModel);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
test("maps supports_image_input to image_input only when true", () => {
|
|
58
|
+
const out = parseDatasheet({
|
|
59
|
+
"fireworks_ai/accounts/fireworks/models/glm-5p3-flash": {
|
|
60
|
+
...glmFlash,
|
|
61
|
+
supports_image_input: true,
|
|
62
|
+
},
|
|
63
|
+
"fireworks_ai/accounts/fireworks/models/glm-5p2": {
|
|
64
|
+
...glmFlash,
|
|
65
|
+
supports_image_input: false,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
expect(out).toHaveLength(2);
|
|
69
|
+
const byId = new Map(out.map((m) => [m.id, m]));
|
|
70
|
+
expect(byId.get("accounts/fireworks/models/glm-5p3-flash")?.image_input).toBe(true);
|
|
71
|
+
expect(byId.get("accounts/fireworks/models/glm-5p2")?.image_input).toBeUndefined();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("maps supports_vision to image_input — the upstream field name (1570 rows vs 8 for supports_image_input)", () => {
|
|
75
|
+
const out = parseDatasheet({
|
|
76
|
+
"fireworks_ai/accounts/fireworks/models/deepseek-v4-flash-vision-exp": {
|
|
77
|
+
...glmFlash,
|
|
78
|
+
supports_vision: true,
|
|
79
|
+
},
|
|
80
|
+
"fireworks_ai/accounts/fireworks/models/deepseek-v4-flash": {
|
|
81
|
+
...glmFlash,
|
|
82
|
+
supports_vision: false,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
expect(out).toHaveLength(2);
|
|
86
|
+
const byId = new Map(out.map((m) => [m.id, m]));
|
|
87
|
+
expect(byId.get("accounts/fireworks/models/deepseek-v4-flash-vision-exp")?.image_input).toBe(true);
|
|
88
|
+
expect(byId.get("accounts/fireworks/models/deepseek-v4-flash")?.image_input).toBeUndefined();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("falls back to max_input_tokens when context_length is absent — upstream rows never carry context_length", () => {
|
|
92
|
+
const { context_length, ...upstreamShape } = glmFlash;
|
|
93
|
+
const out = parseDatasheet({
|
|
94
|
+
"fireworks_ai/accounts/fireworks/models/glm-5p3-flash": upstreamShape,
|
|
95
|
+
});
|
|
96
|
+
expect(out).toHaveLength(1);
|
|
97
|
+
expect(out[0].context_window).toBe(upstreamShape.max_input_tokens);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("reads cache_write from cache_creation_input_token_cost — the upstream field name (503 rows vs 0)", () => {
|
|
101
|
+
const out = parseDatasheet({
|
|
102
|
+
"fireworks_ai/accounts/fireworks/models/glm-5p3-flash": {
|
|
103
|
+
...glmFlash,
|
|
104
|
+
cache_creation_input_token_cost: 0.00000015,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
expect(out).toHaveLength(1);
|
|
108
|
+
expect(out[0].cost?.cache_write).toBe(0.15);
|
|
109
|
+
});
|
|
110
|
+
|
|
57
111
|
test("drops non-chat entries, unknown providers, and rows without limits", () => {
|
|
58
112
|
const out = parseDatasheet({
|
|
59
113
|
"fireworks_ai/accounts/fireworks/models/qwen3-embedding-8b": {
|
|
@@ -64,6 +118,7 @@ describe("parseDatasheet", () => {
|
|
|
64
118
|
"fireworks_ai/accounts/fireworks/models/no-limits": {
|
|
65
119
|
...glmFlash,
|
|
66
120
|
context_length: undefined,
|
|
121
|
+
max_input_tokens: undefined,
|
|
67
122
|
},
|
|
68
123
|
"fireworks_ai/accounts/fireworks/models/no-max-out": {
|
|
69
124
|
...glmFlash,
|
package/src/datasheet.ts
CHANGED
|
@@ -33,8 +33,16 @@ export type DatasheetEntry = {
|
|
|
33
33
|
input_cost_per_token?: number;
|
|
34
34
|
output_cost_per_token?: number;
|
|
35
35
|
cache_read_input_token_cost?: number;
|
|
36
|
+
// Upstream rows name the cache-write rate `cache_creation_input_token_cost`
|
|
37
|
+
// (503 rows); the `cache_write_…` spelling appears on zero rows and is
|
|
38
|
+
// kept for symmetry with Bifrost's own pricing-card vocabulary.
|
|
36
39
|
cache_write_input_token_cost?: number;
|
|
40
|
+
cache_creation_input_token_cost?: number;
|
|
37
41
|
supports_reasoning?: boolean;
|
|
42
|
+
// Upstream rows express image capability as `supports_vision` (1,570
|
|
43
|
+
// rows); `supports_image_input` appears on only 8. Either true counts.
|
|
44
|
+
supports_vision?: boolean;
|
|
45
|
+
supports_image_input?: boolean;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
/** A model in the same shape `gateway-cli models` emits (structural subset). */
|
|
@@ -52,6 +60,7 @@ export type SupplementalModel = {
|
|
|
52
60
|
cache_write: number;
|
|
53
61
|
};
|
|
54
62
|
reasoning?: boolean;
|
|
63
|
+
image_input?: boolean;
|
|
55
64
|
};
|
|
56
65
|
|
|
57
66
|
/** Datasheet provider prefixes whose entries this module understands. */
|
|
@@ -208,8 +217,16 @@ export function parseDatasheet(
|
|
|
208
217
|
if (!prefix) continue;
|
|
209
218
|
const id = key.slice(prefix.length);
|
|
210
219
|
if (!id) continue;
|
|
220
|
+
// Upstream rows never carry `context_length` (0 of 4,336); they state
|
|
221
|
+
// `max_input_tokens` instead. Either sets the context window.
|
|
222
|
+
const contextLength =
|
|
223
|
+
typeof e.context_length === "number"
|
|
224
|
+
? e.context_length
|
|
225
|
+
: typeof e.max_input_tokens === "number"
|
|
226
|
+
? e.max_input_tokens
|
|
227
|
+
: undefined;
|
|
211
228
|
if (
|
|
212
|
-
typeof
|
|
229
|
+
typeof contextLength !== "number" ||
|
|
213
230
|
typeof e.max_output_tokens !== "number"
|
|
214
231
|
) {
|
|
215
232
|
continue;
|
|
@@ -222,7 +239,7 @@ export function parseDatasheet(
|
|
|
222
239
|
id,
|
|
223
240
|
name:
|
|
224
241
|
typeof e.base_model === "string" && e.base_model ? e.base_model : slug,
|
|
225
|
-
context_window:
|
|
242
|
+
context_window: contextLength,
|
|
226
243
|
max_output_tokens: e.max_output_tokens,
|
|
227
244
|
limits_source: "datasheet",
|
|
228
245
|
...(priced
|
|
@@ -232,11 +249,17 @@ export function parseDatasheet(
|
|
|
232
249
|
input: perMillion(e.input_cost_per_token),
|
|
233
250
|
output: perMillion(e.output_cost_per_token),
|
|
234
251
|
cache_read: perMillion(e.cache_read_input_token_cost),
|
|
235
|
-
cache_write: perMillion(
|
|
252
|
+
cache_write: perMillion(
|
|
253
|
+
e.cache_write_input_token_cost ??
|
|
254
|
+
e.cache_creation_input_token_cost,
|
|
255
|
+
),
|
|
236
256
|
},
|
|
237
257
|
}
|
|
238
258
|
: {}),
|
|
239
259
|
...(e.supports_reasoning === true ? { reasoning: true } : {}),
|
|
260
|
+
...(e.supports_image_input === true || e.supports_vision === true
|
|
261
|
+
? { image_input: true }
|
|
262
|
+
: {}),
|
|
240
263
|
});
|
|
241
264
|
}
|
|
242
265
|
return out;
|
package/src/index.ts
CHANGED
|
@@ -118,6 +118,10 @@ export type CliModel = {
|
|
|
118
118
|
reasoning?: boolean;
|
|
119
119
|
reasoning_efforts?: string[];
|
|
120
120
|
reasoning_budget_min?: number;
|
|
121
|
+
/** True when the model accepts image content blocks (from the catalog's
|
|
122
|
+
* modalities.input). Absent means text-only, so a harness never guesses a
|
|
123
|
+
* capability from silence. */
|
|
124
|
+
image_input?: boolean;
|
|
121
125
|
};
|
|
122
126
|
|
|
123
127
|
export type CliModels = { models?: CliModel[] };
|
|
@@ -216,7 +220,10 @@ export function toPiModels(
|
|
|
216
220
|
id: m.id,
|
|
217
221
|
name: priced ? m.name : `${m.name}${UNPRICED_SUFFIX}`,
|
|
218
222
|
reasoning,
|
|
219
|
-
input
|
|
223
|
+
// pi strips image blocks for any model whose input lacks "image".
|
|
224
|
+
// Hardcoding ["text"] here silently blinded every gateway model;
|
|
225
|
+
// the capability must come from the CLI, like reasoning does.
|
|
226
|
+
input: m.image_input ? ["text", "image"] : ["text"],
|
|
220
227
|
cost: {
|
|
221
228
|
input: m.cost?.input ?? 0,
|
|
222
229
|
output: m.cost?.output ?? 0,
|
package/src/plugin.test.ts
CHANGED
|
@@ -334,6 +334,26 @@ describe("disabled models", () => {
|
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
336
|
|
|
337
|
+
describe("image input", () => {
|
|
338
|
+
test("declares image input when the CLI advertises it", async () => {
|
|
339
|
+
// Pi strips image blocks for any model whose input does not include
|
|
340
|
+
// "image". The extension used to hardcode ["text"], which silently
|
|
341
|
+
// blinded every gateway-provided model in pi.
|
|
342
|
+
const { toPiModels } = await import("./index.js");
|
|
343
|
+
const [model] = toPiModels(
|
|
344
|
+
{ models: [{ ...NOVA, image_input: true }] },
|
|
345
|
+
"openai-completions",
|
|
346
|
+
);
|
|
347
|
+
expect(model?.input).toEqual(["text", "image"]);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test("stays text-only when the CLI is silent", async () => {
|
|
351
|
+
const { toPiModels } = await import("./index.js");
|
|
352
|
+
const [model] = toPiModels({ models: [NOVA] }, "openai-completions");
|
|
353
|
+
expect(model?.input).toEqual(["text"]);
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
337
357
|
describe("reasoning", () => {
|
|
338
358
|
const KIMI: CliModel = {
|
|
339
359
|
id: "fireworks/models/kimi-k3",
|