mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Fix OtherTrigger->(new Memory->Agent) case
This commit is contained in:
parent
144f9fb44f
commit
deddc656d7
|
@ -1,4 +1,9 @@
|
|||
import { AGENT_NODE_TYPE, CHAT_TRIGGER_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE } from '@/constants';
|
||||
import {
|
||||
AGENT_NODE_TYPE,
|
||||
CHAT_TRIGGER_NODE_TYPE,
|
||||
MANUAL_TRIGGER_NODE_TYPE,
|
||||
ZENDESK_TRIGGER_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
import { adjustNewNodes } from '@/utils/connectionNodeUtils';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
|
||||
|
@ -61,7 +66,18 @@ describe('adjustNewlyConnectedNodes', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('modifies sessionId with ChatTrigger->(new Memory->Agent)', () => {
|
||||
it('does not modify promptType with OtherTrigger->new Agent', () => {
|
||||
const source = { type: ZENDESK_TRIGGER_NODE_TYPE };
|
||||
const target = { type: AGENT_NODE_TYPE };
|
||||
|
||||
adjustNewNodes(source, target, { sourceIsNew: false });
|
||||
|
||||
expect(target).toEqual({
|
||||
type: AGENT_NODE_TYPE,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not modify sessionId with ChatTrigger->(new Memory->Agent)', () => {
|
||||
const trigger = { type: CHAT_TRIGGER_NODE_TYPE, name: 'trigger' };
|
||||
getsourceNodesByDepth.mockReturnValue([{ name: trigger.name }]);
|
||||
getNode.mockReturnValue({ type: trigger.type });
|
||||
|
@ -76,7 +92,7 @@ describe('adjustNewlyConnectedNodes', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('does not modify sessionId with ManualTrigger->(new Memory->Agent)', () => {
|
||||
it('does modify sessionId with ManualTrigger->(new Memory->Agent)', () => {
|
||||
const trigger = { type: MANUAL_TRIGGER_NODE_TYPE, name: 'trigger' };
|
||||
getsourceNodesByDepth.mockReturnValue([{ name: trigger.name }]);
|
||||
getNode.mockReturnValue({ type: trigger.type });
|
||||
|
@ -91,4 +107,20 @@ describe('adjustNewlyConnectedNodes', () => {
|
|||
parameters: { sessionIdType: 'customKey' },
|
||||
});
|
||||
});
|
||||
|
||||
it('does modify sessionId with OtherTrigger->(new Memory->Agent)', () => {
|
||||
const trigger = { type: ZENDESK_TRIGGER_NODE_TYPE, name: 'trigger' };
|
||||
getsourceNodesByDepth.mockReturnValue([{ name: trigger.name }]);
|
||||
getNode.mockReturnValue({ type: trigger.type });
|
||||
|
||||
const target = { type: AGENT_NODE_TYPE, name: 'myAgent' };
|
||||
const source = { type: '@n8n/n8n-nodes-langchain.memoryBufferWindow' };
|
||||
|
||||
adjustNewNodes(source, target, { targetIsNew: false });
|
||||
|
||||
expect(source).toEqual({
|
||||
type: '@n8n/n8n-nodes-langchain.memoryBufferWindow',
|
||||
parameters: { sessionIdType: 'customKey' },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ function adjustNewSource(source: AddedNode, target: AddedNode) {
|
|||
const { getCurrentWorkflow } = useWorkflowsStore();
|
||||
const workflow = getCurrentWorkflow();
|
||||
|
||||
// If a memory node is added to an Agent, the memory node is actually a parent since it provides input
|
||||
// If a memory node is added to an Agent, the memory node is actually the source since it provides input
|
||||
// So we need to look for the Agent's (other) parents to determine if there is a sessionId provider
|
||||
const ps = workflow.getParentNodesByDepth(target.name, 1);
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue