-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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(core): Implement wrapping of regular nodes as AI Tools #10641
Conversation
Before this change, any tools connected to the agent wouldn't run with updated parameters. This was because the context would've been cached by the closure in the newly added `supplyData` function. Now, we derive the context and parameters from the passed context.
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.
Amazing work! 💪
Not sure it is relevant (feel free to discard), but lodash have some utility methods for working with object properties by path (e.g. get
, set
, toPath
, property
). Although lodash path format is slightly different for array elements, maybe it is possible to replace some custom code with methods from lodash.
I left some minor comments and questions.
134f288
to
576d601
Compare
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.
@burivuhster Thank you for the review! Could you have one more look, please?
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.
Thanks for addressing my comments!
LGTM 🚀
n8n
|
Project |
n8n
|
Branch Review |
ai-284-implement-node-as-tool-wrapper
|
Run status |
|
Run duration | 04m 47s |
Commit |
|
Committer | Oleg Ivaniv |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
0
|
|
0
|
|
422
|
View all changes introduced in this branch ↗︎ |
✅ All Cypress E2E specs passed |
* master: refactor(RabbitMQ Trigger Node): Improve type-safety, add tests, and fix issues with manual triggers (#10663) feat(editor): Add support for nodes with multiple main inputs in new canvas (no-changelog) (#10659) fix(editor): Set minimum zoom to 0 to allow fitting very large workflows in new canvas (no-changelog) (#10666) feat(editor): Change selection to be default canvas behaviour (no-changelog) (#10668) feat: More hints to nodes (#10565) fix(editor): Fix opening executions tab from a new, unsaved workflow (#10652) fix(AI Agent Node): Fix tools agent when using memory and Anthropic models (#10513) feat(editor): Make highlighted data pane floating (#10638) fix(editor): Fix workflow loading after switching to executions view in new canvas (no-changelog) (#10655) refactor(benchmark): Separate cloud env provisioning from running benchmarks (#10657) feat(core): Implement wrapping of regular nodes as AI Tools (#10641) refactor(editor): Remove Trial logic in personalization modal and port to script setup (#10649) fix(core): Declutter webhook insertion errors (#10650) feat: Reintroduce collaboration feature (#10602) feat(benchmark): Add scenario for expressions with Set node (#10647) feat(benchmark): Add benchmark scenario for binary files (#10648) build: Add `reset` script (#10627) feat(editor): Overhaul node insert position computation in new canvas (no-changelog) (#10637)
Got released with |
Co-authored-by: JP van Oosten <[email protected]>
* as an AI Agent Tool. | ||
* Returns the modified item (not copied) | ||
*/ | ||
export function convertNodeToAiTool< |
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.
why did we decide to put this here? can we instead move this to core
?
We have way much code in the workflow package. So unless some code actually needs to be shared between backend, frontend, and nodes, we should avoid adding it to this package 🙏🏽
Summary
This PR introduces the ability to wrap regular n8n nodes as AI Tools for use with AI agents. Key changes include:
Added
usableAsTool
property to node definitions to indicate eligibility for tool wrapping.Implemented
createNodeAsTool
function:getNodeParameter
to integrate LLM-provided values.Modified
NodeExecuteFunctions
:getInputConnectionData
to handle tool nodes.supplyData
method but is marked as usable as a tool, it creates a wrapper function that callsgetNodeAsTool
.Updated
NodeHelpers
withconvertNodeToAiTool
function to modify node descriptions for tool use, including adding a custom description field for LLMs.Right now,
usableAsTool
is not set for any of the nodes, we'll enable this in the next phase once we also have placeholder parameters implemented so that LLM could actually pass data to these tools.Example with
usableAsTool: true
and HackerNews node:CleanShot.2024-09-03.at.09.46.53.mp4
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)