Files
dev/third_party/pi/packages/ai/test/xiaomi-models.test.ts
alexion 6081e3e325 chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
2026-10-15 17:58:48 -04:00

56 lines
2.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { getModels, streamSimple } from "../src/compat.ts";
import { getSupportedThinkingLevels } from "../src/models.ts";
import type { ThinkingLevel } from "../src/types.ts";
const XIAOMI_PROVIDERS = ["xiaomi", "xiaomi-token-plan-cn", "xiaomi-token-plan-ams", "xiaomi-token-plan-sgp"] as const;
const DEPRECATED_MODEL_IDS = ["mimo-v2-flash", "mimo-v2-omni", "mimo-v2-pro"] as const;
const REPLACEMENT_MODEL_IDS = ["mimo-v2.5", "mimo-v2.5-pro"] as const;
describe("Xiaomi MiMo models", () => {
it.each(XIAOMI_PROVIDERS)("omits deprecated models from %s", (provider) => {
const modelIds = getModels(provider).map((model) => model.id);
for (const modelId of DEPRECATED_MODEL_IDS) expect(modelIds).not.toContain(modelId);
});
it.each(XIAOMI_PROVIDERS)("keeps replacement models on %s", (provider) => {
const modelIds = getModels(provider).map((model) => model.id);
for (const modelId of REPLACEMENT_MODEL_IDS) expect(modelIds).toContain(modelId);
});
// #10818: MiMo Chat Completions only supports a thinking on/off toggle.
it.each(XIAOMI_PROVIDERS)("models %s reasoning as an off/on toggle", async (provider) => {
const models = getModels(provider).filter((model) => model.reasoning);
expect(models.length).toBeGreaterThan(0);
for (const model of models) {
expect(getSupportedThinkingLevels(model)).toEqual(["off", "high"]);
const capturePayload = async (reasoning: ThinkingLevel | undefined) => {
let payload: Record<string, unknown> | undefined;
await streamSimple(
model,
{ messages: [{ role: "user", content: "test", timestamp: 0 }] },
{
apiKey: "test-xiaomi-key",
reasoning,
onPayload: (value) => {
payload = value as Record<string, unknown>;
throw new Error("payload captured");
},
},
).result();
return payload;
};
const enabled = await capturePayload("high");
expect(enabled?.thinking).toEqual({ type: "enabled" });
expect(enabled?.reasoning_effort).toBeUndefined();
const disabled = await capturePayload(undefined);
expect(disabled?.thinking).toEqual({ type: "disabled" });
expect(disabled?.reasoning_effort).toBeUndefined();
}
});
});