feat(core): Add Groq provider support for chat hub (no-changelog) (#22071)

This commit is contained in:
Jaakko Husso 2025-11-21 12:34:56 +02:00 committed by GitHub
parent e4605c37fb
commit 731024c941
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 84 additions and 0 deletions

View File

@ -18,6 +18,7 @@ export const chatHubLLMProviderSchema = z.enum([
'azureOpenAi',
'ollama',
'awsBedrock',
'groq',
'openRouter',
'deepSeek',
'cohere',
@ -46,6 +47,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record<
ollama: 'ollamaApi',
azureOpenAi: 'azureOpenAiApi',
awsBedrock: 'aws',
groq: 'groqApi',
openRouter: 'openRouterApi',
deepSeek: 'deepSeekApi',
cohere: 'cohereApi',
@ -87,6 +89,11 @@ const awsBedrockModelSchema = z.object({
model: z.string(),
});
const groqModelSchema = z.object({
provider: z.literal('groq'),
model: z.string(),
});
const openRouterModelSchema = z.object({
provider: z.literal('openRouter'),
model: z.string(),
@ -124,6 +131,7 @@ export const chatHubConversationModelSchema = z.discriminatedUnion('provider', [
azureOpenAIModelSchema,
ollamaModelSchema,
awsBedrockModelSchema,
groqModelSchema,
openRouterModelSchema,
deepSeekModelSchema,
cohereModelSchema,
@ -138,6 +146,7 @@ export type ChatHubGoogleModel = z.infer<typeof googleModelSchema>;
export type ChatHubAzureOpenAIModel = z.infer<typeof azureOpenAIModelSchema>;
export type ChatHubOllamaModel = z.infer<typeof ollamaModelSchema>;
export type ChatHubAwsBedrockModel = z.infer<typeof awsBedrockModelSchema>;
export type ChatHubGroqModel = z.infer<typeof groqModelSchema>;
export type ChatHubOpenRouterModel = z.infer<typeof openRouterModelSchema>;
export type ChatHubDeepSeekModel = z.infer<typeof deepSeekModelSchema>;
export type ChatHubCohereModel = z.infer<typeof cohereModelSchema>;
@ -149,6 +158,7 @@ export type ChatHubBaseLLMModel =
| ChatHubAzureOpenAIModel
| ChatHubOllamaModel
| ChatHubAwsBedrockModel
| ChatHubGroqModel
| ChatHubOpenRouterModel
| ChatHubDeepSeekModel
| ChatHubCohereModel
@ -195,6 +205,7 @@ export const emptyChatModelsResponse: ChatModelsResponse = {
azureOpenAi: { models: [] },
ollama: { models: [] },
awsBedrock: { models: [] },
groq: { models: [] },
openRouter: { models: [] },
deepSeek: { models: [] },
cohere: { models: [] },

View File

@ -512,6 +512,15 @@ export class ChatHubWorkflowService {
},
};
}
case 'groq': {
return {
...common,
parameters: {
model,
options: {},
},
};
}
case 'openRouter': {
return {
...common,

View File

@ -36,6 +36,10 @@ export const PROVIDER_NODE_TYPE_MAP: Record<ChatHubLLMProvider, INodeTypeNameVer
name: '@n8n/n8n-nodes-langchain.lmChatAwsBedrock',
version: 1.1,
},
groq: {
name: '@n8n/n8n-nodes-langchain.lmChatGroq',
version: 1,
},
openRouter: {
name: '@n8n/n8n-nodes-langchain.lmChatOpenRouter',
version: 1,

View File

@ -164,6 +164,8 @@ export class ChatHubService {
return await this.fetchAzureOpenAiModels(credentials, additionalData);
case 'awsBedrock':
return await this.fetchAwsBedrockModels(credentials, additionalData);
case 'groq':
return await this.fetchGroqModels(credentials, additionalData);
case 'openRouter':
return await this.fetchOpenRouterModels(credentials, additionalData);
case 'deepSeek':
@ -709,6 +711,62 @@ export class ChatHubService {
};
}
private async fetchGroqModels(
credentials: INodeCredentials,
additionalData: IWorkflowExecuteAdditionalData,
): Promise<ChatModelsResponse['groq']> {
const results = await this.nodeParametersService.getOptionsViaLoadOptions(
{
routing: {
request: {
method: 'GET',
url: '/models',
},
output: {
postReceive: [
{
type: 'rootProperty',
properties: {
property: 'data',
},
},
{
type: 'filter',
properties: {
pass: '={{ $responseItem.active === true && $responseItem.object === "model" }}',
},
},
{
type: 'setKeyValue',
properties: {
name: '={{$responseItem.id}}',
value: '={{$responseItem.id}}',
},
},
],
},
},
},
additionalData,
PROVIDER_NODE_TYPE_MAP.groq,
{},
credentials,
);
return {
models: results.map((result) => ({
name: result.name,
description: result.description ?? null,
model: {
provider: 'groq',
model: String(result.value),
},
createdAt: null,
updatedAt: null,
})),
};
}
private async fetchAgentWorkflowsAsModels(user: User): Promise<ChatModelsResponse['n8n']> {
const nodeTypes = [CHAT_TRIGGER_NODE_TYPE];
const workflows = await this.workflowService.getWorkflowsWithNodesIncluded(

View File

@ -140,6 +140,7 @@ export const maxContextWindowTokens: Record<ChatHubLLMProvider, Record<string, n
azureOpenAi: {},
ollama: {},
awsBedrock: {},
groq: {},
openRouter: {},
deepSeek: {},
cohere: {},

View File

@ -14,6 +14,7 @@ export const providerDisplayNames: Record<ChatHubProvider, string> = {
azureOpenAi: 'Azure OpenAI',
ollama: 'Ollama',
awsBedrock: 'AWS Bedrock',
groq: 'Groq',
openRouter: 'OpenRouter',
deepSeek: 'DeepSeek',
cohere: 'Cohere',