feat(core): Add separate Azure API key and Entra ID providers (no-changelog)

This commit is contained in:
Jaakko Husso 2025-11-20 16:55:39 +02:00
parent 2681c7033e
commit b6124c2712
No known key found for this signature in database
7 changed files with 27 additions and 8 deletions

View File

@ -16,6 +16,7 @@ export const chatHubLLMProviderSchema = z.enum([
'anthropic',
'google',
'azureOpenAi',
'azureEntraId',
'ollama',
'awsBedrock',
'mistralCloud',
@ -42,6 +43,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record<
google: 'googlePalmApi',
ollama: 'ollamaApi',
azureOpenAi: 'azureOpenAiApi',
azureEntraId: 'azureEntraCognitiveServicesOAuth2Api',
awsBedrock: 'aws',
mistralCloud: 'mistralCloudApi',
};
@ -71,6 +73,11 @@ const azureOpenAIModelSchema = z.object({
model: z.string(),
});
const azureEntraIdModelSchema = z.object({
provider: z.literal('azureEntraId'),
model: z.string(),
});
const ollamaModelSchema = z.object({
provider: z.literal('ollama'),
model: z.string(),
@ -101,6 +108,7 @@ export const chatHubConversationModelSchema = z.discriminatedUnion('provider', [
anthropicModelSchema,
googleModelSchema,
azureOpenAIModelSchema,
azureEntraIdModelSchema,
ollamaModelSchema,
awsBedrockModelSchema,
mistralCloudModelSchema,
@ -112,6 +120,7 @@ export type ChatHubOpenAIModel = z.infer<typeof openAIModelSchema>;
export type ChatHubAnthropicModel = z.infer<typeof anthropicModelSchema>;
export type ChatHubGoogleModel = z.infer<typeof googleModelSchema>;
export type ChatHubAzureOpenAIModel = z.infer<typeof azureOpenAIModelSchema>;
export type ChatHubAzureEntraIdModel = z.infer<typeof azureEntraIdModelSchema>;
export type ChatHubOllamaModel = z.infer<typeof ollamaModelSchema>;
export type ChatHubAwsBedrockModel = z.infer<typeof awsBedrockModelSchema>;
export type ChatHubMistralCloudModel = z.infer<typeof mistralCloudModelSchema>;
@ -120,6 +129,7 @@ export type ChatHubBaseLLMModel =
| ChatHubAnthropicModel
| ChatHubGoogleModel
| ChatHubAzureOpenAIModel
| ChatHubAzureEntraIdModel
| ChatHubOllamaModel
| ChatHubAwsBedrockModel
| ChatHubMistralCloudModel;
@ -163,6 +173,7 @@ export const emptyChatModelsResponse: ChatModelsResponse = {
anthropic: { models: [] },
google: { models: [] },
azureOpenAi: { models: [] },
azureEntraId: { models: [] },
ollama: { models: [] },
awsBedrock: { models: [] },
mistralCloud: { models: [] },

View File

@ -485,6 +485,7 @@ export class ChatHubWorkflowService {
},
};
case 'azureOpenAi':
case 'azureEntraId':
return {
...common,
parameters: {

View File

@ -14,7 +14,7 @@ Requirements:
export const PROVIDER_NODE_TYPE_MAP: Record<ChatHubLLMProvider, INodeTypeNameVersion> = {
openai: {
name: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
version: 1.2,
version: 1.3,
},
anthropic: {
name: '@n8n/n8n-nodes-langchain.lmChatAnthropic',
@ -32,6 +32,10 @@ export const PROVIDER_NODE_TYPE_MAP: Record<ChatHubLLMProvider, INodeTypeNameVer
name: '@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',
version: 1,
},
azureEntraId: {
name: '@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',
version: 1,
},
awsBedrock: {
name: '@n8n/n8n-nodes-langchain.lmChatAwsBedrock',
version: 1.1,

View File

@ -44,6 +44,7 @@ import { ChatHubAgentService } from './chat-hub-agent.service';
import { ChatHubCredentialsService, CredentialWithProjectId } from './chat-hub-credentials.service';
import type { ChatHubMessage } from './chat-hub-message.entity';
import { ChatHubWorkflowService } from './chat-hub-workflow.service';
import { ChatHubAttachmentService } from './chat-hub.attachment.service';
import { JSONL_STREAM_HEADERS, NODE_NAMES, PROVIDER_NODE_TYPE_MAP } from './chat-hub.constants';
import {
HumanMessagePayload,
@ -65,7 +66,6 @@ import { getBase } from '@/workflow-execute-additional-data';
import { WorkflowExecutionService } from '@/workflows/workflow-execution.service';
import { WorkflowFinderService } from '@/workflows/workflow-finder.service';
import { WorkflowService } from '@/workflows/workflow.service';
import { ChatHubAttachmentService } from './chat-hub.attachment.service';
@Service()
export class ChatHubService {
@ -161,7 +161,8 @@ export class ChatHubService {
case 'ollama':
return await this.fetchOllamaModels(credentials, additionalData);
case 'azureOpenAi':
return await this.fetchAzureOpenAiModels(credentials, additionalData);
case 'azureEntraId':
return this.fetchAzureOpenAiModels(credentials, additionalData);
case 'awsBedrock':
return await this.fetchAwsBedrockModels(credentials, additionalData);
case 'mistralCloud':
@ -354,10 +355,10 @@ export class ChatHubService {
};
}
private async fetchAzureOpenAiModels(
private fetchAzureOpenAiModels(
_credentials: INodeCredentials,
_additionalData: IWorkflowExecuteAdditionalData,
): Promise<ChatModelsResponse['azureOpenAi']> {
): ChatModelsResponse['azureOpenAi'] {
// Azure doesn't appear to offer a way to list available models via API.
// If we add support for this in the future on the Azure OpenAI node we should copy that
// implementation here too.

View File

@ -2,10 +2,10 @@ import { withTransaction } from '@n8n/db';
import { Service } from '@n8n/di';
import { DataSource, EntityManager, Repository } from '@n8n/typeorm';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { ChatHubSession } from './chat-hub-session.entity';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
@Service()
export class ChatHubSessionRepository extends Repository<ChatHubSession> {
constructor(dataSource: DataSource) {

View File

@ -138,6 +138,7 @@ export const maxContextWindowTokens: Record<ChatHubLLMProvider, Record<string, n
'models/learnlm-2.0-flash-experimental': 0,
},
azureOpenAi: {},
azureEntraId: {},
ollama: {},
awsBedrock: {},
mistralCloud: {},

View File

@ -11,7 +11,8 @@ export const providerDisplayNames: Record<ChatHubProvider, string> = {
openai: 'OpenAI',
anthropic: 'Anthropic',
google: 'Google',
azureOpenAi: 'Azure OpenAI',
azureOpenAi: 'Azure (API Key)',
azureEntraId: 'Azure (Entra ID)',
ollama: 'Ollama',
awsBedrock: 'AWS Bedrock',
mistralCloud: 'Mistral Cloud',