From 37e4f4fc29b4d04357ee3895a76e8ed6a2172d6a Mon Sep 17 00:00:00 2001 From: Jaakko Husso Date: Thu, 20 Nov 2025 09:55:38 +0200 Subject: [PATCH] feat(core): Add Mistral cloud provider to chat hub (no-changelog) --- packages/@n8n/api-types/src/chat-hub.ts | 13 +++- .../chat-hub/chat-hub-workflow.service.ts | 9 +++ .../modules/chat-hub/chat-hub.constants.ts | 4 ++ .../src/modules/chat-hub/chat-hub.service.ts | 64 +++++++++++++++++++ .../src/modules/chat-hub/context-limits.ts | 1 + .../src/features/ai/chatHub/constants.ts | 1 + 6 files changed, 91 insertions(+), 1 deletion(-) diff --git a/packages/@n8n/api-types/src/chat-hub.ts b/packages/@n8n/api-types/src/chat-hub.ts index 85eae52f0657d..5a15e87fa1e9e 100644 --- a/packages/@n8n/api-types/src/chat-hub.ts +++ b/packages/@n8n/api-types/src/chat-hub.ts @@ -18,6 +18,7 @@ export const chatHubLLMProviderSchema = z.enum([ 'azureOpenAi', 'ollama', 'awsBedrock', + 'mistralCloud', ]); export type ChatHubLLMProvider = z.infer; @@ -42,6 +43,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record< ollama: 'ollamaApi', azureOpenAi: 'azureOpenAiApi', awsBedrock: 'aws', + mistralCloud: 'mistralCloudApi', }; export type ChatHubAgentTool = typeof JINA_AI_TOOL_NODE_TYPE | typeof SEAR_XNG_TOOL_NODE_TYPE; @@ -79,6 +81,11 @@ const awsBedrockModelSchema = z.object({ model: z.string(), }); +const mistralCloudModelSchema = z.object({ + provider: z.literal('mistralCloud'), + model: z.string(), +}); + const n8nModelSchema = z.object({ provider: z.literal('n8n'), workflowId: z.string(), @@ -96,6 +103,7 @@ export const chatHubConversationModelSchema = z.discriminatedUnion('provider', [ azureOpenAIModelSchema, ollamaModelSchema, awsBedrockModelSchema, + mistralCloudModelSchema, n8nModelSchema, chatAgentSchema, ]); @@ -106,13 +114,15 @@ export type ChatHubGoogleModel = z.infer; export type ChatHubAzureOpenAIModel = z.infer; export type ChatHubOllamaModel = z.infer; export type ChatHubAwsBedrockModel = z.infer; +export type ChatHubMistralCloudModel = z.infer; export type ChatHubBaseLLMModel = | ChatHubOpenAIModel | ChatHubAnthropicModel | ChatHubGoogleModel | ChatHubAzureOpenAIModel | ChatHubOllamaModel - | ChatHubAwsBedrockModel; + | ChatHubAwsBedrockModel + | ChatHubMistralCloudModel; export type ChatHubN8nModel = z.infer; export type ChatHubCustomAgentModel = z.infer; @@ -154,6 +164,7 @@ export const emptyChatModelsResponse: ChatModelsResponse = { azureOpenAi: { models: [] }, ollama: { models: [] }, awsBedrock: { models: [] }, + mistralCloud: { models: [] }, n8n: { models: [] }, // eslint-disable-next-line @typescript-eslint/naming-convention 'custom-agent': { models: [] }, diff --git a/packages/cli/src/modules/chat-hub/chat-hub-workflow.service.ts b/packages/cli/src/modules/chat-hub/chat-hub-workflow.service.ts index feffc3b60a8c5..8547e90d3f1b9 100644 --- a/packages/cli/src/modules/chat-hub/chat-hub-workflow.service.ts +++ b/packages/cli/src/modules/chat-hub/chat-hub-workflow.service.ts @@ -474,6 +474,15 @@ export class ChatHubWorkflowService { }, }; } + case 'mistralCloud': { + return { + ...common, + parameters: { + model, + options: {}, + }, + }; + } default: throw new OperationalError('Unsupported model provider'); } diff --git a/packages/cli/src/modules/chat-hub/chat-hub.constants.ts b/packages/cli/src/modules/chat-hub/chat-hub.constants.ts index 33d02af661181..1d850fb6a71b0 100644 --- a/packages/cli/src/modules/chat-hub/chat-hub.constants.ts +++ b/packages/cli/src/modules/chat-hub/chat-hub.constants.ts @@ -36,6 +36,10 @@ export const PROVIDER_NODE_TYPE_MAP: Record { + const results = await this.nodeParametersService.getOptionsViaLoadOptions( + { + routing: { + request: { + method: 'GET', + url: '/models', + }, + output: { + postReceive: [ + { + type: 'rootProperty', + properties: { + property: 'data', + }, + }, + { + type: 'filter', + properties: { + pass: "={{ !$responseItem.id.includes('embed') }}", + }, + }, + { + type: 'setKeyValue', + properties: { + name: '={{ $responseItem.id }}', + value: '={{ $responseItem.id }}', + }, + }, + { + type: 'sort', + properties: { + key: 'name', + }, + }, + ], + }, + }, + }, + additionalData, + PROVIDER_NODE_TYPE_MAP.mistralCloud, + {}, + credentials, + ); + + return { + models: results.map((result) => ({ + name: result.name, + description: result.description ?? String(result.value), + model: { + provider: 'mistralCloud', + model: String(result.value), + }, + createdAt: null, + updatedAt: null, + })), + }; + } + private async fetchAgentWorkflowsAsModels(user: User): Promise { const nodeTypes = [CHAT_TRIGGER_NODE_TYPE]; const workflows = await this.workflowService.getWorkflowsWithNodesIncluded( diff --git a/packages/cli/src/modules/chat-hub/context-limits.ts b/packages/cli/src/modules/chat-hub/context-limits.ts index 99b82c46bfa92..272c08f438186 100644 --- a/packages/cli/src/modules/chat-hub/context-limits.ts +++ b/packages/cli/src/modules/chat-hub/context-limits.ts @@ -140,6 +140,7 @@ export const maxContextWindowTokens: Record = { azureOpenAi: 'Azure OpenAI', ollama: 'Ollama', awsBedrock: 'AWS Bedrock', + mistralCloud: 'Mistral Cloud', n8n: 'n8n', 'custom-agent': 'Custom Agent', };