mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
Merge pull request #7401 from earendil-works/fix-model-tests
fix(ai): update Z.AI model test references
This commit is contained in:
commit
fbab971da2
8 changed files with 23 additions and 65 deletions
|
|
@ -354,8 +354,8 @@ describe("Context overflow error handling", () => {
|
|||
// =============================================================================
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("z.ai", () => {
|
||||
it("glm-4.5-air - should detect overflow via isContextOverflow when z.ai reports it", async () => {
|
||||
const model = getModel("zai", "glm-4.5-air");
|
||||
it("glm-5.2 - should detect overflow via isContextOverflow when z.ai reports it", async () => {
|
||||
const model = getModel("zai", "glm-5.2");
|
||||
const result = await testContextOverflow(model, process.env.ZAI_API_KEY!);
|
||||
logResult(result);
|
||||
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ describe("AI Providers Empty Message Tests", () => {
|
|||
});
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider Empty Messages", () => {
|
||||
const llm = getModel("zai", "glm-4.5-air");
|
||||
const llm = getModel("zai", "glm-5.2");
|
||||
|
||||
it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => {
|
||||
await testEmptyMessage(llm);
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ describe("openai-completions tool_choice", () => {
|
|||
});
|
||||
|
||||
it("enables tool_stream for supported z.ai models with tools", async () => {
|
||||
const model = getModel("zai", "glm-5.1")!;
|
||||
const model = getModel("zai", "glm-5.2")!;
|
||||
const tools: Tool[] = [
|
||||
{
|
||||
name: "ping",
|
||||
|
|
@ -289,11 +289,10 @@ describe("openai-completions tool_choice", () => {
|
|||
});
|
||||
|
||||
it("stores z.ai tool_stream support in model compat metadata", () => {
|
||||
expect(getModel("zai", "glm-5.1")?.compat?.zaiToolStream).toBe(true);
|
||||
expect(getModel("zai", "glm-4.7")?.compat?.zaiToolStream).toBe(true);
|
||||
expect(getModel("zai", "glm-4.7")?.compat?.zaiToolStream).toBe(true);
|
||||
expect(getModel("zai", "glm-5-turbo")?.compat?.zaiToolStream).toBe(true);
|
||||
expect(getModel("zai", "glm-4.5-air")?.compat?.zaiToolStream).toBeUndefined();
|
||||
expect(getModel("zai", "glm-5.2")?.compat?.zaiToolStream).toBe(true);
|
||||
});
|
||||
|
||||
it("stores z.ai GLM-5.2 effort metadata", () => {
|
||||
|
|
@ -436,45 +435,8 @@ describe("openai-completions tool_choice", () => {
|
|||
expect(params.reasoning_effort).toBeUndefined();
|
||||
});
|
||||
|
||||
it("omits tool_stream for unsupported z.ai models", async () => {
|
||||
const model = getModel("zai", "glm-4.5-air")!;
|
||||
const tools: Tool[] = [
|
||||
{
|
||||
name: "ping",
|
||||
description: "Ping tool",
|
||||
parameters: Type.Object({
|
||||
ok: Type.Boolean(),
|
||||
}),
|
||||
},
|
||||
];
|
||||
let payload: unknown;
|
||||
|
||||
await streamSimple(
|
||||
model,
|
||||
{
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "Call ping with ok=true",
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
],
|
||||
tools,
|
||||
},
|
||||
{
|
||||
apiKey: "test",
|
||||
onPayload: (params: unknown) => {
|
||||
payload = params;
|
||||
},
|
||||
},
|
||||
).result();
|
||||
|
||||
const params = (payload ?? mockState.lastParams) as { tool_stream?: boolean };
|
||||
expect(params.tool_stream).toBeUndefined();
|
||||
});
|
||||
|
||||
it("respects explicit z.ai tool_stream compat override", async () => {
|
||||
const baseModel = getModel("zai", "glm-4.5-air")!;
|
||||
const baseModel = getModel("zai", "glm-5.2")!;
|
||||
const model = {
|
||||
...baseModel,
|
||||
compat: {
|
||||
|
|
@ -518,7 +480,7 @@ describe("openai-completions tool_choice", () => {
|
|||
});
|
||||
|
||||
it("omits tool_stream when no tools are provided", async () => {
|
||||
const model = getModel("zai", "glm-5.1")!;
|
||||
const model = getModel("zai", "glm-5.2")!;
|
||||
let payload: unknown;
|
||||
|
||||
await streamSimple(
|
||||
|
|
@ -560,7 +522,7 @@ describe("openai-completions tool_choice", () => {
|
|||
},
|
||||
];
|
||||
|
||||
const model = getModel("zai", "glm-5.1")!;
|
||||
const model = getModel("zai", "glm-5.2")!;
|
||||
const response = await streamSimple(
|
||||
model,
|
||||
{
|
||||
|
|
@ -1467,7 +1429,7 @@ describe("openai-completions tool_choice", () => {
|
|||
});
|
||||
|
||||
it("sends max_tokens for Z.AI completions models", async () => {
|
||||
const cases = [getModel("zai", "glm-5.1")!, getModel("zai", "glm-5.2")!] as const;
|
||||
const cases = [getModel("zai", "glm-5-turbo")!, getModel("zai", "glm-5.2")!] as const;
|
||||
|
||||
for (const model of cases) {
|
||||
expect(model.compat?.maxTokensField).toBe("max_tokens");
|
||||
|
|
|
|||
|
|
@ -919,8 +919,8 @@ describe("Generate E2E Tests", () => {
|
|||
},
|
||||
);
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-5.1 via OpenAI Completions)", () => {
|
||||
const llm = getModel("zai", "glm-5.1");
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-5.2 via OpenAI Completions)", () => {
|
||||
const llm = getModel("zai", "glm-5.2");
|
||||
|
||||
it("should complete basic text generation", { retry: 3 }, async () => {
|
||||
await basicTextGeneration(llm);
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ describe("Token Statistics on Abort", () => {
|
|||
});
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider", () => {
|
||||
const llm = getModel("zai", "glm-4.5-air");
|
||||
const llm = getModel("zai", "glm-5.2");
|
||||
|
||||
it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => {
|
||||
await testTokensOnAbort(llm);
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ describe("Tool Call Without Result Tests", () => {
|
|||
});
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider", () => {
|
||||
const model = getModel("zai", "glm-4.5-air");
|
||||
const model = getModel("zai", "glm-5.2");
|
||||
|
||||
it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => {
|
||||
await testToolCallWithoutResult(model);
|
||||
|
|
|
|||
|
|
@ -400,22 +400,18 @@ describe("totalTokens field", () => {
|
|||
// =========================================================================
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("z.ai", () => {
|
||||
it(
|
||||
"glm-4.5-air - should return totalTokens equal to sum of components",
|
||||
{ retry: 3, timeout: 60000 },
|
||||
async () => {
|
||||
const llm = getModel("zai", "glm-4.5-air");
|
||||
it("glm-5.2 - should return totalTokens equal to sum of components", { retry: 3, timeout: 60000 }, async () => {
|
||||
const llm = getModel("zai", "glm-5.2");
|
||||
|
||||
console.log(`\nz.ai / ${llm.id}:`);
|
||||
const { first, second } = await testTotalTokensWithCache(llm, { apiKey: process.env.ZAI_API_KEY });
|
||||
console.log(`\nz.ai / ${llm.id}:`);
|
||||
const { first, second } = await testTotalTokensWithCache(llm, { apiKey: process.env.ZAI_API_KEY });
|
||||
|
||||
logUsage("First request", first);
|
||||
logUsage("Second request", second);
|
||||
logUsage("First request", first);
|
||||
logUsage("Second request", second);
|
||||
|
||||
assertTotalTokensEqualsComponents(first);
|
||||
assertTotalTokensEqualsComponents(second);
|
||||
},
|
||||
);
|
||||
assertTotalTokensEqualsComponents(first);
|
||||
assertTotalTokensEqualsComponents(second);
|
||||
});
|
||||
});
|
||||
|
||||
// =========================================================================
|
||||
|
|
|
|||
|
|
@ -563,7 +563,7 @@ describe("AI Providers Unicode Surrogate Pair Tests", () => {
|
|||
});
|
||||
|
||||
describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider Unicode Handling", () => {
|
||||
const llm = getModel("zai", "glm-4.5-air");
|
||||
const llm = getModel("zai", "glm-5.2");
|
||||
|
||||
it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => {
|
||||
await testEmojiInToolResults(llm);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue