Skip to content

Commit dec979f

Browse files
committed
feat(core): Add DeepSeek models to chat hub (no-changelog)
1 parent 06900a7 commit dec979f

File tree

6 files changed

+85
-1
lines changed

6 files changed

+85
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
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
]);
2223
export type ChatHubLLMProvider = z.infer<typeof chatHubLLMProviderSchema>;
2324

@@ -42,6 +43,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record<
4243
ollama: 'ollamaApi',
4344
azureOpenAi: 'azureOpenAiApi',
4445
awsBedrock: 'aws',
46+
deepSeek: 'deepSeekApi',
4547
};
4648

4749
export type ChatHubAgentTool = typeof JINA_AI_TOOL_NODE_TYPE | typeof SEAR_XNG_TOOL_NODE_TYPE;
@@ -79,6 +81,11 @@ const awsBedrockModelSchema = z.object({
7981
model: z.string(),
8082
});
8183

84+
const deepSeekModelSchema = z.object({
85+
provider: z.literal('deepSeek'),
86+
model: z.string(),
87+
});
88+
8289
const n8nModelSchema = z.object({
8390
provider: z.literal('n8n'),
8491
workflowId: z.string(),
@@ -96,6 +103,7 @@ export const chatHubConversationModelSchema = z.discriminatedUnion('provider', [
96103
azureOpenAIModelSchema,
97104
ollamaModelSchema,
98105
awsBedrockModelSchema,
106+
deepSeekModelSchema,
99107
n8nModelSchema,
100108
chatAgentSchema,
101109
]);
@@ -106,13 +114,15 @@ export type ChatHubGoogleModel = z.infer<typeof googleModelSchema>;
106114
export type ChatHubAzureOpenAIModel = z.infer<typeof azureOpenAIModelSchema>;
107115
export type ChatHubOllamaModel = z.infer<typeof ollamaModelSchema>;
108116
export type ChatHubAwsBedrockModel = z.infer<typeof awsBedrockModelSchema>;
117+
export type ChatHubDeepSeekModel = z.infer<typeof deepSeekModelSchema>;
109118
export type ChatHubBaseLLMModel =
110119
| ChatHubOpenAIModel
111120
| ChatHubAnthropicModel
112121
| ChatHubGoogleModel
113122
| ChatHubAzureOpenAIModel
114123
| ChatHubOllamaModel
115-
| ChatHubAwsBedrockModel;
124+
| ChatHubAwsBedrockModel
125+
| ChatHubDeepSeekModel;
116126

117127
export type ChatHubN8nModel = z.infer<typeof n8nModelSchema>;
118128
export type ChatHubCustomAgentModel = z.infer<typeof chatAgentSchema>;
@@ -154,6 +164,7 @@ export const emptyChatModelsResponse: ChatModelsResponse = {
154164
azureOpenAi: { models: [] },
155165
ollama: { models: [] },
156166
awsBedrock: { models: [] },
167+
deepSeek: { models: [] },
157168
n8n: { models: [] },
158169
// eslint-disable-next-line @typescript-eslint/naming-convention
159170
'custom-agent': { 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
@@ -474,6 +474,15 @@ export class ChatHubWorkflowService {
474474
},
475475
};
476476
}
477+
case 'deepSeek': {
478+
return {
479+
...common,
480+
parameters: {
481+
model,
482+
options: {},
483+
},
484+
};
485+
}
477486
default:
478487
throw new OperationalError('Unsupported model provider');
479488
}

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
};
4044

4145
export const NODE_NAMES = {

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ export class ChatHubService {
161161
return await this.fetchAzureOpenAiModels(credentials, additionalData);
162162
case 'awsBedrock':
163163
return await this.fetchAwsBedrockModels(credentials, additionalData);
164+
case 'deepSeek':
165+
return await this.fetchDeepSeekModels(credentials, additionalData);
164166
case 'n8n':
165167
return await this.fetchAgentWorkflowsAsModels(user);
166168
case 'custom-agent':
@@ -462,6 +464,62 @@ export class ChatHubService {
462464
};
463465
}
464466

467+
private async fetchDeepSeekModels(
468+
credentials: INodeCredentials,
469+
additionalData: IWorkflowExecuteAdditionalData,
470+
): Promise<ChatModelsResponse['deepSeek']> {
471+
const results = await this.nodeParametersService.getOptionsViaLoadOptions(
472+
{
473+
routing: {
474+
request: {
475+
method: 'GET',
476+
url: '/models',
477+
},
478+
output: {
479+
postReceive: [
480+
{
481+
type: 'rootProperty',
482+
properties: {
483+
property: 'data',
484+
},
485+
},
486+
{
487+
type: 'setKeyValue',
488+
properties: {
489+
name: '={{$responseItem.id}}',
490+
value: '={{$responseItem.id}}',
491+
},
492+
},
493+
{
494+
type: 'sort',
495+
properties: {
496+
key: 'name',
497+
},
498+
},
499+
],
500+
},
501+
},
502+
},
503+
additionalData,
504+
PROVIDER_NODE_TYPE_MAP.deepSeek,
505+
{},
506+
credentials,
507+
);
508+
509+
return {
510+
models: results.map((result) => ({
511+
name: result.name,
512+
description: result.description ?? String(result.value),
513+
model: {
514+
provider: 'deepSeek',
515+
model: String(result.value),
516+
},
517+
createdAt: null,
518+
updatedAt: null,
519+
})),
520+
};
521+
}
522+
465523
private async fetchAgentWorkflowsAsModels(user: User): Promise<ChatModelsResponse['n8n']> {
466524
const nodeTypes = [CHAT_TRIGGER_NODE_TYPE];
467525
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
};
144145

145146
export const getMaxContextWindowTokens = (

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
n8n: 'n8n',
1819
'custom-agent': 'Custom Agent',
1920
};

0 commit comments

Comments
 (0)