mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +00:00
feat(editor): Easy $fromAI Button for AI Tools (#12587)
This commit is contained in:
@@ -107,7 +107,7 @@ describe('LoadNodesAndCredentials', () => {
|
||||
};
|
||||
fullNodeWrapper.description.properties = [existingProp];
|
||||
const result = instance.convertNodeToAiTool(fullNodeWrapper);
|
||||
expect(result.description.properties).toHaveLength(3); // Existing prop + toolDescription + notice
|
||||
expect(result.description.properties).toHaveLength(2); // Existing prop + toolDescription
|
||||
expect(result.description.properties).toContainEqual(existingProp);
|
||||
});
|
||||
|
||||
@@ -121,9 +121,9 @@ describe('LoadNodesAndCredentials', () => {
|
||||
};
|
||||
fullNodeWrapper.description.properties = [resourceProp];
|
||||
const result = instance.convertNodeToAiTool(fullNodeWrapper);
|
||||
expect(result.description.properties[1].name).toBe('descriptionType');
|
||||
expect(result.description.properties[2].name).toBe('toolDescription');
|
||||
expect(result.description.properties[3]).toEqual(resourceProp);
|
||||
expect(result.description.properties[0].name).toBe('descriptionType');
|
||||
expect(result.description.properties[1].name).toBe('toolDescription');
|
||||
expect(result.description.properties[2]).toEqual(resourceProp);
|
||||
});
|
||||
|
||||
it('should handle nodes with operation property', () => {
|
||||
@@ -136,9 +136,9 @@ describe('LoadNodesAndCredentials', () => {
|
||||
};
|
||||
fullNodeWrapper.description.properties = [operationProp];
|
||||
const result = instance.convertNodeToAiTool(fullNodeWrapper);
|
||||
expect(result.description.properties[1].name).toBe('descriptionType');
|
||||
expect(result.description.properties[2].name).toBe('toolDescription');
|
||||
expect(result.description.properties[3]).toEqual(operationProp);
|
||||
expect(result.description.properties[0].name).toBe('descriptionType');
|
||||
expect(result.description.properties[1].name).toBe('toolDescription');
|
||||
expect(result.description.properties[2]).toEqual(operationProp);
|
||||
});
|
||||
|
||||
it('should handle nodes with both resource and operation properties', () => {
|
||||
@@ -158,17 +158,17 @@ describe('LoadNodesAndCredentials', () => {
|
||||
};
|
||||
fullNodeWrapper.description.properties = [resourceProp, operationProp];
|
||||
const result = instance.convertNodeToAiTool(fullNodeWrapper);
|
||||
expect(result.description.properties[1].name).toBe('descriptionType');
|
||||
expect(result.description.properties[2].name).toBe('toolDescription');
|
||||
expect(result.description.properties[3]).toEqual(resourceProp);
|
||||
expect(result.description.properties[4]).toEqual(operationProp);
|
||||
expect(result.description.properties[0].name).toBe('descriptionType');
|
||||
expect(result.description.properties[1].name).toBe('toolDescription');
|
||||
expect(result.description.properties[2]).toEqual(resourceProp);
|
||||
expect(result.description.properties[3]).toEqual(operationProp);
|
||||
});
|
||||
|
||||
it('should handle nodes with empty properties', () => {
|
||||
fullNodeWrapper.description.properties = [];
|
||||
const result = instance.convertNodeToAiTool(fullNodeWrapper);
|
||||
expect(result.description.properties).toHaveLength(2);
|
||||
expect(result.description.properties[1].name).toBe('toolDescription');
|
||||
expect(result.description.properties).toHaveLength(1);
|
||||
expect(result.description.properties[0].name).toBe('toolDescription');
|
||||
});
|
||||
|
||||
it('should handle nodes with existing codex property', () => {
|
||||
|
||||
@@ -701,6 +701,7 @@ export class TelemetryEventRelay extends EventRelay {
|
||||
sharing_role: userRole,
|
||||
credential_type: null,
|
||||
is_managed: false,
|
||||
...TelemetryHelpers.resolveAIMetrics(workflow.nodes, this.nodeTypes),
|
||||
};
|
||||
|
||||
if (!manualExecEventProperties.node_graph_string) {
|
||||
|
||||
@@ -484,14 +484,6 @@ export class LoadNodesAndCredentials {
|
||||
placeholder: `e.g. ${item.description.description}`,
|
||||
};
|
||||
|
||||
const noticeProp: INodeProperties = {
|
||||
displayName:
|
||||
"Use the expression {{ $fromAI('placeholder_name') }} for any data to be filled by the model",
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
};
|
||||
|
||||
item.description.properties.unshift(descProp);
|
||||
|
||||
// If node has resource or operation we can determine pre-populate tool description based on it
|
||||
@@ -505,8 +497,6 @@ export class LoadNodesAndCredentials {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
item.description.properties.unshift(noticeProp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user