@n8n/n8n-nodes-langchain
Version:

118 lines • 4.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemoryMotorhead = void 0;
const motorhead_memory_1 = require("@langchain/community/memory/motorhead_memory");
const n8n_workflow_1 = require("n8n-workflow");
const helpers_1 = require("../../../utils/helpers");
const ai_utilities_1 = require("@n8n/ai-utilities");
const descriptions_1 = require("../descriptions");
class MemoryMotorhead {
constructor() {
this.description = {
displayName: 'Motorhead',
name: 'memoryMotorhead',
icon: 'fa:file-export',
iconColor: 'black',
hidden: true,
group: ['transform'],
version: [1, 1.1, 1.2, 1.3],
description: 'Use Motorhead Memory',
defaults: {
name: 'Motorhead',
},
codex: {
categories: ['AI'],
subcategories: {
AI: ['Memory'],
Memory: ['Other memories'],
},
resources: {
primaryDocumentation: [
{
url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memorymotorhead/',
},
],
},
},
inputs: [],
outputs: [n8n_workflow_1.NodeConnectionTypes.AiMemory],
outputNames: ['Memory'],
credentials: [
{
name: 'motorheadApi',
required: true,
},
],
properties: [
(0, ai_utilities_1.getConnectionHintNoticeField)([n8n_workflow_1.NodeConnectionTypes.AiAgent]),
{
displayName: 'The Motorhead project is no longer maintained. This node is deprecated and will be removed in a future version.',
name: 'deprecationNotice',
type: 'notice',
default: '',
},
{
displayName: 'Session ID',
name: 'sessionId',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
'@version': [1],
},
},
},
{
displayName: 'Session ID',
name: 'sessionId',
type: 'string',
default: '={{ $json.sessionId }}',
description: 'The key to use to store the memory',
displayOptions: {
show: {
'@version': [1.1],
},
},
},
{
...descriptions_1.sessionIdOption,
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 1.2 } }],
},
},
},
(0, descriptions_1.expressionSessionKeyProperty)(1.3),
descriptions_1.sessionKeyProperty,
],
};
}
async supplyData(itemIndex) {
const credentials = await this.getCredentials('motorheadApi');
const nodeVersion = this.getNode().typeVersion;
let sessionId;
if (nodeVersion >= 1.2) {
sessionId = (0, helpers_1.getSessionId)(this, itemIndex);
}
else {
sessionId = this.getNodeParameter('sessionId', itemIndex);
}
const memory = new motorhead_memory_1.MotorheadMemory({
sessionId,
url: `${credentials.host}/motorhead`,
clientId: credentials.clientId,
apiKey: credentials.apiKey,
memoryKey: 'chat_history',
returnMessages: true,
inputKey: 'input',
outputKey: 'output',
});
await memory.init();
return {
response: (0, ai_utilities_1.logWrapper)(memory, this),
};
}
}
exports.MemoryMotorhead = MemoryMotorhead;
//# sourceMappingURL=MemoryMotorhead.node.js.map