feat: Session is selector for memory nodes (#8736)

This commit is contained in:
Michael Kret
2024-02-27 15:01:15 +02:00
committed by GitHub
parent 5f6da7b84e
commit 2aaf211dfc
7 changed files with 188 additions and 22 deletions

View File

@@ -10,6 +10,8 @@ import {
import { MotorheadMemory } from 'langchain/memory';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
import { sessionIdOption, sessionKeyProperty } from '../descriptions';
import { getSessionId } from '../../../utils/helpers';
export class MemoryMotorhead implements INodeType {
description: INodeTypeDescription = {
@@ -17,7 +19,7 @@ export class MemoryMotorhead implements INodeType {
name: 'memoryMotorhead',
icon: 'fa:file-export',
group: ['transform'],
version: [1, 1.1],
version: [1, 1.1, 1.2],
description: 'Use Motorhead Memory',
defaults: {
name: 'Motorhead',
@@ -72,13 +74,29 @@ export class MemoryMotorhead implements INodeType {
},
},
},
{
...sessionIdOption,
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 1.2 } }],
},
},
},
sessionKeyProperty,
],
};
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
const credentials = await this.getCredentials('motorheadApi');
const nodeVersion = this.getNode().typeVersion;
const sessionId = this.getNodeParameter('sessionId', itemIndex) as string;
let sessionId;
if (nodeVersion >= 1.2) {
sessionId = getSessionId(this, itemIndex);
} else {
sessionId = this.getNodeParameter('sessionId', itemIndex) as string;
}
const memory = new MotorheadMemory({
sessionId,