mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(editor): Improve how we show default Agent prompt and Memory session parameters (#11491)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { BufferWindowMemoryInput } from 'langchain/memory';
|
||||
import { BufferWindowMemory } from 'langchain/memory';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
@@ -6,12 +8,16 @@ import {
|
||||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type { BufferWindowMemoryInput } from 'langchain/memory';
|
||||
import { BufferWindowMemory } from 'langchain/memory';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { sessionIdOption, sessionKeyProperty, contextWindowLengthProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
contextWindowLengthProperty,
|
||||
expressionSessionKeyProperty,
|
||||
} from '../descriptions';
|
||||
|
||||
class MemoryChatBufferSingleton {
|
||||
private static instance: MemoryChatBufferSingleton;
|
||||
@@ -72,7 +78,7 @@ export class MemoryBufferWindow implements INodeType {
|
||||
name: 'memoryBufferWindow',
|
||||
icon: 'fa:database',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1, 1.2],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
description: 'Stores in n8n memory, so no credentials required',
|
||||
defaults: {
|
||||
name: 'Window Buffer Memory',
|
||||
@@ -129,6 +135,7 @@ export class MemoryBufferWindow implements INodeType {
|
||||
},
|
||||
},
|
||||
},
|
||||
expressionSessionKeyProperty(1.3),
|
||||
sessionKeyProperty,
|
||||
contextWindowLengthProperty,
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { MotorheadMemory } from '@langchain/community/memory/motorhead_memory';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
@@ -7,11 +8,10 @@ import {
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { MotorheadMemory } from '@langchain/community/memory/motorhead_memory';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { sessionIdOption, sessionKeyProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';
|
||||
|
||||
export class MemoryMotorhead implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -19,7 +19,7 @@ export class MemoryMotorhead implements INodeType {
|
||||
name: 'memoryMotorhead',
|
||||
icon: 'fa:file-export',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1, 1.2],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
description: 'Use Motorhead Memory',
|
||||
defaults: {
|
||||
name: 'Motorhead',
|
||||
@@ -82,6 +82,7 @@ export class MemoryMotorhead implements INodeType {
|
||||
},
|
||||
},
|
||||
},
|
||||
expressionSessionKeyProperty(1.3),
|
||||
sessionKeyProperty,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { PostgresChatMessageHistory } from '@langchain/community/stores/message/postgres';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import type { PostgresNodeCredentials } from 'n8n-nodes-base/dist/nodes/Postgres/v2/helpers/interfaces';
|
||||
import { postgresConnectionTest } from 'n8n-nodes-base/dist/nodes/Postgres/v2/methods/credentialTest';
|
||||
import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/v2/transport';
|
||||
import type {
|
||||
ISupplyDataFunctions,
|
||||
INodeType,
|
||||
@@ -6,16 +11,17 @@ import type {
|
||||
SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import { PostgresChatMessageHistory } from '@langchain/community/stores/message/postgres';
|
||||
import type pg from 'pg';
|
||||
import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/v2/transport';
|
||||
import type { PostgresNodeCredentials } from 'n8n-nodes-base/dist/nodes/Postgres/v2/helpers/interfaces';
|
||||
import { postgresConnectionTest } from 'n8n-nodes-base/dist/nodes/Postgres/v2/methods/credentialTest';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { sessionIdOption, sessionKeyProperty, contextWindowLengthProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
contextWindowLengthProperty,
|
||||
expressionSessionKeyProperty,
|
||||
} from '../descriptions';
|
||||
|
||||
export class MemoryPostgresChat implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -23,7 +29,7 @@ export class MemoryPostgresChat implements INodeType {
|
||||
name: 'memoryPostgresChat',
|
||||
icon: 'file:postgres.svg',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
description: 'Stores the chat history in Postgres table.',
|
||||
defaults: {
|
||||
name: 'Postgres Chat Memory',
|
||||
@@ -56,6 +62,7 @@ export class MemoryPostgresChat implements INodeType {
|
||||
properties: [
|
||||
getConnectionHintNoticeField([NodeConnectionType.AiAgent]),
|
||||
sessionIdOption,
|
||||
expressionSessionKeyProperty(1.2),
|
||||
sessionKeyProperty,
|
||||
{
|
||||
displayName: 'Table Name',
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { RedisChatMessageHistoryInput } from '@langchain/redis';
|
||||
import { RedisChatMessageHistory } from '@langchain/redis';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import {
|
||||
NodeOperationError,
|
||||
type INodeType,
|
||||
@@ -7,15 +10,18 @@ import {
|
||||
type SupplyData,
|
||||
NodeConnectionType,
|
||||
} from 'n8n-workflow';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import type { RedisChatMessageHistoryInput } from '@langchain/redis';
|
||||
import { RedisChatMessageHistory } from '@langchain/redis';
|
||||
import type { RedisClientOptions } from 'redis';
|
||||
import { createClient } from 'redis';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { sessionIdOption, sessionKeyProperty, contextWindowLengthProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
contextWindowLengthProperty,
|
||||
expressionSessionKeyProperty,
|
||||
} from '../descriptions';
|
||||
|
||||
export class MemoryRedisChat implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -23,7 +29,7 @@ export class MemoryRedisChat implements INodeType {
|
||||
name: 'memoryRedisChat',
|
||||
icon: 'file:redis.svg',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
version: [1, 1.1, 1.2, 1.3, 1.4],
|
||||
description: 'Stores the chat history in Redis.',
|
||||
defaults: {
|
||||
name: 'Redis Chat Memory',
|
||||
@@ -86,6 +92,7 @@ export class MemoryRedisChat implements INodeType {
|
||||
},
|
||||
},
|
||||
},
|
||||
expressionSessionKeyProperty(1.4),
|
||||
sessionKeyProperty,
|
||||
{
|
||||
displayName: 'Session Time To Live',
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { XataChatMessageHistory } from '@langchain/community/stores/message/xata';
|
||||
import { BaseClient } from '@xata.io/client';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
ISupplyDataFunctions,
|
||||
@@ -6,13 +9,16 @@ import type {
|
||||
INodeTypeDescription,
|
||||
SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { XataChatMessageHistory } from '@langchain/community/stores/message/xata';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import { BaseClient } from '@xata.io/client';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { sessionIdOption, sessionKeyProperty, contextWindowLengthProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
contextWindowLengthProperty,
|
||||
expressionSessionKeyProperty,
|
||||
} from '../descriptions';
|
||||
|
||||
export class MemoryXata implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -20,7 +26,7 @@ export class MemoryXata implements INodeType {
|
||||
name: 'memoryXata',
|
||||
icon: 'file:xata.svg',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
version: [1, 1.1, 1.2, 1.3, 1.4],
|
||||
description: 'Use Xata Memory',
|
||||
defaults: {
|
||||
name: 'Xata',
|
||||
@@ -86,6 +92,7 @@ export class MemoryXata implements INodeType {
|
||||
},
|
||||
},
|
||||
sessionKeyProperty,
|
||||
expressionSessionKeyProperty(1.4),
|
||||
{
|
||||
...contextWindowLengthProperty,
|
||||
displayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { sessionIdOption, sessionKeyProperty } from '../descriptions';
|
||||
import { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';
|
||||
import type { InputValues, MemoryVariables } from '@langchain/core/memory';
|
||||
@@ -36,7 +36,7 @@ export class MemoryZep implements INodeType {
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
|
||||
icon: 'file:zep.png',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1, 1.2],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
description: 'Use Zep Memory',
|
||||
defaults: {
|
||||
name: 'Zep',
|
||||
@@ -99,6 +99,7 @@ export class MemoryZep implements INodeType {
|
||||
},
|
||||
},
|
||||
},
|
||||
expressionSessionKeyProperty(1.3),
|
||||
sessionKeyProperty,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -21,6 +21,20 @@ export const sessionIdOption: INodeProperties = {
|
||||
default: 'fromInput',
|
||||
};
|
||||
|
||||
export const expressionSessionKeyProperty = (fromVersion: number): INodeProperties => ({
|
||||
displayName: 'Session Key From Previous Node',
|
||||
name: 'sessionKey',
|
||||
type: 'string',
|
||||
default: '={{ $json.sessionId }}',
|
||||
disabledOptions: { show: { sessionIdType: ['fromInput'] } },
|
||||
displayOptions: {
|
||||
show: {
|
||||
sessionIdType: ['fromInput'],
|
||||
'@version': [{ _cnd: { gte: fromVersion } }],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const sessionKeyProperty: INodeProperties = {
|
||||
displayName: 'Key',
|
||||
name: 'sessionKey',
|
||||
|
||||
Reference in New Issue
Block a user