fix(editor): Disable fromAI button for vector stores (#13125)

This commit is contained in:
Charlie Kolb 2025-02-10 09:51:18 +01:00 committed by GitHub
parent 814e2a8924
commit bde84205f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -54,6 +54,17 @@ const AI_DENYLIST_NODE_TYPE: INodeTypeDescription = {
...MOCK_NODE_TYPE_MIXIN,
};
const AI_VECTOR_STORE_NODE_TYPE: INodeTypeDescription = {
name: 'aVectorStore',
codex: {
categories: ['AI'],
subcategories: {
AI: ['Tools', 'Vector Stores'],
},
},
...MOCK_NODE_TYPE_MIXIN,
};
const NON_AI_NODE_TYPE: INodeTypeDescription = {
name: 'AN_NOT_AI_NODE_TYPE',
...MOCK_NODE_TYPE_MIXIN,
@ -64,6 +75,8 @@ describe('makeOverrideValue', () => {
['null nodeType', makeContext(''), null],
['non-ai node type', makeContext(''), NON_AI_NODE_TYPE],
['ai node type on denylist', makeContext(''), AI_DENYLIST_NODE_TYPE],
['vector store type', makeContext(''), AI_VECTOR_STORE_NODE_TYPE],
['denied parameter name', makeContext('', 'parameters.toolName'), AI_NODE_TYPE],
])('should not create an override for %s', (_name, context, nodeType) => {
expect(makeOverrideValue(context, nodeType)).toBeNull();
});

View file

@ -48,6 +48,8 @@ const NODE_DENYLIST = ['toolCode', 'toolHttpRequest'];
const PATH_DENYLIST = [
'parameters.name',
// this is used in vector store tools
'parameters.toolName',
'parameters.description',
// This is used in e.g. the telegram node if the dropdown selects manual mode
'parameters.toolDescription',
@ -164,7 +166,11 @@ export function canBeContentOverride(
if (PATH_DENYLIST.includes(props.path)) return false;
const codex = nodeType?.codex;
if (!codex?.categories?.includes('AI') || !codex?.subcategories?.AI?.includes('Tools'))
if (
!codex?.categories?.includes('AI') ||
!codex?.subcategories?.AI?.includes('Tools') ||
codex?.subcategories?.AI?.includes('Vector Stores') // vector stores do not support fromAI
)
return false;
return !props.parameter.noDataExpression && 'options' !== props.parameter.type;