Skip to content

Commit

Permalink
Use simple object instead of function; use correct version in redis node
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanpaul committed Aug 5, 2024
1 parent 9234197 commit 68a51a6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class MemoryBufferWindow implements INodeType {
},
},
sessionKeyProperty,
contextWindowLengthProperty(),
contextWindowLengthProperty,
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export class MemoryPostgresChat implements INodeType {
description:
'The table name to store the chat history in. If table does not exist, it will be created.',
},
contextWindowLengthProperty({ hide: { '@version': [{ _cnd: { lt: 1.1 } }] } }),
{
...contextWindowLengthProperty,
displayOptions: { hide: { '@version': [{ _cnd: { lt: 1.1 } }] } },
},
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export class MemoryRedisChat implements INodeType {
description:
'For how long the session should be stored in seconds. If set to 0 it will not expire.',
},
contextWindowLengthProperty({ hide: { '@version': [{ _cnd: { lt: 1.3 } }] } }),
{
...contextWindowLengthProperty,
displayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },
},
],
};

Expand Down Expand Up @@ -144,9 +147,9 @@ export class MemoryRedisChat implements INodeType {
}
const redisChatHistory = new RedisChatMessageHistory(redisChatConfig);

const memClass = this.getNode().typeVersion < 1.1 ? BufferMemory : BufferWindowMemory;
const memClass = this.getNode().typeVersion < 1.3 ? BufferMemory : BufferWindowMemory;
const kOptions =
this.getNode().typeVersion < 1.1
this.getNode().typeVersion < 1.3
? {}
: { k: this.getNodeParameter('contextWindowLength', itemIndex) };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export class MemoryXata implements INodeType {
},
},
sessionKeyProperty,
contextWindowLengthProperty({ hide: { '@version': [{ _cnd: { lt: 1.3 } }] } }),
{
...contextWindowLengthProperty,
displayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },
},
],
};

Expand Down
17 changes: 7 additions & 10 deletions packages/@n8n/nodes-langchain/nodes/memory/descriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ export const sessionKeyProperty: INodeProperties = {
},
};

export function contextWindowLengthProperty(displayOptions?: IDisplayOptions): INodeProperties {
return {
displayName: 'Context Window Length',
name: 'contextWindowLength',
type: 'number',
default: 5,
hint: 'How many past interactions the model receives as context',
displayOptions: displayOptions ?? {},
};
}
export const contextWindowLengthProperty: INodeProperties = {
displayName: 'Context Window Length',
name: 'contextWindowLength',
type: 'number',
default: 5,
hint: 'How many past interactions the model receives as context',
};

0 comments on commit 68a51a6

Please sign in to comment.