Skip to content

Commit

Permalink
fix(editor): Disable fromAI button for vector stores (#13125)
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieKolb authored Feb 10, 2025
1 parent 814e2a8 commit bde8420
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/editor-ui/src/utils/fromAIOverrideUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
});
Expand Down
8 changes: 7 additions & 1 deletion packages/editor-ui/src/utils/fromAIOverrideUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bde8420

Please # to comment.