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(editor): Improve how we show default Agent prompt and Memory session parameters #11491

Merged
merged 9 commits into from
Nov 12, 2024

Conversation

OlegIvaniv
Copy link
Contributor

Summary

Currently, our AI nodes default to using expressions like {{ $json.chatInput }} and {{ $json.sessionId }} for certain fields. However, this implementation causes confusion to the new users.

This PR improves the UX by:

  1. Making these default expression fields visible but disabled when in automatic modes (e.g., when promptType is auto)
  2. Introducing a new disabledOptions property that follows the same logic as displayOptions but disables fields instead of hiding them

Changes

  • Added disabledOptions interface parallel to displayOptions for node properties
  • Updated parameter input components to handle disabled state
  • Modified expression editor components to support read-only mode styling
  • Added version checks to ensure backward compatibility
  • Applied the changes to:
    • Chain LLM node
    • Chain Retrieval QA node
    • SQL Agent node
    • Various memory nodes (Buffer Window, Motorhead, Postgres Chat, Redis Chat, Xata, Zep)
    • OpenAI Assistant node
CleanShot.2024-10-31.at.16.12.03.mp4

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)

Copy link

cypress bot commented Oct 31, 2024

n8n    Run #7825

Run Properties:  status check passed Passed #7825  •  git commit d49767b093: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 OlegIvaniv 🗃️ e2e/*
Project n8n
Branch Review ai-372-no-prompt-specified-text_disabled
Run status status check passed Passed #7825
Run duration 04m 19s
Commit git commit d49767b093: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 OlegIvaniv 🗃️ e2e/*
Committer Oleg Ivaniv
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 466
View all changes introduced in this branch ↗︎

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team ui Enhancement in /editor-ui or /design-system labels Oct 31, 2024
Copy link
Contributor

@CharlieKolb CharlieKolb left a comment

Choose a reason for hiding this comment

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

The code looks good and the feature looks even better!

I could see some users not immediately getting that/why the field is disabled, having a tooltip on hover that points calls out the controlling field or a tag next to the parameter name might be a good follow up item.
Having a visible hierarchy with indentation would also help.

Please do get another opinion as well since I'm new and mostly unfamiliar with existing best practices, as my comments will prove :D

@@ -315,7 +315,7 @@ export class ChainLlm implements INodeType {
},
},
{
displayName: 'Prompt',
displayName: 'Prompt Source',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this take from packages/@n8n/nodes-langchain/utils/descriptions.ts? That one still has Prompt rather than Prompt Source, as an aside. (Prompt Source is much better 👍 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I updated all of them to use promptTypeOptions from the shared utils file

@OlegIvaniv
Copy link
Contributor Author

OlegIvaniv commented Nov 12, 2024

The code looks good and the feature looks even better!

I could see some users not immediately getting that/why the field is disabled, having a tooltip on hover that points calls out the controlling field or a tag next to the parameter name might be a good follow up item. Having a visible hierarchy with indentation would also help.

Please do get another opinion as well since I'm new and mostly unfamiliar with existing best practices, as my comments will prove :D

Appreciate the review, @CharlieKolb! I updated the PR to use shared textFromPreviousNode and promptTypeOptions everywhere. Could you have another look, please?
Btw, here's a workflow with all the variations/versions of applicable nodes:
Prompt___Session_Source_Nodes.json

Copy link
Contributor

@CharlieKolb CharlieKolb left a comment

Choose a reason for hiding this comment

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

Thanks for the example workflow, that's great :D

PR looks good to go from my side 👍

Copy link
Contributor

✅ All Cypress E2E specs passed

@elsmr elsmr changed the title feat(editor): Improve show we show default Agent prompt and Memory session parameters feat(editor): Improve how we show default Agent prompt and Memory session parameters Nov 12, 2024
Copy link
Member

@elsmr elsmr left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Nice work, I like how you kept disabledOptions simple by reusing the displayOptions format. Maybe some of that code should be renamed in the future.

show and hide don't make much sense in disabledOptions. It's becoming a more general "Condition" object instead of something specific for hiding parameters.

Copy link
Contributor

✅ All Cypress E2E specs passed

@OlegIvaniv
Copy link
Contributor Author

LGTM! 🎉

Nice work, I like how you kept disabledOptions simple by reusing the displayOptions format. Maybe some of that code should be renamed in the future.

show and hide don't make much sense in disabledOptions. It's becoming a more general "Condition" object instead of something specific for hiding parameters.

Thanks!
+1 on renaming it later to something more general(conditionalParametersOptions?), I would also love to use it for specifying the default value based on condition, but that breaks all kinds of stuff right now :D

@OlegIvaniv OlegIvaniv merged commit 565f8cd into master Nov 12, 2024
86 checks passed
@OlegIvaniv OlegIvaniv deleted the ai-372-no-prompt-specified-text_disabled branch November 12, 2024 10:33
@github-actions github-actions bot mentioned this pull request Nov 13, 2024
@janober
Copy link
Member

janober commented Nov 13, 2024

Got released with [email protected]

burivuhster pushed a commit that referenced this pull request Nov 14, 2024
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 Released ui Enhancement in /editor-ui or /design-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants