-
Notifications
You must be signed in to change notification settings - Fork 31.1k
feat: Add model selector node #16371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: Add model selector node #16371
Conversation
…of subnodes" This reverts commit 690cc18.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cubic found 5 issues across 14 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai
to give specific feedback.
packages/@n8n/nodes-langchain/nodes/ModelSelector/test/ModelSelector.node.test.ts
Show resolved
Hide resolved
packages/@n8n/nodes-langchain/nodes/ModelSelector/ModelSelector.node.ts
Outdated
Show resolved
Hide resolved
packages/core/src/execution-engine/node-execution-context/node-execution-context.ts
Show resolved
Hide resolved
packages/core/src/execution-engine/node-execution-context/utils/get-input-connection-data.ts
Outdated
Show resolved
Hide resolved
...rc/execution-engine/node-execution-context/utils/__tests__/get-input-connection-data.test.ts
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
models.reverse(); | ||
|
||
const rules = this.getNodeParameter('rules.rule', itemIndex, []) as any[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we improve the type here? Something like:
{
modelIndex: number;
conditions: {
options: {
caseSensitive: boolean;
leftValue: string;
typeValidation: string;
version: number;
};
conditions: Array<{
id: string;
leftValue: string;
rightValue: string;
operator: {
type: string;
operation: string;
name: string;
};
}>;
combinator: string;
};
}
const rule = rules[i] as { | ||
modelIndex: string; | ||
}; | ||
const modelIndex = parseInt(rule.modelIndex, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does modelIndex
really come as a string? On my instance I see it as number, so we might not even need to parseInt it.
Summary
Adds a new node that selects one of the connected language models depending on customizable conditions.
To make that possible some adjustments needed to be made in the core:
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/AI-982/choosing-model-based-on-expression-having-a-fallback-model-when-a
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)