From 41f9149be696bf4e745d734a3b4ec72ef2213e7e Mon Sep 17 00:00:00 2001 From: darkskygit Date: Tue, 3 Sep 2024 09:24:59 +0000 Subject: [PATCH] feat(server): support openai compatible stream api (#8065) fix #8010 --- .../backend/server/src/plugins/copilot/providers/openai.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/backend/server/src/plugins/copilot/providers/openai.ts b/packages/backend/server/src/plugins/copilot/providers/openai.ts index 4bc8aedf64..fd1d2bb2be 100644 --- a/packages/backend/server/src/plugins/copilot/providers/openai.ts +++ b/packages/backend/server/src/plugins/copilot/providers/openai.ts @@ -255,6 +255,9 @@ export class OpenAIProvider ); for await (const message of result) { + if (!Array.isArray(message.choices) || !message.choices.length) { + continue; + } const content = message.choices[0].delta.content; if (content) { yield content;