Files
sophon-realtime-guide/model.test.mjs
T

36 lines
1.4 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { builds, callModes, makeRecipe, toolSteps } from "./model.js";
test("every documented build and mode has distinct startup and request examples", () => {
for (const [key, build] of Object.entries(builds)) {
for (const mode of build.modes) {
assert.ok(callModes[mode]);
const example = makeRecipe(key, mode);
assert.ok(example.startup.includes("SKIP_DOWNLOAD=1"));
assert.ok(example.request.length > 30);
}
}
});
test("E2E cannot select an undocumented OpenAI-style entry", () => {
assert.throws(() => makeRecipe("e2e", "http"), RangeError);
assert.equal(callModes.e2e.endpoint, "ws://HOST:8000/ws");
});
test("Live and Realtime gateways retain their distinct event formats", () => {
assert.ok(
makeRecipe("flash", "live").request.includes("session.commentary.append"),
);
assert.ok(
makeRecipe("tag", "realtime").request.includes("function_call_output"),
);
assert.ok(
makeRecipe("flash", "http").startup.includes("python client_example.py"),
);
});
test("tool walkthrough distinguishes model output and actual execution", () => {
assert.equal(toolSteps.length, 7);
assert.ok(toolSteps[1].code.includes("<tool_call>"));
assert.ok(toolSteps[4].code.includes("actual_weather_service"));
assert.ok(toolSteps[5].code.includes("示例结果"));
});