From 50ae6869d2bbe301bd32c8314fc6294cce60b01f Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 18 Jul 2025 01:05:37 -0700 Subject: [PATCH] test: update opeani-adapters tests --- packages/openai-adapters/src/test/main.test.ts | 1 + packages/openai-adapters/src/test/util.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index be4d8b809..f4d8de2d8 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -117,6 +117,7 @@ const TESTS: Omit[] = [ model: "gpt-4.1", apiBase: "https://continue-openai.openai.azure.com", apiKey: process.env.AZURE_OPENAI_GPT41_API_KEY, + roles: ["chat"], env: { deployment: "gpt-4.1", apiVersion: "2024-02-15-preview", diff --git a/packages/openai-adapters/src/test/util.ts b/packages/openai-adapters/src/test/util.ts index ac1647ff7..5c751e792 100644 --- a/packages/openai-adapters/src/test/util.ts +++ b/packages/openai-adapters/src/test/util.ts @@ -138,6 +138,10 @@ export function testChat( ); let completion = ""; for await (const result of stream) { + // Skip usage chunks that have empty choices array + if (result.choices.length === 0) { + continue; + } completion += result.choices[0].delta.content ?? ""; expect(result.choices.length).toBeGreaterThan(0); @@ -262,6 +266,10 @@ export function testChat( }, new AbortController().signal, )) { + // Skip usage chunks that have empty choices array + if (chunk.choices.length === 0) { + continue; + } const toolCall = chunk.choices[0].delta.tool_calls?.[0]; if (!toolCall) { continue; @@ -333,6 +341,10 @@ export function testChat( }, new AbortController().signal, )) { + // Skip usage chunks that have empty choices array + if (chunk.choices.length === 0) { + continue; + } response += chunk.choices[0].delta.content ?? ""; }