Skip to content

Commit a2ce3f1

Browse files
Cadiackonstantintieber
authored andcommitted
feat(core): Add DeepSeek support to chat hub (no-changelog) (#22037)
1 parent 001503f commit a2ce3f1

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

packages/@n8n/api-types/src/chat-hub.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const chatHubLLMProviderSchema = z.enum([
1818
'azureOpenAi',
1919
'ollama',
2020
'awsBedrock',
21+
'deepSeek',
2122
'cohere',
2223
'mistralCloud',
2324
]);
@@ -44,6 +45,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record<
4445
ollama: 'ollamaApi',
4546
azureOpenAi: 'azureOpenAiApi',
4647
awsBedrock: 'aws',
48+
deepSeek: 'deepSeekApi',
4749
cohere: 'cohereApi',
4850
mistralCloud: 'mistralCloudApi',
4951
};
@@ -83,6 +85,11 @@ const awsBedrockModelSchema = z.object({
8385
model: z.string(),
8486
});
8587

88+
const deepSeekModelSchema = z.object({
89+
provider: z.literal('deepSeek'),
90+
model: z.string(),
91+
});
92+
8693
const cohereModelSchema = z.object({
8794
provider: z.literal('cohere'),
8895
model: z.string(),
@@ -110,6 +117,7 @@ export const chatHubConversationModelSchema = z.discriminatedUnion('provider', [
110117
azureOpenAIModelSchema,
111118
ollamaModelSchema,
112119
awsBedrockModelSchema,
120+
deepSeekModelSchema,
113121
cohereModelSchema,
114122
mistralCloudModelSchema,
115123
n8nModelSchema,
@@ -122,6 +130,7 @@ export type ChatHubGoogleModel = z.infer<typeof googleModelSchema>;
122130
export type ChatHubAzureOpenAIModel = z.infer<typeof azureOpenAIModelSchema>;
123131
export type ChatHubOllamaModel = z.infer<typeof ollamaModelSchema>;
124132
export type ChatHubAwsBedrockModel = z.infer<typeof awsBedrockModelSchema>;
133+
export type ChatHubDeepSeekModel = z.infer<typeof deepSeekModelSchema>;
125134
export type ChatHubCohereModel = z.infer<typeof cohereModelSchema>;
126135
export type ChatHubMistralCloudModel = z.infer<typeof mistralCloudModelSchema>;
127136
export type ChatHubBaseLLMModel =
@@ -131,6 +140,7 @@ export type ChatHubBaseLLMModel =
131140
| ChatHubAzureOpenAIModel
132141
| ChatHubOllamaModel
133142
| ChatHubAwsBedrockModel
143+
| ChatHubDeepSeekModel
134144
| ChatHubCohereModel
135145
| ChatHubMistralCloudModel;
136146

@@ -175,6 +185,7 @@ export const emptyChatModelsResponse: ChatModelsResponse = {
175185
azureOpenAi: { models: [] },
176186
ollama: { models: [] },
177187
awsBedrock: { models: [] },
188+
deepSeek: { models: [] },
178189
cohere: { models: [] },
179190
mistralCloud: { models: [] },
180191
n8n: { models: [] },

packages/cli/src/modules/chat-hub/chat-hub-workflow.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,15 @@ export class ChatHubWorkflowService {
512512
},
513513
};
514514
}
515+
case 'deepSeek': {
516+
return {
517+
...common,
518+
parameters: {
519+
model,
520+
options: {},
521+
},
522+
};
523+
}
515524
case 'cohere': {
516525
return {
517526
...common,

packages/cli/src/modules/chat-hub/chat-hub.constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export const PROVIDER_NODE_TYPE_MAP: Record<ChatHubLLMProvider, INodeTypeNameVer
3636
name: '@n8n/n8n-nodes-langchain.lmChatAwsBedrock',
3737
version: 1.1,
3838
},
39+
deepSeek: {
40+
name: '@n8n/n8n-nodes-langchain.lmChatDeepSeek',
41+
version: 1,
42+
},
3943
cohere: {
4044
name: '@n8n/n8n-nodes-langchain.lmChatCohere',
4145
version: 1,

packages/cli/src/modules/chat-hub/chat-hub.service.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ export class ChatHubService {
164164
return await this.fetchAzureOpenAiModels(credentials, additionalData);
165165
case 'awsBedrock':
166166
return await this.fetchAwsBedrockModels(credentials, additionalData);
167+
case 'deepSeek':
168+
return await this.fetchDeepSeekModels(credentials, additionalData);
167169
case 'cohere':
168170
return await this.fetchCohereModels(credentials, additionalData);
169171
case 'mistralCloud':
@@ -593,6 +595,62 @@ export class ChatHubService {
593595
};
594596
}
595597

598+
private async fetchDeepSeekModels(
599+
credentials: INodeCredentials,
600+
additionalData: IWorkflowExecuteAdditionalData,
601+
): Promise<ChatModelsResponse['deepSeek']> {
602+
const results = await this.nodeParametersService.getOptionsViaLoadOptions(
603+
{
604+
routing: {
605+
request: {
606+
method: 'GET',
607+
url: '/models',
608+
},
609+
output: {
610+
postReceive: [
611+
{
612+
type: 'rootProperty',
613+
properties: {
614+
property: 'data',
615+
},
616+
},
617+
{
618+
type: 'setKeyValue',
619+
properties: {
620+
name: '={{$responseItem.id}}',
621+
value: '={{$responseItem.id}}',
622+
},
623+
},
624+
{
625+
type: 'sort',
626+
properties: {
627+
key: 'name',
628+
},
629+
},
630+
],
631+
},
632+
},
633+
},
634+
additionalData,
635+
PROVIDER_NODE_TYPE_MAP.deepSeek,
636+
{},
637+
credentials,
638+
);
639+
640+
return {
641+
models: results.map((result) => ({
642+
name: result.name,
643+
description: result.description ?? String(result.value),
644+
model: {
645+
provider: 'deepSeek',
646+
model: String(result.value),
647+
},
648+
createdAt: null,
649+
updatedAt: null,
650+
})),
651+
};
652+
}
653+
596654
private async fetchAgentWorkflowsAsModels(user: User): Promise<ChatModelsResponse['n8n']> {
597655
const nodeTypes = [CHAT_TRIGGER_NODE_TYPE];
598656
const workflows = await this.workflowService.getWorkflowsWithNodesIncluded(

packages/cli/src/modules/chat-hub/context-limits.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export const maxContextWindowTokens: Record<ChatHubLLMProvider, Record<string, n
140140
azureOpenAi: {},
141141
ollama: {},
142142
awsBedrock: {},
143+
deepSeek: {},
143144
cohere: {},
144145
mistralCloud: {},
145146
};

packages/frontend/editor-ui/src/features/ai/chatHub/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const providerDisplayNames: Record<ChatHubProvider, string> = {
1414
azureOpenAi: 'Azure OpenAI',
1515
ollama: 'Ollama',
1616
awsBedrock: 'AWS Bedrock',
17+
deepSeek: 'DeepSeek',
1718
cohere: 'Cohere',
1819
mistralCloud: 'Mistral Cloud',
1920
n8n: 'n8n',

0 commit comments

Comments
 (0)