Skip to content
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

feat(AI Transform Node): New node #10405

Merged
merged 53 commits into from
Aug 14, 2024
Merged

Conversation

michael-radency
Copy link
Contributor

@michael-radency michael-radency commented Aug 14, 2024

Summary

fix to original PR #9990

AI_TRANSFORM_NODE_TYPE has to be added to SCRIPTING_NODE_TYPES and NODES_WITH_RENAMABLE_CONTENT; otherwise, the original items are updated.


This PR introduces a new "AI Transform"* node that generates code snippets based on user instructions. The AI is context-aware, understanding the workflow's nodes and their data types. Users can simply enter their instructions and click the "Generate Code" button to let the AI automatically populate the Code parameter.

image


During development, the node's "button" property was improved:

export type NodePropertyAction = {
	type: 'askAiCodeGeneration';
	handler?: string;
	target?: string;
};

export interface INodePropertyTypeOptions {
	
	buttonConfig?: {
		action?: string | NodePropertyAction;
		label?: string; 
		hasInputField?: boolean;
		inputFieldMaxLength?: number; 
	};
	...
}

This updated interface allows you to specify a label, an optional input field with its maximum input length, and an action. The action can be specified as a string or as a NodePropertyAction, which allows you to set the type of action (currently only 'askAiCodeGeneration') and optionally an action target, such as a parameter that would be affected as a result of this action. Additionally, a handler function defined in methods.actionHandler can be executed on the backend when clicked.

	methods = {
		actionHandler: {
			async generateCode(this: ILoadOptionsFunctions, payload: IDataObject | string | undefined) {
				const url = this.getNodeParameter('url', 0) as string;
				let body: IDataObject = {};
				if (payload) {
					body = typeof payload === 'string' ? jsonParse(payload) : payload;
				}
				const response = (await this.helpers.httpRequest({
					method: 'POST',
					url,
					headers: {
						'Content-Type': 'application/json',
					},
					body,
				})) as {
					data: { code: string };
				};

				return response?.data?.code;
			},
		},
	};

  • This node is currently available only on the cloud.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-1461/ai-transform-node-p0

michael-radency and others added 30 commits July 9, 2024 08:28
michael-radency and others added 17 commits August 6, 2024 12:09
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team node/new Creation of an entirely new node ui Enhancement in /editor-ui or /design-system labels Aug 14, 2024
Copy link
Contributor

@ShireenMissi ShireenMissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Copy link

cypress bot commented Aug 14, 2024



Test summary

401 0 0 0Flakiness 1


Run details

Project n8n
Status Passed
Commit 87c6890
Started Aug 14, 2024 1:10 PM
Ended Aug 14, 2024 1:15 PM
Duration 04:47 💡
OS Linux Debian -
Browser Electron 118

View run in Cypress Cloud ➡️


Flakiness

e2e/14-mapping.cy.ts Flakiness
1 Data mapping > maps expressions from table header

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

Copy link
Contributor

✅ All Cypress E2E specs passed

@michael-radency michael-radency merged commit 4d222ac into master Aug 14, 2024
28 checks passed
@michael-radency michael-radency deleted the node-1461-transform-ai-node branch August 14, 2024 13:20
@github-actions github-actions bot mentioned this pull request Aug 14, 2024
@janober
Copy link
Member

janober commented Aug 15, 2024

Got released with n8n@1.55.0

MiloradFilipovic added a commit that referenced this pull request Aug 15, 2024
* master: (22 commits)
  refactor(editor): Type node view event bus (no-changelog) (#10396)
  refactor: Update to license SDK v2.13.1 to address dependency updates (#10422)
  refactor(core): Simplify Redis client types (no-changelog) (#10397)
  fix: Project Viewer always seeing a connection error when testing credentials (#10417)
  fix(editor): Fix incorrect node type version selection on new canvas (no-changelog) (#10412)
  fix(core): Fix payload property in `workflow-post-execute` event (#10413)
  fix: Require mfa code to change email (#10354)
  ci: Remove hard-coded package version in unit tests (no-changelog) (#10414)
  refactor(editor): Remove deleted event name from UI (#10402)
  🚀 Release 1.55.0 (#10411)
  fix: Add better error handling for chat errors (#10408)
  ci: Trigger Docker releases on tag creation instead of release publishing (no-changelog) (#10409)
  fix(AI Agent Node): Fix issues with some tools not populating (#10406)
  feat(AI Transform Node): Telemetry (no-changelog) (#10398)
  feat(AI Transform Node): New node (#10405)
  feat: Add Ask assistant behind feature flag (#9995)
  refactor(editor): Use form event bus everywhere (no-changelog) (#10394)
  fix: Remove node AI Transform node (no-changelog) (#10400)
  fix(editor): Remove `@n8n/permissions` from `n8n-workflow` (no-changelog) (#10399)
  refactor(core): Make new configs consistent (no-changelog) (#10393)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team node/new Creation of an entirely new node Released ui Enhancement in /editor-ui or /design-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants