rename and test

This commit is contained in:
Charlie Kolb 2024-11-12 10:32:07 +01:00
parent 70c92760d5
commit c2a44583c7
No known key found for this signature in database
4 changed files with 49 additions and 8 deletions

View file

@ -44,7 +44,7 @@ import { useExternalHooks } from '@/composables/useExternalHooks';
import { sortNodeCreateElements, transformNodeType } from '../utils'; import { sortNodeCreateElements, transformNodeType } from '../utils';
import { useI18n } from '@/composables/useI18n'; import { useI18n } from '@/composables/useI18n';
import { useCanvasStore } from '@/stores/canvas.store'; import { useCanvasStore } from '@/stores/canvas.store';
import { adjustNewlyConnectedNodes } from '@/utils/connectionParameterUtils'; import { adjustNewlyConnectedNodes } from '@/utils/connectionNodeUtils';
export const useActions = () => { export const useActions = () => {
const nodeCreatorStore = useNodeCreatorStore(); const nodeCreatorStore = useNodeCreatorStore();

View file

@ -96,7 +96,7 @@ import type { useRouter } from 'vue-router';
import { useClipboard } from '@/composables/useClipboard'; import { useClipboard } from '@/composables/useClipboard';
import { useUniqueNodeName } from '@/composables/useUniqueNodeName'; import { useUniqueNodeName } from '@/composables/useUniqueNodeName';
import { isPresent } from '../utils/typesUtils'; import { isPresent } from '../utils/typesUtils';
import { adjustNewlyConnectedNodes } from '@/utils/connectionParameterUtils'; import { adjustNewlyConnectedNodes } from '@/utils/connectionNodeUtils';
type AddNodeData = Partial<INodeUi> & { type AddNodeData = Partial<INodeUi> & {
type: string; type: string;

View file

@ -0,0 +1,41 @@
import { AGENT_NODE_TYPE, CHAT_TRIGGER_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE } from '@/constants';
import { adjustNewlyConnectedNodes } from './connectionNodeUtils';
describe('adjustNewlyConnectedNodes', () => {
it('modifies promptType with ChatTrigger->Agent', () => {
const parent = { type: CHAT_TRIGGER_NODE_TYPE };
const child = { type: AGENT_NODE_TYPE };
adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({
type: AGENT_NODE_TYPE,
parameters: { promptType: 'define' },
});
});
it('does not modify promptType with ManualTrigger->Agent', () => {
const parent = { type: MANUAL_TRIGGER_NODE_TYPE };
const child = { type: AGENT_NODE_TYPE };
adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({
type: AGENT_NODE_TYPE,
});
});
it('modifies sessionId with ChatTrigger->Memory', () => {
const parent = { type: CHAT_TRIGGER_NODE_TYPE };
const child = { type: 'memoryBufferWindow' };
adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({
type: 'memoryBufferWindow',
});
});
it('does not modify sessionId with ManualTrigger->Memory', () => {
const parent = { type: MANUAL_TRIGGER_NODE_TYPE };
const child = { type: 'memoryBufferWindow' };
adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({
type: 'memoryBufferWindow',
parameters: { sessionIdType: 'customKey' },
});
});
});

View file

@ -17,12 +17,12 @@ const AI_NODES = [
]; ];
const MEMORY_NODE_NAMES = [ const MEMORY_NODE_NAMES = [
'memoryBufferWindow', '@n8n/n8n-nodes-langchain.memoryBufferWindow',
'memoryMotorhead', '@n8n/n8n-nodes-langchain.memoryMotorhead',
'memoryPostgresChat', '@n8n/n8n-nodes-langchain.memoryPostgresChat',
'memoryRedisChat', '@n8n/n8n-nodes-langchain.memoryRedisChat',
'memoryXata', '@n8n/n8n-nodes-langchain.memoryXata',
'memoryZep', '@n8n/n8n-nodes-langchain.memoryZep',
]; ];
const PROMPT_PROVIDER_NODE_NAMES = [CHAT_TRIGGER_NODE_TYPE]; const PROMPT_PROVIDER_NODE_NAMES = [CHAT_TRIGGER_NODE_TYPE];