Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat(server): support openai compatible stream api (#8065)

darkskygit41f9149be696
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;