




















@@ -1446,7 +1446,9 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
14461446| string
14471447| undefined) === "get_weather",
14481448);
1449-expect(withIdentity).toBeTruthy();
1449+if (!withIdentity) {
1450+throw new Error("expected tool call delta with identity");
1451+}
14501452const argsJoined = toolCallDeltaRecords
14511453.filter((record) => record.index === 0)
14521454.map(
@@ -1460,7 +1462,9 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
14601462const finishChunk = toolCallChunks
14611463.flatMap((chunk) => (chunk.choices as Array<Record<string, unknown>> | undefined) ?? [])
14621464.find((choice) => choice.finish_reason === "tool_calls");
1463-expect(finishChunk).toBeTruthy();
1465+if (!finishChunk) {
1466+throw new Error("expected tool_calls finish chunk");
1467+}
14641468}
1465146914661470{
@@ -1499,9 +1503,11 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
14991503.filter((d) => d !== "[DONE]")
15001504.map((d) => JSON.parse(d) as Record<string, unknown>);
15011505const usageChunk = jsonChunks.find((chunk) => "usage" in chunk);
1502-expect(usageChunk).toBeTruthy();
1503-expect(usageChunk?.choices).toEqual([]);
1504-expect(usageChunk?.usage).toEqual({
1506+if (!usageChunk) {
1507+throw new Error("expected streamed usage chunk");
1508+}
1509+expect(usageChunk.choices).toEqual([]);
1510+expect(usageChunk.usage).toEqual({
15051511prompt_tokens: 12,
15061512completion_tokens: 3,
15071513total_tokens: 15,
@@ -1566,7 +1572,9 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
15661572const finishChunk = lateToolCallChunks
15671573.flatMap((chunk) => (chunk.choices as Array<Record<string, unknown>> | undefined) ?? [])
15681574.find((choice) => choice.finish_reason === "tool_calls");
1569-expect(finishChunk).toBeTruthy();
1575+if (!finishChunk) {
1576+throw new Error("expected late tool_calls finish chunk");
1577+}
15701578const anyToolCalls = lateToolCallChunks.some((chunk) => {
15711579const choice = ((chunk.choices as Array<Record<string, unknown>> | undefined) ?? [])[0];
15721580const delta = (choice?.delta as Record<string, unknown> | undefined) ?? {};
@@ -1608,7 +1616,9 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
16081616((chunk.error as { type?: unknown }).type ?? "") === "invalid_request_error" &&
16091617((chunk.error as { message?: unknown }).message ?? "") === "invalid tool configuration",
16101618);
1611-expect(protocolError).toBeTruthy();
1619+if (!protocolError) {
1620+throw new Error("expected invalid tool configuration protocol error");
1621+}
16121622const stopChoice = toolConflictChunks
16131623.flatMap((c) => (c.choices as Array<Record<string, unknown>> | undefined) ?? [])
16141624.find((choice) => choice.finish_reason === "stop");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。