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(HTTP Request Tool Node): Use DynamicStructureTool with models supporting it (no-changelog) #10246

Merged
merged 14 commits into from
Aug 7, 2024

Conversation

burivuhster
Copy link
Contributor

@burivuhster burivuhster commented Jul 30, 2024

Summary

This PR is an attempt to make passing parameters to HTTP tool more reliable. More specifically – to utilize model's tool calling feature when it is possible (e.g. OpenAI, Claude). To achieve this, we need to provide HTTP tool as a DynamicStructuredTool to the agent when it makes sense. To save backwards compatibility we need to provide DynamicAgent, as it was done before.

We introduced a wrapper class (N8nTool), extending DynamicStructuredTool, having an additional asDynamicTool() method, doing the wrapping.

Agents use HTTP Tool node as DynamicStructuredTool or DynamicTool depending on their abilities (see getConnectedTools)

To make sure we don't break existing workflows, we incremented the minor node version.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/AI-249/tools-agent-with-openai-chat-model-sometimes-refuses-to-pass-proper

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Jul 30, 2024
Comment on lines 396 to 405

const description = prepareToolDescription(toolDescription, toolParameters);
const schema = makeToolInputSchema(toolParameters);

const tool = new DynamicTool({ name, description, func });
const tool = new N8nTool(this, {
name,
description: toolDescription,
func,
schema,
});

Copy link
Contributor

Choose a reason for hiding this comment

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

are we sure that after update behavior would be same? if not I would suggest to put those changes under new minor version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the node version?

Copy link
Contributor

Choose a reason for hiding this comment

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

@burivuhster
yes, exactly

@burivuhster burivuhster changed the title wip: use HTTP tool as DynamicStructuredTool wherever possible feat(HTTP Request Tool Node): Use DynamicStructureTool with models supporting it Aug 6, 2024
@burivuhster burivuhster marked this pull request as ready for review August 6, 2024 11:49
@burivuhster burivuhster changed the title feat(HTTP Request Tool Node): Use DynamicStructureTool with models supporting it feat(HTTP Request Tool Node): Use DynamicStructureTool with models supporting it (no-changelog) Aug 6, 2024
Copy link
Contributor

@michael-radency michael-radency 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 7, 2024



Test summary

394 0 0 0Flakiness 0


Run details

Project n8n
Status Passed
Commit 6e3c52c
Started Aug 7, 2024 6:19 AM
Ended Aug 7, 2024 6:24 AM
Duration 04:44 💡
OS Linux Debian -
Browser Electron 118

View run in Cypress Cloud ➡️


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

github-actions bot commented Aug 7, 2024

✅ All Cypress E2E specs passed

@burivuhster burivuhster merged commit a936680 into master Aug 7, 2024
30 of 32 checks passed
@burivuhster burivuhster deleted the ai-249-tools-agent-with-openai-chat-model branch August 7, 2024 09:20
@janober
Copy link
Member

janober commented Aug 7, 2024

Got released with [email protected]

MiloradFilipovic added a commit that referenced this pull request Aug 7, 2024
* master:
  refactor(core): Centralize scaling mode (no-changelog) (#9835)
  fix(editor): Remove body padding from storybook previews (no-changelog) (#10317)
  feat(MySQL Node): Return decimal types as numbers (#10313)
  🚀 Release 1.54.0 (#10315)
  feat(Elasticsearch Node): Add bulk operations for Elasticsearch (#9940)
  feat(Stripe Trigger Node): Add Stripe webhook descriptions based on the workflow ID and name (#9956)
  feat(MongoDB Node): Add projection to query options on Find (#9972)
  fix(Invoice Ninja Node): Fix payment types (#10196)
  feat(HTTP Request Tool Node): Use DynamicStructuredTool with models supporting it (no-changelog) (#10246)
  feat: Return scopes on executions (no-changelog) (#10310)
  feat(Webflow Node): Update to use the v2 API (#9996)
  feat(Lemlist Trigger Node): Update Trigger events (#10311)
  feat(Calendly Trigger Node): Update event names (no-changelog) (#10129)
  refactor(core): Reorganize webhook related components under src/webhooks (no-changelog) (#10296)
  docs: Fix links to license files in readme (no-changelog) (#10257)
  fix(editor): Update design system Avatar component to show initials also when only firstName or lastName is given (#10308)
  fix(editor): Update tags filter/editor to not show non existing tag as a selectable option (#10297)
  fix(editor): Update project tabs test (no-changelog) (#10300)
  fix(core): VM2 sandbox should not throw on `new Promise` (#10298)

# Conflicts:
#	packages/design-system/src/components/N8nAvatar/Avatar.vue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants