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.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(server): upgrade models to gpt4.1 (#11696)
darkskygite0970daa5a45
diff --git a/packages/backend/server/src/__tests__/copilot-provider.spec.ts b/packages/backend/server/src/__tests__/copilot-provider.spec.tsindex 047b43a7ae..a03d685915 100644--- a/packages/backend/server/src/__tests__/copilot-provider.spec.ts+++ b/packages/backend/server/src/__tests__/copilot-provider.spec.ts@@ -461,8 +461,9 @@ const actions = [],verifier: (t: ExecutionContext<Tester>, result: string) => {assertNotWrappedInCodeBlock(t, result);+ const cleared = result.toLowerCase();t.assert(- result.toLowerCase().includes('单一事实来源'),+ cleared.includes('单一') || cleared.includes('SSOT'),'explain code result should include keyword');},diff --git a/packages/backend/server/src/__tests__/mocks/copilot.mock.ts b/packages/backend/server/src/__tests__/mocks/copilot.mock.tsindex 7f7014a8e8..0d34dde72d 100644--- a/packages/backend/server/src/__tests__/mocks/copilot.mock.ts+++ b/packages/backend/server/src/__tests__/mocks/copilot.mock.ts@@ -17,6 +17,9 @@ export class MockCopilotProvider extends OpenAIProvider {'test','gpt-4o','gpt-4o-2024-08-06',+ 'gpt-4.1',+ 'gpt-4.1-2025-04-14',+ 'gpt-4.1-mini','fast-sdxl/image-to-image','lcm-sd15-i2i','clarity-upscaler',@@ -47,7 +50,7 @@ export class MockCopilotProvider extends OpenAIProvider {override async *generateTextStream(messages: PromptMessage[],- model: string = 'gpt-4o-mini',+ model: string = 'gpt-4.1-mini',options: CopilotChatOptions = {}): AsyncIterable<string> {this.checkParams({ messages, model, options });diff --git a/packages/backend/server/src/plugins/copilot/prompt/prompts.ts b/packages/backend/server/src/plugins/copilot/prompt/prompts.tsindex 85471b3655..eeed0ceba4 100644--- a/packages/backend/server/src/plugins/copilot/prompt/prompts.ts+++ b/packages/backend/server/src/plugins/copilot/prompt/prompts.ts@@ -142,7 +142,7 @@ const workflows: Prompt[] = [{name: 'workflow:image-sketch:step2',action: 'workflow:image-sketch:step2',- model: 'gpt-4o-mini-2024-07-18',+ model: 'gpt-4.1-mini',messages: [{role: 'system',@@ -179,7 +179,7 @@ const workflows: Prompt[] = [{name: 'workflow:image-clay:step2',action: 'workflow:image-clay:step2',- model: 'gpt-4o-mini-2024-07-18',+ model: 'gpt-4.1-mini',messages: [{role: 'system',@@ -216,7 +216,7 @@ const workflows: Prompt[] = [{name: 'workflow:image-anime:step2',action: 'workflow:image-anime:step2',- model: 'gpt-4o-mini-2024-07-18',+ model: 'gpt-4.1-mini',messages: [{role: 'system',@@ -253,7 +253,7 @@ const workflows: Prompt[] = [{name: 'workflow:image-pixel:step2',action: 'workflow:image-pixel:step2',- model: 'gpt-4o-mini-2024-07-18',+ model: 'gpt-4.1-mini',messages: [{role: 'system',@@ -355,7 +355,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Generate a caption',action: 'Generate a caption',- model: 'gpt-4o-mini-2024-07-18',+ model: 'gpt-4.1-mini',messages: [{role: 'user',@@ -367,7 +367,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Summary',action: 'Summary',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -384,7 +384,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Summary as title',action: 'Summary as title',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -401,7 +401,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Summary the webpage',action: 'Summary the webpage',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'user',@@ -413,7 +413,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Explain this',action: 'Explain this',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -429,7 +429,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Explain this image',action: 'Explain this image',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -446,7 +446,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Explain this code',action: 'Explain this code',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -463,7 +463,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Translate to',action: 'Translate',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -508,7 +508,7 @@ Convert a multi-speaker audio recording into a structured JSON format by transcr{name: 'Write an article about this',action: 'Write an article about this',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -536,7 +536,7 @@ Rules to follow:{name: 'Write a twitter about this',action: 'Write a twitter about this',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -553,7 +553,7 @@ Rules to follow:{name: 'Write a poem about this',action: 'Write a poem about this',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -570,7 +570,7 @@ Rules to follow:{name: 'Write a blog post about this',action: 'Write a blog post about this',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -586,7 +586,7 @@ Rules to follow:{name: 'Write outline',action: 'Write outline',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -603,7 +603,7 @@ Rules to follow:{name: 'Change tone to',action: 'Change tone',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -702,7 +702,7 @@ Rules to follow:{name: 'Improve writing for it',action: 'Improve writing for it',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -718,7 +718,7 @@ Rules to follow:{name: 'Improve grammar for it',action: 'Improve grammar for it',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -734,7 +734,7 @@ Rules to follow:{name: 'Fix spelling for it',action: 'Fix spelling for it',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -750,7 +750,7 @@ Rules to follow:{name: 'Find action items from it',action: 'Find action items from it',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -774,7 +774,7 @@ If there are items in the content that can be used as to-do tasks, please refer{name: 'Check code error',action: 'Check code error',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -824,7 +824,7 @@ If there are items in the content that can be used as to-do tasks, please refer{name: 'Make it real',action: 'Make it real',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -865,7 +865,7 @@ When sent new wireframes, respond ONLY with the contents of the html file.`,{name: 'Make it real with text',action: 'Make it real with text',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -900,7 +900,7 @@ When sent new notes, respond ONLY with the contents of the html file.`,{name: 'Make it longer',action: 'Make it longer',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -928,7 +928,7 @@ Output: Generate a new version of the provided content that is longer in length{name: 'Make it shorter',action: 'Make it shorter',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -955,7 +955,7 @@ Finally, you should present the final, shortened content as your response. Make{name: 'Continue writing',action: 'Continue writing',- model: 'gpt-4o-2024-08-06',+ model: 'gpt-4.1-2025-04-14',messages: [{role: 'system',@@ -984,7 +984,7 @@ Finally, please only send us the content of your continuation in Markdown Formatconst chat: Prompt[] = [{name: 'debug:chat:gpt4',- model: 'gpt-4o',+ model: 'gpt-4.1',messages: [{role: 'system',@@ -995,7 +995,7 @@ const chat: Prompt[] = [},{name: 'Chat With AFFiNE AI',- model: 'gpt-4o',+ model: 'gpt-4.1',messages: [{role: 'system',diff --git a/packages/backend/server/src/plugins/copilot/providers/openai.ts b/packages/backend/server/src/plugins/copilot/providers/openai.tsindex 6fa0622f0f..8d6c5510dc 100644--- a/packages/backend/server/src/plugins/copilot/providers/openai.ts+++ b/packages/backend/server/src/plugins/copilot/providers/openai.ts@@ -62,6 +62,9 @@ export class OpenAIProvider'gpt-4o-2024-08-06','gpt-4o-mini','gpt-4o-mini-2024-07-18',+ 'gpt-4.1',+ 'gpt-4.1-2025-04-14',+ 'gpt-4.1-mini','o1','o3-mini',// embeddings@@ -176,7 +179,7 @@ export class OpenAIProvider// ====== text to text ======async generateText(messages: PromptMessage[],- model: string = 'gpt-4o-mini',+ model: string = 'gpt-4.1-mini',options: CopilotChatOptions = {}): Promise<string> {await this.checkParams({ messages, model, options });@@ -221,7 +224,7 @@ export class OpenAIProviderasync *generateTextStream(messages: PromptMessage[],- model: string = 'gpt-4o-mini',+ model: string = 'gpt-4.1-mini',options: CopilotChatOptions = {}): AsyncIterable<string> {await this.checkParams({ messages, model, options });diff --git a/packages/backend/server/src/plugins/copilot/types.ts b/packages/backend/server/src/plugins/copilot/types.tsindex fcde77d47a..2db4d0a42e 100644--- a/packages/backend/server/src/plugins/copilot/types.ts+++ b/packages/backend/server/src/plugins/copilot/types.ts@@ -11,6 +11,9 @@ export enum AvailableModels {Gpt4Omni0806 = 'gpt-4o-2024-08-06',Gpt4OmniMini = 'gpt-4o-mini',Gpt4OmniMini0718 = 'gpt-4o-mini-2024-07-18',+ Gpt41 = 'gpt-4.1',+ Gpt410414 = 'gpt-4.1-2025-04-14',+ Gpt41Mini = 'gpt-4.1-mini',// embeddingsTextEmbedding3Large = 'text-embedding-3-large',TextEmbedding3Small = 'text-embedding-3-small',diff --git a/packages/backend/server/src/schema.gql b/packages/backend/server/src/schema.gqlindex 1067e1dbe1..4be56d5aa0 100644--- a/packages/backend/server/src/schema.gql+++ b/packages/backend/server/src/schema.gql@@ -195,6 +195,9 @@ enum CopilotModels {Gpt4Omni0806Gpt4OmniMiniGpt4OmniMini0718+ Gpt41+ Gpt41Mini+ Gpt410414TextEmbedding3LargeTextEmbedding3SmallTextEmbeddingAda002diff --git a/packages/common/graphql/src/schema.ts b/packages/common/graphql/src/schema.tsindex 7ce4d43b21..6cdd2ec878 100644--- a/packages/common/graphql/src/schema.ts+++ b/packages/common/graphql/src/schema.ts@@ -279,6 +279,9 @@ export enum CopilotModels {Gpt4Omni0806 = 'Gpt4Omni0806',Gpt4OmniMini = 'Gpt4OmniMini',Gpt4OmniMini0718 = 'Gpt4OmniMini0718',+ Gpt41 = 'Gpt41',+ Gpt41Mini = 'Gpt41Mini',+ Gpt410414 = 'Gpt410414',TextEmbedding3Large = 'TextEmbedding3Large',TextEmbedding3Small = 'TextEmbedding3Small',TextEmbeddingAda002 = 'TextEmbeddingAda002',