-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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(Question and Answer Chain Node): Customize question and answer prompt #10385
Conversation
Hi @mprytoluk -- thank you for contributing to this node! I like the idea of being able to change the system prompt, so really appreciate your PR. A couple of things that came to mind while looking at this:
|
Hi @jeanpaul. Thank you very much for your review! I believe the points you raised are very important, and I'm excited to work on them. I won't be able to work on this PR for the next 3-4 weeks, but as soon as possible, I will resume with changes addressing the points raised. |
Hello again @jeanpaul! I've made new commits addressing all the points raised in your review. As for points 2,3,4: |
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.
Hi @mprytoluk, Thanks for these changes! This makes the code also a bit simpler, which I like 😄
It looks good, so I'll go ahead and merge it.
* master: feat(Iterable Node): Add support for EDC and USDC selection (#10908) test(Schedule Trigger Node): Add tests and extract trigger test helper (no-changelog) (#10625) fix(Todoist Node): Fix listSearch filter bug in Todoist Node (#10989) fix(AwsS3 Node): Fix search only using first input parameters (#10998) fix(editor): Fix bug causing node issues to not be assigned before first interaction (no-changelog) (#10980) fix(editor): Allow resources to move between personal and team projects (#10683) fix(Respond to Webhook Node): Node does not work with Wait node (#10992) fix(core): Upgrade @n8n/typeorm to address a rare mutex release issue (#10993) refactor(core): Separate execution `startedAt` from `createdAt` (#10810) refactor(core): Make all pubsub messages type-safe (#10990) feat(Question and Answer Chain Node): Customize question and answer system prompt (#10385) fix(editor): Fix performance issue in credentials list (#10988) fix(RSS Feed Trigger Node): Fix regression on missing timestamps (#10991) fix(editor): Fix workflow executions list page redirection (#10981) fix(editor): Fix filter execution by "Queued" (#10987) fix(API): Fix workflow project transfer (#10651)
Got released with |
Hi, thanks for the node update! |
Summary
The PR adds the ability to customize the Question and Answer prompt of the “Question and Answer Chain” node.
There are options to add a standard prompt (for non-Chat models) and a chat prompt, as a system message (for Chat models). The default langchain prompts are used as default values for these prompts.
If the "Custom Question and Answer Prompt" boolean is set to false (the default value), the node doesn't change it's behavior at all, so this isn't a breaking change.
In the current state (without this PR), the Question and Answer prompt is not customizable, and the default prompt is used, according to the Model Type, as defined in the langchain code.
To test this PR, you could add this node between the "Question and Anwser Chain" node and the Language Model node to log the used Input prompt on the web console:
{ "meta": { "instanceId": "72f1ea16a419b6b7665b6919b04c52751be5f8fdaa216af12b4f670d6bfb854a" }, "nodes": [ { "parameters": { "code": { "supplyData": { "code": "const llm = await this.getInputConnectionData('ai_languageModel', 0);\n\nllm.callbacks = [\n {\n handleLLMStart(llm, prompts){\n const inputPrompt = prompts[0];\n console.log(inputPrompt);\n },\n },\n];\n\nreturn llm;" } }, "inputs": { "input": [ { "type": "ai_languageModel", "maxConnections": 1, "required": true } ] }, "outputs": { "output": [ { "type": "ai_languageModel" } ] } }, "id": "a036cc49-3b5f-4afd-a901-7060166d59f0", "name": "Log Input Prompt", "type": "@n8n/n8n-nodes-langchain.code", "typeVersion": 1, "position": [ 460, 1060 ] } ], "connections": {}, "pinData": {} }
PR screenshots:
Related Linear tickets, Github issues, and Community forum posts
This PR implements the feature requested here, in which is further elaborated why this feature is useful.
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)