UNPKG

@n8n/n8n-nodes-langchain

Version:

![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

175 lines 5.68 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var MemoryZep_node_exports = {}; __export(MemoryZep_node_exports, { MemoryZep: () => MemoryZep }); module.exports = __toCommonJS(MemoryZep_node_exports); var import_zep = require("@langchain/community/memory/zep"); var import_zep_cloud = require("@langchain/community/memory/zep_cloud"); var import_n8n_workflow = require("n8n-workflow"); var import_helpers = require("../../../utils/helpers"); var import_logWrapper = require("../../../utils/logWrapper"); var import_sharedFields = require("../../../utils/sharedFields"); var import_descriptions = require("../descriptions"); class WhiteSpaceTrimmedZepCloudMemory extends import_zep_cloud.ZepCloudMemory { async loadMemoryVariables(values) { const memoryVariables = await super.loadMemoryVariables(values); memoryVariables.chat_history = memoryVariables.chat_history.filter( (m) => m.content.toString().trim() ); return memoryVariables; } } class MemoryZep { constructor() { this.description = { displayName: "Zep", name: "memoryZep", hidden: true, // 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, 1.3], description: "Use Zep Memory", defaults: { name: "Zep" }, 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.memoryzep/" } ] } }, inputs: [], outputs: [import_n8n_workflow.NodeConnectionTypes.AiMemory], outputNames: ["Memory"], credentials: [ { name: "zepApi", required: true } ], properties: [ { displayName: "This Zep integration is deprecated and will be removed in a future version.", name: "deprecationNotice", type: "notice", default: "" }, (0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiAgent]), { displayName: "Only works with Zep Cloud and Community edition <= v0.27.2", name: "supportedVersions", 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] } } }, { ...import_descriptions.sessionIdOption, displayOptions: { show: { "@version": [{ _cnd: { gte: 1.2 } }] } } }, (0, import_descriptions.expressionSessionKeyProperty)(1.3), import_descriptions.sessionKeyProperty ] }; } async supplyData(itemIndex) { const credentials = await this.getCredentials("zepApi"); const nodeVersion = this.getNode().typeVersion; let sessionId; if (nodeVersion >= 1.2) { sessionId = (0, import_helpers.getSessionId)(this, itemIndex); } else { sessionId = this.getNodeParameter("sessionId", itemIndex); } let memory; if (credentials.cloud) { if (!credentials.apiKey) { throw new import_n8n_workflow.NodeOperationError(this.getNode(), "API key is required to use Zep Cloud"); } memory = new WhiteSpaceTrimmedZepCloudMemory({ sessionId, apiKey: credentials.apiKey, memoryType: "perpetual", memoryKey: "chat_history", returnMessages: true, inputKey: "input", outputKey: "output", separateMessages: false }); } else { if (!credentials.apiUrl) { throw new import_n8n_workflow.NodeOperationError(this.getNode(), "API url is required to use Zep Open Source"); } memory = new import_zep.ZepMemory({ sessionId, baseURL: credentials.apiUrl, apiKey: credentials.apiKey, memoryKey: "chat_history", returnMessages: true, inputKey: "input", outputKey: "output" }); } return { response: (0, import_logWrapper.logWrapper)(memory, this) }; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MemoryZep }); //# sourceMappingURL=MemoryZep.node.js.map