UNPKG

@n8n/n8n-nodes-langchain

Version:

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

120 lines 3.85 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 create_operation_exports = {}; __export(create_operation_exports, { description: () => description, execute: () => execute }); module.exports = __toCommonJS(create_operation_exports); var import_n8n_workflow = require("n8n-workflow"); var import_transport = require("../../../transport"); var import_descriptions = require("../descriptions"); var import_responses = require("../text/helpers/responses"); const properties = [ { displayName: "Messages", name: "messages", type: "fixedCollection", typeOptions: { sortable: true, multipleValues: true }, placeholder: "Add Message", default: { values: [{ type: "text" }] }, options: [ { displayName: "Message", name: "values", values: [ { displayName: "Role", name: "role", type: "options", description: "Role in shaping the model's response, it tells the model how it should behave and interact with the user", options: [ { name: "User", value: "user", description: "Send a message as a user and get a response from the model" }, { name: "Assistant", value: "assistant", description: "Tell the model to adopt a specific tone or personality" }, { name: "System", value: "system", description: "Usually used to set the model's behavior or context for the next user message" } ], default: "user" }, { ...import_descriptions.textMessageProperties[0], displayOptions: {} } ] } ] }, { displayName: "Options", name: "options", placeholder: "Add Option", type: "collection", default: {}, options: [import_descriptions.metadataProperty] } ]; const displayOptions = { show: { operation: ["create"], resource: ["conversation"] } }; const description = (0, import_n8n_workflow.updateDisplayOptions)(displayOptions, properties); async function execute(i) { const options = this.getNodeParameter("options", i, {}); const messages = this.getNodeParameter("messages.values", i, []); const body = { items: await import_responses.formatInputMessages.call(this, i, messages) }; if (options.metadata) { const metadata = (0, import_n8n_workflow.jsonParse)(options.metadata, { errorMessage: "Invalid JSON in metadata field" }); if (!(0, import_n8n_workflow.isObjectEmpty)(metadata)) { body.metadata = metadata; } } const response = await import_transport.apiRequest.call(this, "POST", "/conversations", { body }); return [ { json: response, pairedItem: { item: i } } ]; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { description, execute }); //# sourceMappingURL=create.operation.js.map