mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-03 18:27:09 +02:00
feat(core): Add Mistral cloud provider to chat hub (no-changelog) (#22067)
This commit is contained in:
parent
5c58bf919f
commit
11e898eafe
|
|
@ -18,6 +18,7 @@ export const chatHubLLMProviderSchema = z.enum([
|
|||
'azureOpenAi',
|
||||
'ollama',
|
||||
'awsBedrock',
|
||||
'mistralCloud',
|
||||
]);
|
||||
export type ChatHubLLMProvider = z.infer<typeof chatHubLLMProviderSchema>;
|
||||
|
||||
|
|
@ -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<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 ChatHubMistralCloudModel = z.infer<typeof mistralCloudModelSchema>;
|
||||
export type ChatHubBaseLLMModel =
|
||||
| ChatHubOpenAIModel
|
||||
| ChatHubAnthropicModel
|
||||
| ChatHubGoogleModel
|
||||
| ChatHubAzureOpenAIModel
|
||||
| ChatHubOllamaModel
|
||||
| ChatHubAwsBedrockModel;
|
||||
| ChatHubAwsBedrockModel
|
||||
| ChatHubMistralCloudModel;
|
||||
|
||||
export type ChatHubN8nModel = z.infer<typeof n8nModelSchema>;
|
||||
export type ChatHubCustomAgentModel = z.infer<typeof chatAgentSchema>;
|
||||
|
|
@ -155,6 +165,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: [] },
|
||||
|
|
|
|||
|
|
@ -510,6 +510,15 @@ export class ChatHubWorkflowService {
|
|||
},
|
||||
};
|
||||
}
|
||||
case 'mistralCloud': {
|
||||
return {
|
||||
...common,
|
||||
parameters: {
|
||||
model,
|
||||
options: {},
|
||||
},
|
||||
};
|
||||
}
|
||||
default:
|
||||
throw new OperationalError('Unsupported model provider');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ export const PROVIDER_NODE_TYPE_MAP: Record<ChatHubLLMProvider, INodeTypeNameVer
|
|||
name: '@n8n/n8n-nodes-langchain.lmChatAwsBedrock',
|
||||
version: 1.1,
|
||||
},
|
||||
mistralCloud: {
|
||||
name: '@n8n/n8n-nodes-langchain.lmChatMistralCloud',
|
||||
version: 1,
|
||||
},
|
||||
};
|
||||
|
||||
export const NODE_NAMES = {
|
||||
|
|
|
|||
|
|
@ -164,6 +164,8 @@ export class ChatHubService {
|
|||
return await this.fetchAzureOpenAiModels(credentials, additionalData);
|
||||
case 'awsBedrock':
|
||||
return await this.fetchAwsBedrockModels(credentials, additionalData);
|
||||
case 'mistralCloud':
|
||||
return await this.fetchMistralCloudModels(credentials, additionalData);
|
||||
case 'n8n':
|
||||
return await this.fetchAgentWorkflowsAsModels(user);
|
||||
case 'custom-agent':
|
||||
|
|
@ -470,6 +472,68 @@ export class ChatHubService {
|
|||
};
|
||||
}
|
||||
|
||||
private async fetchMistralCloudModels(
|
||||
credentials: INodeCredentials,
|
||||
additionalData: IWorkflowExecuteAdditionalData,
|
||||
): Promise<ChatModelsResponse['mistralCloud']> {
|
||||
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<ChatModelsResponse['n8n']> {
|
||||
const nodeTypes = [CHAT_TRIGGER_NODE_TYPE];
|
||||
const workflows = await this.workflowService.getWorkflowsWithNodesIncluded(
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ export const maxContextWindowTokens: Record<ChatHubLLMProvider, Record<string, n
|
|||
azureOpenAi: {},
|
||||
ollama: {},
|
||||
awsBedrock: {},
|
||||
mistralCloud: {},
|
||||
};
|
||||
|
||||
export const getMaxContextWindowTokens = (
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export const providerDisplayNames: Record<ChatHubProvider, string> = {
|
|||
azureOpenAi: 'Azure OpenAI',
|
||||
ollama: 'Ollama',
|
||||
awsBedrock: 'AWS Bedrock',
|
||||
mistralCloud: 'Mistral Cloud',
|
||||
n8n: 'n8n',
|
||||
'custom-agent': 'Custom Agent',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user