@n8n/n8n-nodes-langchain 1.115.1 → 1.116.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/credentials/AnthropicApi.credentials.js +39 -8
- package/dist/credentials/AnthropicApi.credentials.js.map +1 -1
- package/dist/credentials/LemonadeApi.credentials.js +70 -0
- package/dist/credentials/LemonadeApi.credentials.js.map +1 -0
- package/dist/known/credentials.json +9 -0
- package/dist/known/nodes.json +12 -0
- package/dist/nodes/agents/Agent/Agent.node.js +1 -2
- package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js +2 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/description.js +13 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/description.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js +49 -30
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js +3 -0
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsLemonade/EmbeddingsLemonade.node.js +87 -0
- package/dist/nodes/embeddings/EmbeddingsLemonade/EmbeddingsLemonade.node.js.map +1 -0
- package/dist/nodes/embeddings/EmbeddingsLemonade/lemonade.svg +53 -0
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +17 -0
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +12 -8
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
- package/dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js +106 -0
- package/dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js.map +1 -0
- package/dist/nodes/llms/LMChatLemonade/lemonade.svg +53 -0
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +6 -5
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
- package/dist/nodes/llms/LMLemonade/LmLemonade.node.js +107 -0
- package/dist/nodes/llms/LMLemonade/LmLemonade.node.js.map +1 -0
- package/dist/nodes/llms/LMLemonade/description.js +147 -0
- package/dist/nodes/llms/LMLemonade/description.js.map +1 -0
- package/dist/nodes/llms/LMLemonade/lemonade.svg +53 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +3 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js +14 -1
- package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +107 -47
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js +2 -1
- package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js +43 -4
- package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js.map +1 -1
- package/dist/nodes/vendors/Anthropic/transport/index.js +9 -5
- package/dist/nodes/vendors/Anthropic/transport/index.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js +50 -11
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/helpers/binary-data.js +3 -3
- package/dist/nodes/vendors/OpenAi/helpers/binary-data.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/helpers/description.js +75 -0
- package/dist/nodes/vendors/OpenAi/helpers/description.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/helpers/modelFiltering.js +34 -0
- package/dist/nodes/vendors/OpenAi/helpers/modelFiltering.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/polling.js +52 -0
- package/dist/nodes/vendors/OpenAi/helpers/polling.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js +27 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js +10 -6
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v1/OpenAiV1.node.js +110 -0
- package/dist/nodes/vendors/OpenAi/v1/OpenAiV1.node.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/create.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/create.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/deleteAssistant.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/deleteAssistant.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/list.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/message.operation.js +5 -5
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/update.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/update.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/audio/generate.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/audio/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/audio/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/audio/transcribe.operation.js +2 -2
- package/dist/nodes/vendors/OpenAi/v1/actions/audio/transcribe.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/audio/translate.operation.js +2 -2
- package/dist/nodes/vendors/OpenAi/v1/actions/audio/translate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/descriptions.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/file/deleteFile.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/file/deleteFile.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/file/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/file/list.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/file/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/file/upload.operation.js +2 -2
- package/dist/nodes/vendors/OpenAi/v1/actions/file/upload.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/image/analyze.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/image/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/image/generate.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/image/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/image/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/node.type.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/router.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/router.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/text/classify.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/text/classify.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v1/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/text/message.operation.js +4 -4
- package/dist/nodes/vendors/OpenAi/v1/actions/text/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/OpenAiV2.node.js +116 -0
- package/dist/nodes/vendors/OpenAi/v2/OpenAiV2.node.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/generate.operation.js +197 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/index.js +96 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/transcribe.operation.js +121 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/transcribe.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/translate.operation.js +111 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/translate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/create.operation.js +120 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/create.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/get.operation.js +60 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/get.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/index.js +94 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/remove.operation.js +60 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/remove.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/update.operation.js +75 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/conversation/update.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/descriptions.js +279 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/descriptions.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/deleteFile.operation.js +84 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/deleteFile.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/index.js +84 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/list.operation.js +92 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/upload.operation.js +130 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/file/upload.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/analyze.operation.js +211 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/edit.operation.js +464 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/edit.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/generate.operation.js +319 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/index.js +84 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/image/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/node.type.js +17 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/node.type.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/router.js +111 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/router.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/classify.operation.js +102 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/classify.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/helpers/responses.js +277 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/helpers/responses.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/index.js +75 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js +774 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/video/generate.operation.js +199 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/video/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/video/index.js +64 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/video/index.js.map +1 -0
- package/dist/types/credentials.json +2 -1
- package/dist/types/nodes.json +10 -6
- package/dist/utils/helpers.js +22 -2
- package/dist/utils/helpers.js.map +1 -1
- package/package.json +14 -10
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/audio/index.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/descriptions.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/file/index.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/image/index.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/node.type.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/router.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/text/index.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js.map +0 -1
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js +0 -160
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js.map +0 -1
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/index.js +0 -0
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/audio/index.js +0 -0
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/descriptions.js +0 -0
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/file/index.js +0 -0
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/image/index.js +0 -0
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/node.type.js +0 -0
- /package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/text/index.js +0 -0
package/dist/utils/helpers.js
CHANGED
|
@@ -150,9 +150,29 @@ function escapeSingleCurlyBrackets(text) {
|
|
|
150
150
|
return result;
|
|
151
151
|
}
|
|
152
152
|
const getConnectedTools = async (ctx, enforceUniqueNames, convertStructuredTool = true, escapeCurlyBrackets = false) => {
|
|
153
|
-
const
|
|
153
|
+
const toolkitConnections = await ctx.getInputConnectionData(
|
|
154
|
+
import_n8n_workflow.NodeConnectionTypes.AiTool,
|
|
155
|
+
0
|
|
156
|
+
);
|
|
157
|
+
const parentNodes = "getParentNodes" in ctx ? ctx.getParentNodes(ctx.getNode().name, {
|
|
158
|
+
connectionType: import_n8n_workflow.NodeConnectionTypes.AiTool,
|
|
159
|
+
depth: 1
|
|
160
|
+
}) : [];
|
|
161
|
+
const connectedTools = (toolkitConnections ?? []).flatMap((toolOrToolkit, index) => {
|
|
154
162
|
if (toolOrToolkit instanceof import_agents.Toolkit) {
|
|
155
|
-
|
|
163
|
+
const tools = toolOrToolkit.getTools();
|
|
164
|
+
return tools.map((tool) => {
|
|
165
|
+
const sourceNode = parentNodes[index] ?? tool.name;
|
|
166
|
+
tool.metadata ??= {};
|
|
167
|
+
tool.metadata.isFromToolkit = true;
|
|
168
|
+
tool.metadata.sourceNodeName = sourceNode?.name;
|
|
169
|
+
return tool;
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
const sourceNode = parentNodes[index] ?? toolOrToolkit.name;
|
|
173
|
+
toolOrToolkit.metadata ??= {};
|
|
174
|
+
toolOrToolkit.metadata.isFromToolkit = false;
|
|
175
|
+
toolOrToolkit.metadata.sourceNodeName = sourceNode?.name;
|
|
156
176
|
}
|
|
157
177
|
return toolOrToolkit;
|
|
158
178
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/helpers.ts"],"sourcesContent":["import type { BaseChatMessageHistory } from '@langchain/core/chat_history';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { BaseLLM } from '@langchain/core/language_models/llms';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport type { Tool } from '@langchain/core/tools';\nimport { Toolkit } from 'langchain/agents';\nimport type { BaseChatMemory } from 'langchain/memory';\nimport { NodeConnectionTypes, NodeOperationError, jsonStringify } from 'n8n-workflow';\nimport type {\n\tAiEvent,\n\tIDataObject,\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tIWebhookFunctions,\n} from 'n8n-workflow';\n\nimport { N8nTool } from './N8nTool';\n\nfunction hasMethods<T>(obj: unknown, ...methodNames: Array<string | symbol>): obj is T {\n\treturn methodNames.every(\n\t\t(methodName) =>\n\t\t\ttypeof obj === 'object' &&\n\t\t\tobj !== null &&\n\t\t\tmethodName in obj &&\n\t\t\ttypeof (obj as Record<string | symbol, unknown>)[methodName] === 'function',\n\t);\n}\n\nexport function getMetadataFiltersValues(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\titemIndex: number,\n): Record<string, never> | undefined {\n\tconst options = ctx.getNodeParameter('options', itemIndex, {});\n\n\tif (options.metadata) {\n\t\tconst { metadataValues: metadata } = options.metadata as {\n\t\t\tmetadataValues: Array<{\n\t\t\t\tname: string;\n\t\t\t\tvalue: string;\n\t\t\t}>;\n\t\t};\n\t\tif (metadata.length > 0) {\n\t\t\treturn metadata.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});\n\t\t}\n\t}\n\n\tif (options.searchFilterJson) {\n\t\treturn ctx.getNodeParameter('options.searchFilterJson', itemIndex, '', {\n\t\t\tensureType: 'object',\n\t\t}) as Record<string, never>;\n\t}\n\n\treturn undefined;\n}\n\nexport function isBaseChatMemory(obj: unknown) {\n\treturn hasMethods<BaseChatMemory>(obj, 'loadMemoryVariables', 'saveContext');\n}\n\nexport function isBaseChatMessageHistory(obj: unknown) {\n\treturn hasMethods<BaseChatMessageHistory>(obj, 'getMessages', 'addMessage');\n}\n\nexport function isChatInstance(model: unknown): model is BaseChatModel {\n\tconst namespace = (model as BaseLLM)?.lc_namespace ?? [];\n\n\treturn namespace.includes('chat_models');\n}\n\nexport function isToolsInstance(model: unknown): model is Tool {\n\tconst namespace = (model as Tool)?.lc_namespace ?? [];\n\n\treturn namespace.includes('tools');\n}\n\nexport function getPromptInputByType(options: {\n\tctx: IExecuteFunctions | ISupplyDataFunctions;\n\ti: number;\n\tpromptTypeKey: string;\n\tinputKey: string;\n}) {\n\tconst { ctx, i, promptTypeKey, inputKey } = options;\n\tconst promptType = ctx.getNodeParameter(promptTypeKey, i, 'define') as string;\n\n\tlet input;\n\tif (promptType === 'auto') {\n\t\tinput = ctx.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else {\n\t\tinput = ctx.getNodeParameter(inputKey, i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tthrow new NodeOperationError(ctx.getNode(), 'No prompt specified', {\n\t\t\tdescription:\n\t\t\t\t\"Expected to find the prompt in an input field called 'chatInput' (this is what the chat trigger node outputs). To use something else, change the 'Prompt' parameter\",\n\t\t});\n\t}\n\n\treturn input;\n}\n\nexport function getSessionId(\n\tctx: ISupplyDataFunctions | IWebhookFunctions,\n\titemIndex: number,\n\tselectorKey = 'sessionIdType',\n\tautoSelect = 'fromInput',\n\tcustomKey = 'sessionKey',\n) {\n\tlet sessionId = '';\n\tconst selectorType = ctx.getNodeParameter(selectorKey, itemIndex) as string;\n\n\tif (selectorType === autoSelect) {\n\t\t// If memory node is used in webhook like node(like chat trigger node), it doesn't have access to evaluateExpression\n\t\t// so we try to extract sessionId from the bodyData\n\t\tif ('getBodyData' in ctx) {\n\t\t\tconst bodyData = ctx.getBodyData() ?? {};\n\t\t\tsessionId = bodyData.sessionId as string;\n\t\t} else {\n\t\t\tsessionId = ctx.evaluateExpression('{{ $json.sessionId }}', itemIndex) as string;\n\n\t\t\t// try to get sessionId from chat trigger\n\t\t\tif (!sessionId || sessionId === undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tconst chatTrigger = ctx.getChatTrigger();\n\n\t\t\t\t\tif (chatTrigger) {\n\t\t\t\t\t\tsessionId = ctx.evaluateExpression(\n\t\t\t\t\t\t\t`{{ $('${chatTrigger.name}').first().json.sessionId }}`,\n\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t) as string;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {}\n\t\t\t}\n\t\t}\n\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'No session ID found', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Expected to find the session ID in an input field called 'sessionId' (this is what the chat trigger node outputs). To use something else, change the 'Session ID' parameter\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tsessionId = ctx.getNodeParameter(customKey, itemIndex, '') as string;\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Key parameter is empty', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Provide a key to use as session ID in the 'Key' parameter or use the 'Connected Chat Trigger Node' option to use the session ID from your Chat Trigger\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn sessionId;\n}\n\nexport function logAiEvent(\n\texecuteFunctions: IExecuteFunctions | ISupplyDataFunctions,\n\tevent: AiEvent,\n\tdata?: IDataObject,\n) {\n\ttry {\n\t\texecuteFunctions.logAiEvent(event, data ? jsonStringify(data) : undefined);\n\t} catch (error) {\n\t\texecuteFunctions.logger.debug(`Error logging AI event: ${event}`);\n\t}\n}\n\nexport function serializeChatHistory(chatHistory: BaseMessage[]): string {\n\treturn chatHistory\n\t\t.map((chatMessage) => {\n\t\t\tif (chatMessage._getType() === 'human') {\n\t\t\t\treturn `Human: ${chatMessage.content}`;\n\t\t\t} else if (chatMessage._getType() === 'ai') {\n\t\t\t\treturn `Assistant: ${chatMessage.content}`;\n\t\t\t} else {\n\t\t\t\treturn `${chatMessage.content}`;\n\t\t\t}\n\t\t})\n\t\t.join('\\n');\n}\n\nexport function escapeSingleCurlyBrackets(text?: string): string | undefined {\n\tif (text === undefined) return undefined;\n\n\tlet result = text;\n\n\tresult = result\n\t\t// First handle triple brackets to avoid interference with double brackets\n\t\t.replace(/(?<!{){{{(?!{)/g, '{{{{')\n\t\t.replace(/(?<!})}}}(?!})/g, '}}}}')\n\t\t// Then handle single brackets, but only if they're not part of double brackets\n\t\t// Convert single { to {{ if it's not already part of {{ or {{{\n\t\t.replace(/(?<!{){(?!{)/g, '{{')\n\t\t// Convert single } to }} if it's not already part of }} or }}}\n\t\t.replace(/(?<!})}(?!})/g, '}}');\n\n\treturn result;\n}\n\nexport const getConnectedTools = async (\n\tctx: IExecuteFunctions | IWebhookFunctions | ISupplyDataFunctions,\n\tenforceUniqueNames: boolean,\n\tconvertStructuredTool: boolean = true,\n\tescapeCurlyBrackets: boolean = false,\n) => {\n\tconst connectedTools = (\n\t\t((await ctx.getInputConnectionData(NodeConnectionTypes.AiTool, 0)) as Array<Toolkit | Tool>) ??\n\t\t[]\n\t).flatMap((toolOrToolkit) => {\n\t\tif (toolOrToolkit instanceof Toolkit) {\n\t\t\treturn toolOrToolkit.getTools() as Tool[];\n\t\t}\n\n\t\treturn toolOrToolkit;\n\t});\n\n\tif (!enforceUniqueNames) return connectedTools;\n\n\tconst seenNames = new Set<string>();\n\n\tconst finalTools: Tool[] = [];\n\n\tfor (const tool of connectedTools) {\n\t\tconst { name } = tool;\n\t\tif (seenNames.has(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`You have multiple tools with the same name: '${name}', please rename them to avoid conflicts`,\n\t\t\t);\n\t\t}\n\t\tseenNames.add(name);\n\n\t\tif (escapeCurlyBrackets) {\n\t\t\ttool.description = escapeSingleCurlyBrackets(tool.description) ?? tool.description;\n\t\t}\n\n\t\tif (convertStructuredTool && tool instanceof N8nTool) {\n\t\t\tfinalTools.push(tool.asDynamicTool());\n\t\t} else {\n\t\t\tfinalTools.push(tool);\n\t\t}\n\t}\n\n\treturn finalTools;\n};\n\n/**\n * Sometimes model output is wrapped in an additional object property.\n * This function unwraps the output if it is in the format { output: { output: { ... } } }\n */\nexport function unwrapNestedOutput(output: Record<string, unknown>): Record<string, unknown> {\n\tif (\n\t\t'output' in output &&\n\t\tObject.keys(output).length === 1 &&\n\t\ttypeof output.output === 'object' &&\n\t\toutput.output !== null &&\n\t\t'output' in output.output &&\n\t\tObject.keys(output.output).length === 1\n\t) {\n\t\treturn output.output as Record<string, unknown>;\n\t}\n\n\treturn output;\n}\n\n/**\n * Detects if a text contains a character that repeats sequentially for a specified threshold.\n * This is used to prevent performance issues with tiktoken on highly repetitive content.\n * @param text The text to check\n * @param threshold The minimum number of sequential repeats to detect (default: 1000)\n * @returns true if a character repeats sequentially for at least the threshold amount\n */\nexport function hasLongSequentialRepeat(text: string, threshold = 1000): boolean {\n\ttry {\n\t\t// Validate inputs\n\t\tif (\n\t\t\ttext === null ||\n\t\t\ttypeof text !== 'string' ||\n\t\t\ttext.length === 0 ||\n\t\t\tthreshold <= 0 ||\n\t\t\ttext.length < threshold\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// Use string iterator to avoid creating array copy (memory efficient)\n\t\tconst iterator = text[Symbol.iterator]();\n\t\tlet prev = iterator.next();\n\n\t\tif (prev.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet count = 1;\n\t\tfor (const char of iterator) {\n\t\t\tif (char === prev.value) {\n\t\t\t\tcount++;\n\t\t\t\tif (count >= threshold) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcount = 1;\n\t\t\t\tprev = { value: char, done: false };\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t} catch (error) {\n\t\t// On any error, return false to allow normal processing\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,0BAAuE;AASvE,qBAAwB;AAExB,SAAS,WAAc,QAAiB,aAA+C;AACtF,SAAO,YAAY;AAAA,IAClB,CAAC,eACA,OAAO,QAAQ,YACf,QAAQ,QACR,cAAc,OACd,OAAQ,IAAyC,UAAU,MAAM;AAAA,EACnE;AACD;AAEO,SAAS,yBACf,KACA,WACoC;AACpC,QAAM,UAAU,IAAI,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAE7D,MAAI,QAAQ,UAAU;AACrB,UAAM,EAAE,gBAAgB,SAAS,IAAI,QAAQ;AAM7C,QAAI,SAAS,SAAS,GAAG;AACxB,aAAO,SAAS,OAAO,CAAC,KAAK,EAAE,MAAM,MAAM,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,GAAG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O,SAAS,YAChB,KAAK,WAAW,KAChB,aAAa,KACb,KAAK,SAAS,WACb;AACD,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,KAAK,OAAO,QAAQ,EAAE;AACvC,QAAI,OAAO,SAAS,KAAK;AAEzB,QAAI,KAAK,MAAM;AACd,aAAO;AAAA,IACR;AAEA,QAAI,QAAQ;AACZ,eAAW,QAAQ,UAAU;AAC5B,UAAI,SAAS,KAAK,OAAO;AACxB;AACA,YAAI,SAAS,WAAW;AACvB,iBAAO;AAAA,QACR;AAAA,MACD,OAAO;AACN,gBAAQ;AACR,eAAO,EAAE,OAAO,MAAM,MAAM,MAAM;AAAA,MACnC;AAAA,IACD;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AAEf,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../utils/helpers.ts"],"sourcesContent":["import type { BaseChatMessageHistory } from '@langchain/core/chat_history';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { BaseLLM } from '@langchain/core/language_models/llms';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport type { Tool } from '@langchain/core/tools';\nimport { Toolkit } from 'langchain/agents';\nimport type { BaseChatMemory } from 'langchain/memory';\nimport { NodeConnectionTypes, NodeOperationError, jsonStringify } from 'n8n-workflow';\nimport type {\n\tAiEvent,\n\tIDataObject,\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tIWebhookFunctions,\n} from 'n8n-workflow';\n\nimport { N8nTool } from './N8nTool';\n\nfunction hasMethods<T>(obj: unknown, ...methodNames: Array<string | symbol>): obj is T {\n\treturn methodNames.every(\n\t\t(methodName) =>\n\t\t\ttypeof obj === 'object' &&\n\t\t\tobj !== null &&\n\t\t\tmethodName in obj &&\n\t\t\ttypeof (obj as Record<string | symbol, unknown>)[methodName] === 'function',\n\t);\n}\n\nexport function getMetadataFiltersValues(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\titemIndex: number,\n): Record<string, never> | undefined {\n\tconst options = ctx.getNodeParameter('options', itemIndex, {});\n\n\tif (options.metadata) {\n\t\tconst { metadataValues: metadata } = options.metadata as {\n\t\t\tmetadataValues: Array<{\n\t\t\t\tname: string;\n\t\t\t\tvalue: string;\n\t\t\t}>;\n\t\t};\n\t\tif (metadata.length > 0) {\n\t\t\treturn metadata.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});\n\t\t}\n\t}\n\n\tif (options.searchFilterJson) {\n\t\treturn ctx.getNodeParameter('options.searchFilterJson', itemIndex, '', {\n\t\t\tensureType: 'object',\n\t\t}) as Record<string, never>;\n\t}\n\n\treturn undefined;\n}\n\nexport function isBaseChatMemory(obj: unknown) {\n\treturn hasMethods<BaseChatMemory>(obj, 'loadMemoryVariables', 'saveContext');\n}\n\nexport function isBaseChatMessageHistory(obj: unknown) {\n\treturn hasMethods<BaseChatMessageHistory>(obj, 'getMessages', 'addMessage');\n}\n\nexport function isChatInstance(model: unknown): model is BaseChatModel {\n\tconst namespace = (model as BaseLLM)?.lc_namespace ?? [];\n\n\treturn namespace.includes('chat_models');\n}\n\nexport function isToolsInstance(model: unknown): model is Tool {\n\tconst namespace = (model as Tool)?.lc_namespace ?? [];\n\n\treturn namespace.includes('tools');\n}\n\nexport function getPromptInputByType(options: {\n\tctx: IExecuteFunctions | ISupplyDataFunctions;\n\ti: number;\n\tpromptTypeKey: string;\n\tinputKey: string;\n}) {\n\tconst { ctx, i, promptTypeKey, inputKey } = options;\n\tconst promptType = ctx.getNodeParameter(promptTypeKey, i, 'define') as string;\n\n\tlet input;\n\tif (promptType === 'auto') {\n\t\tinput = ctx.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else {\n\t\tinput = ctx.getNodeParameter(inputKey, i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tthrow new NodeOperationError(ctx.getNode(), 'No prompt specified', {\n\t\t\tdescription:\n\t\t\t\t\"Expected to find the prompt in an input field called 'chatInput' (this is what the chat trigger node outputs). To use something else, change the 'Prompt' parameter\",\n\t\t});\n\t}\n\n\treturn input;\n}\n\nexport function getSessionId(\n\tctx: ISupplyDataFunctions | IWebhookFunctions,\n\titemIndex: number,\n\tselectorKey = 'sessionIdType',\n\tautoSelect = 'fromInput',\n\tcustomKey = 'sessionKey',\n) {\n\tlet sessionId = '';\n\tconst selectorType = ctx.getNodeParameter(selectorKey, itemIndex) as string;\n\n\tif (selectorType === autoSelect) {\n\t\t// If memory node is used in webhook like node(like chat trigger node), it doesn't have access to evaluateExpression\n\t\t// so we try to extract sessionId from the bodyData\n\t\tif ('getBodyData' in ctx) {\n\t\t\tconst bodyData = ctx.getBodyData() ?? {};\n\t\t\tsessionId = bodyData.sessionId as string;\n\t\t} else {\n\t\t\tsessionId = ctx.evaluateExpression('{{ $json.sessionId }}', itemIndex) as string;\n\n\t\t\t// try to get sessionId from chat trigger\n\t\t\tif (!sessionId || sessionId === undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tconst chatTrigger = ctx.getChatTrigger();\n\n\t\t\t\t\tif (chatTrigger) {\n\t\t\t\t\t\tsessionId = ctx.evaluateExpression(\n\t\t\t\t\t\t\t`{{ $('${chatTrigger.name}').first().json.sessionId }}`,\n\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t) as string;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {}\n\t\t\t}\n\t\t}\n\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'No session ID found', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Expected to find the session ID in an input field called 'sessionId' (this is what the chat trigger node outputs). To use something else, change the 'Session ID' parameter\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tsessionId = ctx.getNodeParameter(customKey, itemIndex, '') as string;\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Key parameter is empty', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Provide a key to use as session ID in the 'Key' parameter or use the 'Connected Chat Trigger Node' option to use the session ID from your Chat Trigger\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn sessionId;\n}\n\nexport function logAiEvent(\n\texecuteFunctions: IExecuteFunctions | ISupplyDataFunctions,\n\tevent: AiEvent,\n\tdata?: IDataObject,\n) {\n\ttry {\n\t\texecuteFunctions.logAiEvent(event, data ? jsonStringify(data) : undefined);\n\t} catch (error) {\n\t\texecuteFunctions.logger.debug(`Error logging AI event: ${event}`);\n\t}\n}\n\nexport function serializeChatHistory(chatHistory: BaseMessage[]): string {\n\treturn chatHistory\n\t\t.map((chatMessage) => {\n\t\t\tif (chatMessage._getType() === 'human') {\n\t\t\t\treturn `Human: ${chatMessage.content}`;\n\t\t\t} else if (chatMessage._getType() === 'ai') {\n\t\t\t\treturn `Assistant: ${chatMessage.content}`;\n\t\t\t} else {\n\t\t\t\treturn `${chatMessage.content}`;\n\t\t\t}\n\t\t})\n\t\t.join('\\n');\n}\n\nexport function escapeSingleCurlyBrackets(text?: string): string | undefined {\n\tif (text === undefined) return undefined;\n\n\tlet result = text;\n\n\tresult = result\n\t\t// First handle triple brackets to avoid interference with double brackets\n\t\t.replace(/(?<!{){{{(?!{)/g, '{{{{')\n\t\t.replace(/(?<!})}}}(?!})/g, '}}}}')\n\t\t// Then handle single brackets, but only if they're not part of double brackets\n\t\t// Convert single { to {{ if it's not already part of {{ or {{{\n\t\t.replace(/(?<!{){(?!{)/g, '{{')\n\t\t// Convert single } to }} if it's not already part of }} or }}}\n\t\t.replace(/(?<!})}(?!})/g, '}}');\n\n\treturn result;\n}\n\nexport const getConnectedTools = async (\n\tctx: IExecuteFunctions | IWebhookFunctions | ISupplyDataFunctions,\n\tenforceUniqueNames: boolean,\n\tconvertStructuredTool: boolean = true,\n\tescapeCurlyBrackets: boolean = false,\n) => {\n\tconst toolkitConnections = (await ctx.getInputConnectionData(\n\t\tNodeConnectionTypes.AiTool,\n\t\t0,\n\t)) as Array<Toolkit | Tool>;\n\n\t// Get parent nodes to map toolkits to their source nodes\n\tconst parentNodes =\n\t\t'getParentNodes' in ctx\n\t\t\t? ctx.getParentNodes(ctx.getNode().name, {\n\t\t\t\t\tconnectionType: NodeConnectionTypes.AiTool,\n\t\t\t\t\tdepth: 1,\n\t\t\t\t})\n\t\t\t: [];\n\n\tconst connectedTools = (toolkitConnections ?? []).flatMap((toolOrToolkit, index) => {\n\t\tif (toolOrToolkit instanceof Toolkit) {\n\t\t\tconst tools = toolOrToolkit.getTools() as Tool[];\n\t\t\t// Add metadata to each tool from the toolkit\n\t\t\treturn tools.map((tool) => {\n\t\t\t\tconst sourceNode = parentNodes[index] ?? tool.name;\n\n\t\t\t\ttool.metadata ??= {};\n\t\t\t\ttool.metadata.isFromToolkit = true;\n\t\t\t\ttool.metadata.sourceNodeName = sourceNode?.name;\n\t\t\t\treturn tool;\n\t\t\t});\n\t\t} else {\n\t\t\tconst sourceNode = parentNodes[index] ?? toolOrToolkit.name;\n\t\t\ttoolOrToolkit.metadata ??= {};\n\t\t\ttoolOrToolkit.metadata.isFromToolkit = false;\n\t\t\ttoolOrToolkit.metadata.sourceNodeName = sourceNode?.name;\n\t\t}\n\n\t\treturn toolOrToolkit;\n\t});\n\n\tif (!enforceUniqueNames) return connectedTools;\n\n\tconst seenNames = new Set<string>();\n\n\tconst finalTools: Tool[] = [];\n\n\tfor (const tool of connectedTools) {\n\t\tconst { name } = tool;\n\t\tif (seenNames.has(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`You have multiple tools with the same name: '${name}', please rename them to avoid conflicts`,\n\t\t\t);\n\t\t}\n\t\tseenNames.add(name);\n\n\t\tif (escapeCurlyBrackets) {\n\t\t\ttool.description = escapeSingleCurlyBrackets(tool.description) ?? tool.description;\n\t\t}\n\n\t\tif (convertStructuredTool && tool instanceof N8nTool) {\n\t\t\tfinalTools.push(tool.asDynamicTool());\n\t\t} else {\n\t\t\tfinalTools.push(tool);\n\t\t}\n\t}\n\n\treturn finalTools;\n};\n\n/**\n * Sometimes model output is wrapped in an additional object property.\n * This function unwraps the output if it is in the format { output: { output: { ... } } }\n */\nexport function unwrapNestedOutput(output: Record<string, unknown>): Record<string, unknown> {\n\tif (\n\t\t'output' in output &&\n\t\tObject.keys(output).length === 1 &&\n\t\ttypeof output.output === 'object' &&\n\t\toutput.output !== null &&\n\t\t'output' in output.output &&\n\t\tObject.keys(output.output).length === 1\n\t) {\n\t\treturn output.output as Record<string, unknown>;\n\t}\n\n\treturn output;\n}\n\n/**\n * Detects if a text contains a character that repeats sequentially for a specified threshold.\n * This is used to prevent performance issues with tiktoken on highly repetitive content.\n * @param text The text to check\n * @param threshold The minimum number of sequential repeats to detect (default: 1000)\n * @returns true if a character repeats sequentially for at least the threshold amount\n */\nexport function hasLongSequentialRepeat(text: string, threshold = 1000): boolean {\n\ttry {\n\t\t// Validate inputs\n\t\tif (\n\t\t\ttext === null ||\n\t\t\ttypeof text !== 'string' ||\n\t\t\ttext.length === 0 ||\n\t\t\tthreshold <= 0 ||\n\t\t\ttext.length < threshold\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// Use string iterator to avoid creating array copy (memory efficient)\n\t\tconst iterator = text[Symbol.iterator]();\n\t\tlet prev = iterator.next();\n\n\t\tif (prev.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet count = 1;\n\t\tfor (const char of iterator) {\n\t\t\tif (char === prev.value) {\n\t\t\t\tcount++;\n\t\t\t\tif (count >= threshold) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcount = 1;\n\t\t\t\tprev = { value: char, done: false };\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t} catch (error) {\n\t\t// On any error, return false to allow normal processing\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AK,MAAM;AACd,aAAO;AAAA,IACR;AAEA,QAAI,QAAQ;AACZ,eAAW,QAAQ,UAAU;AAC5B,UAAI,SAAS,KAAK,OAAO;AACxB;AACA,YAAI,SAAS,WAAW;AACvB,iBAAO;AAAA,QACR;AAAA,MACD,OAAO;AACN,gBAAQ;AACR,eAAO,EAAE,OAAO,MAAM,MAAM,MAAM;AAAA,MACnC;AAAA,IACD;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AAEf,WAAO;AAAA,EACR;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/n8n-nodes-langchain",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.116.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"dist/credentials/MotorheadApi.credentials.js",
|
|
23
23
|
"dist/credentials/MilvusApi.credentials.js",
|
|
24
24
|
"dist/credentials/MistralCloudApi.credentials.js",
|
|
25
|
+
"dist/credentials/LemonadeApi.credentials.js",
|
|
25
26
|
"dist/credentials/OllamaApi.credentials.js",
|
|
26
27
|
"dist/credentials/OpenRouterApi.credentials.js",
|
|
27
28
|
"dist/credentials/PineconeApi.credentials.js",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js",
|
|
63
64
|
"dist/nodes/embeddings/EmbeddingsMistralCloud/EmbeddingsMistralCloud.node.js",
|
|
64
65
|
"dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js",
|
|
66
|
+
"dist/nodes/embeddings/EmbeddingsLemonade/EmbeddingsLemonade.node.js",
|
|
65
67
|
"dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js",
|
|
66
68
|
"dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js",
|
|
67
69
|
"dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js",
|
|
@@ -72,6 +74,7 @@
|
|
|
72
74
|
"dist/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.js",
|
|
73
75
|
"dist/nodes/llms/LmChatGroq/LmChatGroq.node.js",
|
|
74
76
|
"dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js",
|
|
77
|
+
"dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js",
|
|
75
78
|
"dist/nodes/llms/LMChatOllama/LmChatOllama.node.js",
|
|
76
79
|
"dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js",
|
|
77
80
|
"dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js",
|
|
@@ -79,6 +82,7 @@
|
|
|
79
82
|
"dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js",
|
|
80
83
|
"dist/nodes/llms/LMOpenAi/LmOpenAi.node.js",
|
|
81
84
|
"dist/nodes/llms/LMCohere/LmCohere.node.js",
|
|
85
|
+
"dist/nodes/llms/LMLemonade/LmLemonade.node.js",
|
|
82
86
|
"dist/nodes/llms/LMOllama/LmOllama.node.js",
|
|
83
87
|
"dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js",
|
|
84
88
|
"dist/nodes/mcp/McpClientTool/McpClientTool.node.js",
|
|
@@ -151,7 +155,7 @@
|
|
|
151
155
|
"jest-mock-extended": "^3.0.4",
|
|
152
156
|
"tsup": "^8.5.0",
|
|
153
157
|
"@n8n/eslint-plugin-community-nodes": "0.6.0",
|
|
154
|
-
"n8n-core": "1.
|
|
158
|
+
"n8n-core": "1.116.0"
|
|
155
159
|
},
|
|
156
160
|
"dependencies": {
|
|
157
161
|
"@aws-sdk/client-sso-oidc": "3.808.0",
|
|
@@ -170,18 +174,18 @@
|
|
|
170
174
|
"@langchain/google-genai": "0.2.17",
|
|
171
175
|
"@langchain/google-vertexai": "0.2.18",
|
|
172
176
|
"@langchain/groq": "0.2.3",
|
|
173
|
-
"@langchain/mistralai": "0.2.
|
|
177
|
+
"@langchain/mistralai": "0.2.3",
|
|
174
178
|
"@langchain/mongodb": "^0.1.0",
|
|
175
179
|
"@langchain/ollama": "0.2.3",
|
|
176
|
-
"@langchain/openai": "0.6.
|
|
180
|
+
"@langchain/openai": "0.6.16",
|
|
177
181
|
"@langchain/pinecone": "0.2.0",
|
|
178
182
|
"@langchain/qdrant": "0.1.2",
|
|
179
183
|
"@langchain/redis": "0.1.1",
|
|
180
184
|
"@langchain/textsplitters": "0.1.0",
|
|
181
185
|
"@langchain/weaviate": "0.2.0",
|
|
182
|
-
"@modelcontextprotocol/sdk": "1.
|
|
186
|
+
"@modelcontextprotocol/sdk": "1.15.1",
|
|
183
187
|
"@mozilla/readability": "0.6.0",
|
|
184
|
-
"@n8n/typeorm": "0.3.20-
|
|
188
|
+
"@n8n/typeorm": "0.3.20-14",
|
|
185
189
|
"@n8n/vm2": "3.9.25",
|
|
186
190
|
"@pinecone-database/pinecone": "^5.0.2",
|
|
187
191
|
"@qdrant/js-client-rest": "1.14.1",
|
|
@@ -202,7 +206,7 @@
|
|
|
202
206
|
"jsdom": "23.0.1",
|
|
203
207
|
"langchain": "0.3.33",
|
|
204
208
|
"lodash": "4.17.21",
|
|
205
|
-
"mammoth": "1.
|
|
209
|
+
"mammoth": "1.11.0",
|
|
206
210
|
"mime-types": "2.1.35",
|
|
207
211
|
"mongodb": "6.11.0",
|
|
208
212
|
"openai": "5.12.2",
|
|
@@ -219,13 +223,13 @@
|
|
|
219
223
|
"zod": "3.25.67",
|
|
220
224
|
"zod-to-json-schema": "3.23.3",
|
|
221
225
|
"@n8n/client-oauth2": "0.30.0",
|
|
226
|
+
"@n8n/config": "1.59.0",
|
|
222
227
|
"@n8n/di": "0.9.0",
|
|
223
|
-
"@n8n/config": "1.58.0",
|
|
224
228
|
"@n8n/errors": "^0.5.0",
|
|
225
229
|
"@n8n/json-schema-to-zod": "1.5.0",
|
|
226
|
-
"n8n-nodes-base": "1.114.1",
|
|
227
230
|
"@n8n/typescript-config": "1.3.0",
|
|
228
|
-
"n8n-workflow": "1.
|
|
231
|
+
"n8n-workflow": "1.114.0",
|
|
232
|
+
"n8n-nodes-base": "1.115.0"
|
|
229
233
|
},
|
|
230
234
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
231
235
|
"homepage": "https://n8n.io",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/create.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { NodeOperationError, updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\nimport { modelRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [\n\tmodelRLC('modelSearch'),\n\t{\n\t\tdisplayName: 'Name',\n\t\tname: 'name',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tdescription: 'The name of the assistant. The maximum length is 256 characters.',\n\t\tplaceholder: 'e.g. My Assistant',\n\t\trequired: true,\n\t},\n\t{\n\t\tdisplayName: 'Description',\n\t\tname: 'description',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tdescription: 'The description of the assistant. The maximum length is 512 characters.',\n\t\tplaceholder: 'e.g. My personal assistant',\n\t},\n\t{\n\t\tdisplayName: 'Instructions',\n\t\tname: 'instructions',\n\t\ttype: 'string',\n\t\tdescription:\n\t\t\t'The system instructions that the assistant uses. The maximum length is 32768 characters.',\n\t\tdefault: '',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Code Interpreter',\n\t\tname: 'codeInterpreter',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription:\n\t\t\t'Whether to enable the code interpreter that allows the assistants to write and run Python code in a sandboxed execution environment, find more <a href=\"https://platform.openai.com/docs/assistants/tools/code-interpreter\" target=\"_blank\">here</a>',\n\t},\n\t{\n\t\tdisplayName: 'Knowledge Retrieval',\n\t\tname: 'knowledgeRetrieval',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription:\n\t\t\t'Whether to augments the assistant with knowledge from outside its model, such as proprietary product information or documents, find more <a href=\"https://platform.openai.com/docs/assistants/tools/knowledge-retrieval\" target=\"_blank\">here</a>',\n\t},\n\t//we want to display Files selector only when codeInterpreter true or knowledgeRetrieval true or both\n\t{\n\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options\n\t\tdisplayName: 'Files',\n\t\tname: 'file_ids',\n\t\ttype: 'multiOptions',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-multi-options\n\t\tdescription:\n\t\t\t'The files to be used by the assistant, there can be a maximum of 20 files attached to the assistant. You can use expression to pass file IDs as an array or comma-separated string.',\n\t\ttypeOptions: {\n\t\t\tloadOptionsMethod: 'getFiles',\n\t\t},\n\t\tdefault: [],\n\t\thint: \"Add more files by using the 'Upload a File' operation\",\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tcodeInterpreter: [true],\n\t\t\t},\n\t\t\thide: {\n\t\t\t\tknowledgeRetrieval: [true],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options\n\t\tdisplayName: 'Files',\n\t\tname: 'file_ids',\n\t\ttype: 'multiOptions',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-multi-options\n\t\tdescription:\n\t\t\t'The files to be used by the assistant, there can be a maximum of 20 files attached to the assistant',\n\t\ttypeOptions: {\n\t\t\tloadOptionsMethod: 'getFiles',\n\t\t},\n\t\tdefault: [],\n\t\thint: \"Add more files by using the 'Upload a File' operation\",\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tknowledgeRetrieval: [true],\n\t\t\t},\n\t\t\thide: {\n\t\t\t\tcodeInterpreter: [true],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options\n\t\tdisplayName: 'Files',\n\t\tname: 'file_ids',\n\t\ttype: 'multiOptions',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-multi-options\n\t\tdescription:\n\t\t\t'The files to be used by the assistant, there can be a maximum of 20 files attached to the assistant',\n\t\ttypeOptions: {\n\t\t\tloadOptionsMethod: 'getFiles',\n\t\t},\n\t\tdefault: [],\n\t\thint: \"Add more files by using the 'Upload a File' operation\",\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tknowledgeRetrieval: [true],\n\t\t\t\tcodeInterpreter: [true],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName:\n\t\t\t'Add custom n8n tools when you <i>message</i> your assistant (rather than when creating it)',\n\t\tname: 'noticeTools',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Output Randomness (Temperature)',\n\t\t\t\tname: 'temperature',\n\t\t\t\tdefault: 1,\n\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive. We generally recommend altering this or temperature but not both.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Output Randomness (Top P)',\n\t\t\t\tname: 'topP',\n\t\t\t\tdefault: 1,\n\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t'An alternative to sampling with temperature, controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Fail if Assistant Already Exists',\n\t\t\t\tname: 'failIfExists',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to fail an operation if the assistant with the same name already exists',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['create'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;\n\tconst name = this.getNodeParameter('name', i) as string;\n\tconst assistantDescription = this.getNodeParameter('description', i) as string;\n\tconst instructions = this.getNodeParameter('instructions', i) as string;\n\tconst codeInterpreter = this.getNodeParameter('codeInterpreter', i) as boolean;\n\tconst knowledgeRetrieval = this.getNodeParameter('knowledgeRetrieval', i) as boolean;\n\tlet file_ids = this.getNodeParameter('file_ids', i, []) as string[] | string;\n\tif (typeof file_ids === 'string') {\n\t\tfile_ids = file_ids.split(',').map((file_id) => file_id.trim());\n\t}\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tif (options.failIfExists) {\n\t\tconst assistants: string[] = [];\n\n\t\tlet has_more = true;\n\t\tlet after: string | undefined;\n\n\t\tdo {\n\t\t\tconst response = (await apiRequest.call(this, 'GET', '/assistants', {\n\t\t\t\theaders: {\n\t\t\t\t\t'OpenAI-Beta': 'assistants=v2',\n\t\t\t\t},\n\t\t\t\tqs: {\n\t\t\t\t\tlimit: 100,\n\t\t\t\t\tafter,\n\t\t\t\t},\n\t\t\t})) as { data: IDataObject[]; has_more: boolean; last_id: string };\n\n\t\t\tfor (const assistant of response.data || []) {\n\t\t\t\tassistants.push(assistant.name as string);\n\t\t\t}\n\n\t\t\thas_more = response.has_more;\n\n\t\t\tif (has_more) {\n\t\t\t\tafter = response.last_id;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (has_more);\n\n\t\tif (assistants.includes(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`An assistant with the same name '${name}' already exists`,\n\t\t\t\t{ itemIndex: i },\n\t\t\t);\n\t\t}\n\t}\n\n\tif (file_ids.length > 20) {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\t'The maximum number of files that can be attached to the assistant is 20',\n\t\t\t{ itemIndex: i },\n\t\t);\n\t}\n\n\tconst body: IDataObject = {\n\t\tmodel,\n\t\tname,\n\t\tdescription: assistantDescription,\n\t\tinstructions,\n\t};\n\n\tconst tools = [];\n\n\tif (codeInterpreter) {\n\t\ttools.push({\n\t\t\ttype: 'code_interpreter',\n\t\t});\n\t\tbody.tool_resources = {\n\t\t\t...((body.tool_resources as object) ?? {}),\n\t\t\tcode_interpreter: {\n\t\t\t\tfile_ids,\n\t\t\t},\n\t\t};\n\t}\n\n\tif (knowledgeRetrieval) {\n\t\ttools.push({\n\t\t\ttype: 'file_search',\n\t\t});\n\t\tbody.tool_resources = {\n\t\t\t...((body.tool_resources as object) ?? {}),\n\t\t\tfile_search: {\n\t\t\t\tvector_stores: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfile_ids,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t};\n\t}\n\n\tif (tools.length) {\n\t\tbody.tools = tools;\n\t}\n\n\tconst response = await apiRequest.call(this, 'POST', '/assistants', {\n\t\tbody,\n\t\theaders: {\n\t\t\t'OpenAI-Beta': 'assistants=v2',\n\t\t},\n\t});\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;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A,QACT,KAAK,QAAQ;AAAA,QACb,oCAAoC,IAAI;AAAA,QACxC,EAAE,WAAW,EAAE;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AAEA,MAAI,SAAS,SAAS,IAAI;AACzB,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,MACA,EAAE,WAAW,EAAE;AAAA,IAChB;AAAA,EACD;AAEA,QAAM,OAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACD;AAEA,QAAM,QAAQ,CAAC;AAEf,MAAI,iBAAiB;AACpB,UAAM,KAAK;AAAA,MACV,MAAM;AAAA,IACP,CAAC;AACD,SAAK,iBAAiB;AAAA,MACrB,GAAK,KAAK,kBAA6B,CAAC;AAAA,MACxC,kBAAkB;AAAA,QACjB;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,MAAI,oBAAoB;AACvB,UAAM,KAAK;AAAA,MACV,MAAM;AAAA,IACP,CAAC;AACD,SAAK,iBAAiB;AAAA,MACrB,GAAK,KAAK,kBAA6B,CAAC;AAAA,MACxC,aAAa;AAAA,QACZ,eAAe;AAAA,UACd;AAAA,YACC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,MAAI,MAAM,QAAQ;AACjB,SAAK,QAAQ;AAAA,EACd;AAEA,QAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,QAAQ,eAAe;AAAA,IACnE;AAAA,IACA,SAAS;AAAA,MACR,eAAe;AAAA,IAChB;AAAA,EACD,CAAC;AAED,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":["response"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.ts"],"sourcesContent":["import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\nimport { assistantRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [assistantRLC];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['deleteAssistant'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\n\tconst response = await apiRequest.call(this, 'DELETE', `/assistants/${assistantId}`, {\n\t\theaders: {\n\t\t\t'OpenAI-Beta': 'assistants=v2',\n\t\t},\n\t});\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAErC,uBAA2B;AAC3B,0BAA6B;AAE7B,MAAM,aAAgC,CAAC,gCAAY;AAEnD,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,iBAAiB;AAAA,IAC7B,UAAU,CAAC,WAAW;AAAA,EACvB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,cAAc,KAAK,iBAAiB,eAAe,GAAG,IAAI,EAAE,cAAc,KAAK,CAAC;AAEtF,QAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,UAAU,eAAe,WAAW,IAAI;AAAA,IACpF,SAAS;AAAA,MACR,eAAe;AAAA,IAChB;AAAA,EACD,CAAC;AAED,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as create from './create.operation';\nimport * as deleteAssistant from './deleteAssistant.operation';\nimport * as list from './list.operation';\nimport * as message from './message.operation';\nimport * as update from './update.operation';\n\nexport { create, deleteAssistant, message, list, update };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Create an Assistant',\n\t\t\t\tvalue: 'create',\n\t\t\t\taction: 'Create an assistant',\n\t\t\t\tdescription: 'Create a new assistant',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Delete an Assistant',\n\t\t\t\tvalue: 'deleteAssistant',\n\t\t\t\taction: 'Delete an assistant',\n\t\t\t\tdescription: 'Delete an assistant from the account',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'List Assistants',\n\t\t\t\tvalue: 'list',\n\t\t\t\taction: 'List assistants',\n\t\t\t\tdescription: 'List assistants in the organization',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Message an Assistant',\n\t\t\t\tvalue: 'message',\n\t\t\t\taction: 'Message an assistant',\n\t\t\t\tdescription: 'Send messages to an assistant',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Update an Assistant',\n\t\t\t\tvalue: 'update',\n\t\t\t\taction: 'Update an assistant',\n\t\t\t\tdescription: 'Update an existing assistant',\n\t\t\t},\n\t\t],\n\t\tdefault: 'message',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['assistant'],\n\t\t\t},\n\t\t},\n\t},\n\n\t...create.description,\n\t...deleteAssistant.description,\n\t...message.description,\n\t...list.description,\n\t...update.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,aAAwB;AACxB,sBAAiC;AACjC,WAAsB;AACtB,cAAyB;AACzB,aAAwB;AAIjB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,WAAW;AAAA,MACvB;AAAA,IACD;AAAA,EACD;AAAA,EAEA,GAAG,OAAO;AAAA,EACV,GAAG,gBAAgB;AAAA,EACnB,GAAG,QAAQ;AAAA,EACX,GAAG,KAAK;AAAA,EACR,GAAG,OAAO;AACX;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/list.operation.ts"],"sourcesContent":["import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Simplify Output',\n\t\tname: 'simplify',\n\t\ttype: 'boolean',\n\t\tdefault: true,\n\t\tdescription: 'Whether to return a simplified version of the response instead of the raw data',\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['list'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst returnData: INodeExecutionData[] = [];\n\n\tlet has_more = true;\n\tlet after: string | undefined;\n\n\tdo {\n\t\tconst response = await apiRequest.call(this, 'GET', '/assistants', {\n\t\t\theaders: {\n\t\t\t\t'OpenAI-Beta': 'assistants=v2',\n\t\t\t},\n\t\t\tqs: {\n\t\t\t\tlimit: 100,\n\t\t\t\tafter,\n\t\t\t},\n\t\t});\n\n\t\tfor (const assistant of response.data || []) {\n\t\t\ttry {\n\t\t\t\tassistant.created_at = new Date(assistant.created_at * 1000).toISOString();\n\t\t\t} catch (error) {}\n\n\t\t\treturnData.push({ json: assistant, pairedItem: { item: i } });\n\t\t}\n\n\t\thas_more = response.has_more;\n\n\t\tif (has_more) {\n\t\t\tafter = response.last_id as string;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t} while (has_more);\n\n\tconst simplify = this.getNodeParameter('simplify', i) as boolean;\n\n\tif (simplify) {\n\t\treturn returnData.map((item) => {\n\t\t\tconst { id, name, model } = item.json;\n\t\t\treturn {\n\t\t\t\tjson: {\n\t\t\t\t\tid,\n\t\t\t\t\tname,\n\t\t\t\t\tmodel,\n\t\t\t\t},\n\t\t\t\tpairedItem: { item: i },\n\t\t\t};\n\t\t});\n\t}\n\n\treturn returnData;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,MAAM;AAAA,IAClB,UAAU,CAAC,WAAW;AAAA,EACvB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,aAAmC,CAAC;AAE1C,MAAI,WAAW;AACf,MAAI;AAEJ,KAAG;AACF,UAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,OAAO,eAAe;AAAA,MAClE,SAAS;AAAA,QACR,eAAe;AAAA,MAChB;AAAA,MACA,IAAI;AAAA,QACH,OAAO;AAAA,QACP;AAAA,MACD;AAAA,IACD,CAAC;AAED,eAAW,aAAa,SAAS,QAAQ,CAAC,GAAG;AAC5C,UAAI;AACH,kBAAU,aAAa,IAAI,KAAK,UAAU,aAAa,GAAI,EAAE,YAAY;AAAA,MAC1E,SAAS,OAAO;AAAA,MAAC;AAEjB,iBAAW,KAAK,EAAE,MAAM,WAAW,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAAA,IAC7D;AAEA,eAAW,SAAS;AAEpB,QAAI,UAAU;AACb,cAAQ,SAAS;AAAA,IAClB,OAAO;AACN;AAAA,IACD;AAAA,EACD,SAAS;AAET,QAAM,WAAW,KAAK,iBAAiB,YAAY,CAAC;AAEpD,MAAI,UAAU;AACb,WAAO,WAAW,IAAI,CAAC,SAAS;AAC/B,YAAM,EAAE,IAAI,MAAM,MAAM,IAAI,KAAK;AACjC,aAAO;AAAA,QACN,MAAM;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,QACA,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AACR;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/message.operation.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { AgentExecutor } from 'langchain/agents';\nimport type { OpenAIToolType } from 'langchain/dist/experimental/openai_assistant/schema';\nimport { OpenAIAssistantRunnable } from 'langchain/experimental/openai_assistant';\nimport type { BufferWindowMemory } from 'langchain/memory';\nimport omit from 'lodash/omit';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeProperties,\n} from 'n8n-workflow';\nimport {\n\tApplicationError,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tupdateDisplayOptions,\n} from 'n8n-workflow';\nimport { OpenAI as OpenAIClient } from 'openai';\n\nimport { promptTypeOptions } from '@utils/descriptions';\nimport { getConnectedTools } from '@utils/helpers';\nimport { getTracingConfig } from '@utils/tracing';\n\nimport { formatToOpenAIAssistantTool, getChatMessages } from '../../helpers/utils';\nimport { assistantRLC } from '../descriptions';\nimport { getProxyAgent } from '@utils/httpProxyAgent';\n\nconst properties: INodeProperties[] = [\n\tassistantRLC,\n\t{\n\t\t...promptTypeOptions,\n\t\tname: 'prompt',\n\t},\n\t{\n\t\tdisplayName: 'Prompt (User Message)',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: 'e.g. Hello, how can you help me?',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tprompt: ['define'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Memory',\n\t\tname: 'memory',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Use memory connector',\n\t\t\t\tvalue: 'connector',\n\t\t\t\tdescription: 'Connect one of the supported memory nodes',\n\t\t\t},\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\tname: 'Use thread ID',\n\t\t\t\tvalue: 'threadId',\n\t\t\t\tdescription: 'Specify the ID of the thread to continue',\n\t\t\t},\n\t\t],\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t},\n\t\t},\n\t\tdefault: 'connector',\n\t},\n\t{\n\t\tdisplayName: 'Thread ID',\n\t\tname: 'threadId',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: '',\n\t\tdescription: 'The ID of the thread to continue, a new thread will be created if not specified',\n\t\thint: 'If the thread ID is empty or undefined a new thread will be created and included in the response',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t\tmemory: ['threadId'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Connect your own custom n8n tools to this node on the canvas',\n\t\tname: 'noticeTools',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\tdescription: 'Additional options to add',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\tname: 'baseURL',\n\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.8 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\tname: 'maxRetries',\n\t\t\t\tdefault: 2,\n\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\tname: 'timeout',\n\t\t\t\tdefault: 10000,\n\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Preserve Original Tools',\n\t\t\t\tname: 'preserveOriginalTools',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to preserve the original tools of the assistant after the execution of this node, otherwise the tools will be replaced with the connected tools, if any, default is true',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['message'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\nconst mapChatMessageToThreadMessage = (\n\tmessage: BaseMessage,\n): OpenAIClient.Beta.Threads.ThreadCreateParams.Message => ({\n\trole: message._getType() === 'ai' ? 'assistant' : 'user',\n\tcontent: message.content.toString(),\n});\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst credentials = await this.getCredentials('openAiApi');\n\tconst nodeVersion = this.getNode().typeVersion;\n\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\n\tlet input;\n\tif (prompt === 'auto') {\n\t\tinput = this.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else {\n\t\tinput = this.getNodeParameter('text', i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tthrow new NodeOperationError(this.getNode(), 'No prompt specified', {\n\t\t\tdescription:\n\t\t\t\t\"Expected to find the prompt in an input field called 'chatInput' (this is what the chat trigger node outputs). To use something else, change the 'Prompt' parameter\",\n\t\t});\n\t}\n\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\n\tconst options = this.getNodeParameter('options', i, {}) as {\n\t\tbaseURL?: string;\n\t\tmaxRetries: number;\n\t\ttimeout: number;\n\t\tpreserveOriginalTools?: boolean;\n\t};\n\n\tconst baseURL = (options.baseURL ?? credentials.url) as string;\n\n\tconst client = new OpenAIClient({\n\t\tapiKey: credentials.apiKey as string,\n\t\tmaxRetries: options.maxRetries ?? 2,\n\t\ttimeout: options.timeout ?? 10000,\n\t\tbaseURL,\n\t\tfetchOptions: {\n\t\t\tdispatcher: getProxyAgent(baseURL),\n\t\t},\n\t});\n\n\tconst agent = new OpenAIAssistantRunnable({ assistantId, client, asAgent: true });\n\n\tconst tools = await getConnectedTools(this, nodeVersion > 1, false);\n\tlet assistantTools;\n\n\tif (tools.length) {\n\t\tconst transformedConnectedTools = tools?.map(formatToOpenAIAssistantTool) ?? [];\n\t\tconst nativeToolsParsed: OpenAIToolType = [];\n\n\t\tassistantTools = (await client.beta.assistants.retrieve(assistantId)).tools;\n\n\t\tconst useCodeInterpreter = assistantTools.some((tool) => tool.type === 'code_interpreter');\n\t\tif (useCodeInterpreter) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'code_interpreter',\n\t\t\t});\n\t\t}\n\n\t\tconst useRetrieval = assistantTools.some((tool) => tool.type === 'file_search');\n\t\tif (useRetrieval) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'file_search',\n\t\t\t});\n\t\t}\n\n\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\ttools: [...nativeToolsParsed, ...transformedConnectedTools],\n\t\t});\n\t}\n\n\tconst agentExecutor = AgentExecutor.fromAgentAndTools({\n\t\tagent,\n\t\ttools: tools ?? [],\n\t});\n\n\tconst useMemoryConnector =\n\t\tnodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector';\n\tconst memory =\n\t\tuseMemoryConnector || nodeVersion < 1.6\n\t\t\t? ((await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BufferWindowMemory\n\t\t\t\t\t| undefined)\n\t\t\t: undefined;\n\n\tconst threadId =\n\t\tnodeVersion >= 1.6 && !useMemoryConnector\n\t\t\t? (this.getNodeParameter('threadId', i) as string)\n\t\t\t: undefined;\n\n\tconst chainValues: IDataObject = {\n\t\tcontent: input,\n\t\tsignal: this.getExecutionCancelSignal(),\n\t\ttimeout: options.timeout ?? 10000,\n\t};\n\tlet thread: OpenAIClient.Beta.Threads.Thread;\n\tif (memory) {\n\t\tconst chatMessages = await getChatMessages(memory);\n\n\t\t// Construct a new thread from the chat history to map the memory\n\t\tif (chatMessages.length) {\n\t\t\tconst first32Messages = chatMessages.slice(0, 32);\n\t\t\t// There is a undocumented limit of 32 messages per thread when creating a thread with messages\n\t\t\tconst mappedMessages: OpenAIClient.Beta.Threads.ThreadCreateParams.Message[] =\n\t\t\t\tfirst32Messages.map(mapChatMessageToThreadMessage);\n\n\t\t\tthread = await client.beta.threads.create({ messages: mappedMessages });\n\t\t\tconst overLimitMessages = chatMessages.slice(32).map(mapChatMessageToThreadMessage);\n\n\t\t\t// Send the remaining messages that exceed the limit of 32 sequentially\n\t\t\tfor (const message of overLimitMessages) {\n\t\t\t\tawait client.beta.threads.messages.create(thread.id, message);\n\t\t\t}\n\n\t\t\tchainValues.threadId = thread.id;\n\t\t}\n\t} else if (threadId) {\n\t\tchainValues.threadId = threadId;\n\t}\n\n\tlet filteredResponse: IDataObject = {};\n\ttry {\n\t\tconst response = await agentExecutor.withConfig(getTracingConfig(this)).invoke(chainValues);\n\t\tif (memory) {\n\t\t\tawait memory.saveContext({ input }, { output: response.output });\n\n\t\t\tif (response.threadId && response.runId) {\n\t\t\t\tconst threadRun = await client.beta.threads.runs.retrieve(response.runId, {\n\t\t\t\t\tthread_id: response.threadId,\n\t\t\t\t});\n\t\t\t\tresponse.usage = threadRun.usage;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\toptions.preserveOriginalTools !== false &&\n\t\t\tnodeVersion >= 1.3 &&\n\t\t\t(assistantTools ?? [])?.length\n\t\t) {\n\t\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\t\ttools: assistantTools,\n\t\t\t});\n\t\t}\n\t\t// Remove configuration properties and runId added by Langchain that are not relevant to the user\n\t\tfilteredResponse = omit(response, ['signal', 'timeout', 'content', 'runId']) as IDataObject;\n\t} catch (error) {\n\t\tif (!(error instanceof ApplicationError)) {\n\t\t\tthrow new NodeOperationError(this.getNode(), error.message, { itemIndex: i });\n\t\t}\n\t}\n\n\treturn [{ json: filteredResponse, pairedItem: { item: i } }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAE9B,8BAAwC;AAExC,kBAAiB;AAOjB,0BAKO;AACP,oBAAuC;AAEvC,0BAAkC;AAClC,qBAAkC;AAClC,qBAAiC;AAEjC,mBAA6D;AAC7D,IAAAA,uBAA6B;AAC7B,4BAA8B;AAE9B,MAAM,aAAgC;AAAA,EACrC;AAAA,EACA;AAAA,IACC,GAAG;AAAA,IACH,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,QAAQ,CAAC,QAAQ;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,aAAa;AAAA,MACd;AAAA,MACA;AAAA;AAAA,QAEC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,MACpC;AAAA,IACD;AAAA,IACA,SAAS;AAAA,EACV;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IAC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AW,WAAW,mBAAmB;AACxC,cAAM,OAAO,KAAK,QAAQ,SAAS,OAAO,OAAO,IAAI,OAAO;AAAA,MAC7D;AAEA,kBAAY,WAAW,OAAO;AAAA,IAC/B;AAAA,EACD,WAAW,UAAU;AACpB,gBAAY,WAAW;AAAA,EACxB;AAEA,MAAI,mBAAgC,CAAC;AACrC,MAAI;AACH,UAAM,WAAW,MAAM,cAAc,eAAW,iCAAiB,IAAI,CAAC,EAAE,OAAO,WAAW;AAC1F,QAAI,QAAQ;AACX,YAAM,OAAO,YAAY,EAAE,MAAM,GAAG,EAAE,QAAQ,SAAS,OAAO,CAAC;AAE/D,UAAI,SAAS,YAAY,SAAS,OAAO;AACxC,cAAM,YAAY,MAAM,OAAO,KAAK,QAAQ,KAAK,SAAS,SAAS,OAAO;AAAA,UACzE,WAAW,SAAS;AAAA,QACrB,CAAC;AACD,iBAAS,QAAQ,UAAU;AAAA,MAC5B;AAAA,IACD;AAEA,QACC,QAAQ,0BAA0B,SAClC,eAAe,QACd,kBAAkB,CAAC,IAAI,QACvB;AACD,YAAM,OAAO,KAAK,WAAW,OAAO,aAAa;AAAA,QAChD,OAAO;AAAA,MACR,CAAC;AAAA,IACF;AAEA,2BAAmB,YAAAC,SAAK,UAAU,CAAC,UAAU,WAAW,WAAW,OAAO,CAAC;AAAA,EAC5E,SAAS,OAAO;AACf,QAAI,EAAE,iBAAiB,uCAAmB;AACzC,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,MAAM,SAAS,EAAE,WAAW,EAAE,CAAC;AAAA,IAC7E;AAAA,EACD;AAEA,SAAO,CAAC,EAAE,MAAM,kBAAkB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAC5D;","names":["import_descriptions","OpenAIClient","omit"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/update.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { ApplicationError, NodeOperationError, updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\nimport { assistantRLC, modelRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [\n\tassistantRLC,\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Code Interpreter',\n\t\t\t\tname: 'codeInterpreter',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to enable the code interpreter that allows the assistants to write and run Python code in a sandboxed execution environment, find more <a href=\"https://platform.openai.com/docs/assistants/tools/code-interpreter\" target=\"_blank\">here</a>',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tdescription: 'The description of the assistant. The maximum length is 512 characters.',\n\t\t\t\tplaceholder: 'e.g. My personal assistant',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options\n\t\t\t\tdisplayName: 'Files',\n\t\t\t\tname: 'file_ids',\n\t\t\t\ttype: 'multiOptions',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-multi-options\n\t\t\t\tdescription:\n\t\t\t\t\t'The files to be used by the assistant, there can be a maximum of 20 files attached to the assistant. You can use expression to pass file IDs as an array or comma-separated string.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsMethod: 'getFiles',\n\t\t\t\t},\n\t\t\t\tdefault: [],\n\t\t\t\thint: \"Add more files by using the 'Upload a File' operation, any existing files not selected here will be removed.\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Instructions',\n\t\t\t\tname: 'instructions',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'The system instructions that the assistant uses. The maximum length is 32768 characters.',\n\t\t\t\tdefault: '',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 2,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Knowledge Retrieval',\n\t\t\t\tname: 'knowledgeRetrieval',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to augments the assistant with knowledge from outside its model, such as proprietary product information or documents, find more <a href=\"https://platform.openai.com/docs/assistants/tools/knowledge-retrieval\" target=\"_blank\">here</a>',\n\t\t\t},\n\t\t\t{ ...modelRLC('modelSearch'), required: false },\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tdescription: 'The name of the assistant. The maximum length is 256 characters.',\n\t\t\t\tplaceholder: 'e.g. My Assistant',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Remove All Custom Tools (Functions)',\n\t\t\t\tname: 'removeCustomTools',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to remove all custom tools (functions) from the assistant',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Output Randomness (Temperature)',\n\t\t\t\tname: 'temperature',\n\t\t\t\tdefault: 1,\n\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive. We generally recommend altering this or temperature but not both.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Output Randomness (Top P)',\n\t\t\t\tname: 'topP',\n\t\t\t\tdefault: 1,\n\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t'An alternative to sampling with temperature, controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['update'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nfunction getFileIds(file_ids: unknown): string[] {\n\tif (Array.isArray(file_ids)) {\n\t\treturn file_ids;\n\t}\n\n\tif (typeof file_ids === 'string') {\n\t\treturn file_ids.split(',').map((file_id) => file_id.trim());\n\t}\n\n\tthrow new ApplicationError('Invalid file_ids type');\n}\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst {\n\t\tmodelId,\n\t\tname,\n\t\tinstructions,\n\t\tcodeInterpreter,\n\t\tknowledgeRetrieval,\n\t\tfile_ids,\n\t\tremoveCustomTools,\n\t\ttemperature,\n\t\ttopP,\n\t} = options;\n\n\tconst assistantDescription = options.description as string;\n\n\tconst body: IDataObject = {};\n\n\tif (file_ids) {\n\t\tconst files = getFileIds(file_ids);\n\t\tif (files.length > 20) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The maximum number of files that can be attached to the assistant is 20',\n\t\t\t\t{ itemIndex: i },\n\t\t\t);\n\t\t}\n\n\t\tbody.tool_resources = {\n\t\t\t...((body.tool_resources as object) ?? {}),\n\t\t\tcode_interpreter: {\n\t\t\t\tfile_ids: files,\n\t\t\t},\n\t\t\t// updating file_ids for file_search directly is not supported by OpenAI API\n\t\t\t// only updating vector_store_ids for file_search is supported\n\t\t\t// support for this to be added as part of ADO-2968\n\t\t\t// https://platform.openai.com/docs/api-reference/assistants/modifyAssistant\n\t\t};\n\t}\n\n\tif (modelId) {\n\t\tbody.model = this.getNodeParameter('options.modelId', i, '', { extractValue: true }) as string;\n\t}\n\n\tif (name) {\n\t\tbody.name = name;\n\t}\n\n\tif (assistantDescription) {\n\t\tbody.description = assistantDescription;\n\t}\n\n\tif (instructions) {\n\t\tbody.instructions = instructions;\n\t}\n\n\tif (temperature) {\n\t\tbody.temperature = temperature;\n\t}\n\n\tif (topP) {\n\t\tbody.topP = topP;\n\t}\n\n\tlet tools =\n\t\t((\n\t\t\tawait apiRequest.call(this, 'GET', `/assistants/${assistantId}`, {\n\t\t\t\theaders: {\n\t\t\t\t\t'OpenAI-Beta': 'assistants=v2',\n\t\t\t\t},\n\t\t\t})\n\t\t).tools as IDataObject[]) || [];\n\n\tif (codeInterpreter && !tools.find((tool) => tool.type === 'code_interpreter')) {\n\t\ttools.push({\n\t\t\ttype: 'code_interpreter',\n\t\t});\n\t}\n\n\tif (codeInterpreter === false && tools.find((tool) => tool.type === 'code_interpreter')) {\n\t\ttools = tools.filter((tool) => tool.type !== 'code_interpreter');\n\t}\n\n\tif (knowledgeRetrieval && !tools.find((tool) => tool.type === 'file_search')) {\n\t\ttools.push({\n\t\t\ttype: 'file_search',\n\t\t});\n\t}\n\n\tif (knowledgeRetrieval === false && tools.find((tool) => tool.type === 'file_search')) {\n\t\ttools = tools.filter((tool) => tool.type !== 'file_search');\n\t}\n\n\tif (removeCustomTools) {\n\t\ttools = tools.filter((tool) => tool.type !== 'function');\n\t}\n\n\tbody.tools = tools;\n\n\tconst response = await apiRequest.call(this, 'POST', `/assistants/${assistantId}`, {\n\t\tbody,\n\t\theaders: {\n\t\t\t'OpenAI-Beta': 'assistants=v2',\n\t\t},\n\t});\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA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I,mBAAmB;AACtB,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,UAAU;AAAA,EACxD;AAEA,OAAK,QAAQ;AAEb,QAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,QAAQ,eAAe,WAAW,IAAI;AAAA,IAClF;AAAA,IACA,SAAS;AAAA,MACR,eAAe;AAAA,IAChB;AAAA,EACD,CAAC;AAED,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/audio/generate.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tIDataObject,\n\tINodeExecutionData,\n} from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Model',\n\t\tname: 'model',\n\t\ttype: 'options',\n\t\tdefault: 'tts-1',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'TTS-1',\n\t\t\t\tvalue: 'tts-1',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'TTS-1-HD',\n\t\t\t\tvalue: 'tts-1-hd',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Text Input',\n\t\tname: 'input',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. The quick brown fox jumped over the lazy dog',\n\t\tdescription: 'The text to generate audio for. The maximum length is 4096 characters.',\n\t\tdefault: '',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Voice',\n\t\tname: 'voice',\n\t\ttype: 'options',\n\t\tdefault: 'alloy',\n\t\tdescription: 'The voice to use when generating the audio',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Alloy',\n\t\t\t\tvalue: 'alloy',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Echo',\n\t\t\t\tvalue: 'echo',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Fable',\n\t\t\t\tvalue: 'fable',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Nova',\n\t\t\t\tvalue: 'nova',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Onyx',\n\t\t\t\tvalue: 'onyx',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Shimmer',\n\t\t\t\tvalue: 'shimmer',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Response Format',\n\t\t\t\tname: 'response_format',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'mp3',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'MP3',\n\t\t\t\t\t\tvalue: 'mp3',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'OPUS',\n\t\t\t\t\t\tvalue: 'opus',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'AAC',\n\t\t\t\t\t\tvalue: 'aac',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'FLAC',\n\t\t\t\t\t\tvalue: 'flac',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Audio Speed',\n\t\t\t\tname: 'speed',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 1,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 0.25,\n\t\t\t\t\tmaxValue: 4,\n\t\t\t\t\tnumberPrecision: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Put Output in Field',\n\t\t\t\tname: 'binaryPropertyOutput',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'data',\n\t\t\t\thint: 'The name of the output field to put the binary file data in',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['generate'],\n\t\tresource: ['audio'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('model', i) as string;\n\tconst input = this.getNodeParameter('input', i) as string;\n\tconst voice = this.getNodeParameter('voice', i) as string;\n\tlet response_format = 'mp3';\n\tlet speed = 1;\n\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tif (options.response_format) {\n\t\tresponse_format = options.response_format as string;\n\t}\n\n\tif (options.speed) {\n\t\tspeed = options.speed as number;\n\t}\n\n\tconst body: IDataObject = {\n\t\tmodel,\n\t\tinput,\n\t\tvoice,\n\t\tresponse_format,\n\t\tspeed,\n\t};\n\n\tconst option = {\n\t\tuseStream: true,\n\t\treturnFullResponse: true,\n\t\tencoding: 'arraybuffer',\n\t\tjson: false,\n\t};\n\n\tconst response = await apiRequest.call(this, 'POST', '/audio/speech', { body, option });\n\n\tconst binaryData = await this.helpers.prepareBinaryData(\n\t\tresponse,\n\t\t`audio.${response_format}`,\n\t\t`audio/${response_format}`,\n\t);\n\n\tconst binaryPropertyOutput = (options.binaryPropertyOutput as string) || 'data';\n\n\tconst newItem: INodeExecutionData = {\n\t\tjson: {\n\t\t\t...binaryData,\n\t\t\tdata: undefined,\n\t\t},\n\t\tpairedItem: { item: i },\n\t\tbinary: {\n\t\t\t[binaryPropertyOutput]: binaryData,\n\t\t},\n\t};\n\n\treturn [newItem];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AA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AA,IACrC;AAAA,IACA,SAAS,eAAe;AAAA,IACxB,SAAS,eAAe;AAAA,EACzB;AAEA,QAAM,uBAAwB,QAAQ,wBAAmC;AAEzE,QAAM,UAA8B;AAAA,IACnC,MAAM;AAAA,MACL,GAAG;AAAA,MACH,MAAM;AAAA,IACP;AAAA,IACA,YAAY,EAAE,MAAM,EAAE;AAAA,IACtB,QAAQ;AAAA,MACP,CAAC,oBAAoB,GAAG;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,CAAC,OAAO;AAChB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/audio/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as generate from './generate.operation';\nimport * as transcribe from './transcribe.operation';\nimport * as translate from './translate.operation';\n\nexport { generate, transcribe, translate };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Generate Audio',\n\t\t\t\tvalue: 'generate',\n\t\t\t\taction: 'Generate audio',\n\t\t\t\tdescription: 'Creates audio from a text prompt',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Transcribe a Recording',\n\t\t\t\tvalue: 'transcribe',\n\t\t\t\taction: 'Transcribe a recording',\n\t\t\t\tdescription: 'Transcribes audio into the text',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Translate a Recording',\n\t\t\t\tvalue: 'translate',\n\t\t\t\taction: 'Translate a recording',\n\t\t\t\tdescription: 'Translate audio into the text in the english language',\n\t\t\t},\n\t\t],\n\t\tdefault: 'generate',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['audio'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'OpenAI API limits the size of the audio file to 25 MB',\n\t\tname: 'fileSizeLimitNotice',\n\t\ttype: 'notice',\n\t\tdefault: ' ',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['audio'],\n\t\t\t\toperation: ['translate', 'transcribe'],\n\t\t\t},\n\t\t},\n\t},\n\t...generate.description,\n\t...transcribe.description,\n\t...translate.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAA0B;AAC1B,iBAA4B;AAC5B,gBAA2B;AAIpB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,OAAO;AAAA,MACnB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,OAAO;AAAA,QAClB,WAAW,CAAC,aAAa,YAAY;AAAA,MACtC;AAAA,IACD;AAAA,EACD;AAAA,EACA,GAAG,SAAS;AAAA,EACZ,GAAG,WAAW;AAAA,EACd,GAAG,UAAU;AACd;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/audio/transcribe.operation.ts"],"sourcesContent":["import FormData from 'form-data';\nimport type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { getBinaryDataFile } from '../../helpers/binary-data';\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Input Data Field Name',\n\t\tname: 'binaryPropertyName',\n\t\ttype: 'string',\n\t\tdefault: 'data',\n\t\tplaceholder: 'e.g. data',\n\t\thint: 'The name of the input field containing the binary file data to be processed',\n\t\tdescription:\n\t\t\t'Name of the binary property which contains the audio file in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Language of the Audio File',\n\t\t\t\tname: 'language',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'The language of the input audio. Supplying the input language in <a href=\"https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes\" target=\"_blank\">ISO-639-1</a> format will improve accuracy and latency.',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Output Randomness (Temperature)',\n\t\t\t\tname: 'temperature',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 0,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 0,\n\t\t\t\t\tmaxValue: 1,\n\t\t\t\t\tnumberPrecision: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['transcribe'],\n\t\tresource: ['audio'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = 'whisper-1';\n\tconst binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst formData = new FormData();\n\n\tformData.append('model', model);\n\n\tif (options.language) {\n\t\tformData.append('language', options.language);\n\t}\n\n\tif (options.temperature) {\n\t\tformData.append('temperature', options.temperature.toString());\n\t}\n\n\tconst { filename, contentType, fileContent } = await getBinaryDataFile(\n\t\tthis,\n\t\ti,\n\t\tbinaryPropertyName,\n\t);\n\tformData.append('file', fileContent, {\n\t\tfilename,\n\t\tcontentType,\n\t});\n\n\tconst response = await apiRequest.call(this, 'POST', '/audio/transcriptions', {\n\t\toption: { formData },\n\t\theaders: formData.getHeaders(),\n\t});\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqB;AAErB,0BAAqC;AAErC,yBAAkC;AAClC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aACC;AAAA,EACF;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aACC;AAAA,QACD,SAAS;AAAA,MACV;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,UACZ,UAAU;AAAA,UACV,UAAU;AAAA,UACV,iBAAiB;AAAA,QAClB;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,YAAY;AAAA,IACxB,UAAU,CAAC,OAAO;AAAA,EACnB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,QAAQ;AACd,QAAM,qBAAqB,KAAK,iBAAiB,sBAAsB,CAAC;AACxE,QAAM,UAAU,KAAK,iBAAiB,WAAW,GAAG,CAAC,CAAC;AAEtD,QAAM,WAAW,IAAI,iBAAAA,QAAS;AAE9B,WAAS,OAAO,SAAS,KAAK;AAE9B,MAAI,QAAQ,UAAU;AACrB,aAAS,OAAO,YAAY,QAAQ,QAAQ;AAAA,EAC7C;AAEA,MAAI,QAAQ,aAAa;AACxB,aAAS,OAAO,eAAe,QAAQ,YAAY,SAAS,CAAC;AAAA,EAC9D;AAEA,QAAM,EAAE,UAAU,aAAa,YAAY,IAAI,UAAM;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,WAAS,OAAO,QAAQ,aAAa;AAAA,IACpC;AAAA,IACA;AAAA,EACD,CAAC;AAED,QAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,QAAQ,yBAAyB;AAAA,IAC7E,QAAQ,EAAE,SAAS;AAAA,IACnB,SAAS,SAAS,WAAW;AAAA,EAC9B,CAAC;AAED,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":["FormData"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/audio/translate.operation.ts"],"sourcesContent":["import FormData from 'form-data';\nimport type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { getBinaryDataFile } from '../../helpers/binary-data';\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Input Data Field Name',\n\t\tname: 'binaryPropertyName',\n\t\ttype: 'string',\n\t\tdefault: 'data',\n\t\thint: 'The name of the input field containing the binary file data to be processed',\n\t\tplaceholder: 'e.g. data',\n\t\tdescription:\n\t\t\t'Name of the binary property which contains the audio file in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Output Randomness (Temperature)',\n\t\t\t\tname: 'temperature',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 0,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 0,\n\t\t\t\t\tmaxValue: 1,\n\t\t\t\t\tnumberPrecision: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['translate'],\n\t\tresource: ['audio'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = 'whisper-1';\n\tconst binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst formData = new FormData();\n\n\tformData.append('model', model);\n\n\tif (options.temperature) {\n\t\tformData.append('temperature', options.temperature.toString());\n\t}\n\n\tconst { filename, contentType, fileContent } = await getBinaryDataFile(\n\t\tthis,\n\t\ti,\n\t\tbinaryPropertyName,\n\t);\n\tformData.append('file', fileContent, {\n\t\tfilename,\n\t\tcontentType,\n\t});\n\n\tconst response = await apiRequest.call(this, 'POST', '/audio/translations', {\n\t\toption: { formData },\n\t\theaders: formData.getHeaders(),\n\t});\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\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A,EACD,CAAC;AAED,QAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,QAAQ,uBAAuB;AAAA,IAC3E,QAAQ,EAAE,SAAS;AAAA,IACnB,SAAS,SAAS,WAAW;AAAA,EAC9B,CAAC;AAED,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":["FormData"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/vendors/OpenAi/actions/descriptions.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nexport const modelRLC = (searchListMethod: string = 'modelSearch'): INodeProperties => ({\n\tdisplayName: 'Model',\n\tname: 'modelId',\n\ttype: 'resourceLocator',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod,\n\t\t\t\tsearchable: true,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'ID',\n\t\t\tname: 'id',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. gpt-4',\n\t\t},\n\t],\n});\n\nexport const assistantRLC: INodeProperties = {\n\tdisplayName: 'Assistant',\n\tname: 'assistantId',\n\ttype: 'resourceLocator',\n\tdescription:\n\t\t'Assistant to respond to the message. You can add, modify or remove assistants in the <a href=\"https://platform.openai.com/playground?mode=assistant\" target=\"_blank\">playground</a>.',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod: 'assistantSearch',\n\t\t\t\tsearchable: true,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'ID',\n\t\t\tname: 'id',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. asst_abc123',\n\t\t},\n\t],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,WAAW,CAAC,mBAA2B,mBAAoC;AAAA,EACvF,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS,EAAE,MAAM,QAAQ,OAAO,GAAG;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,IACN;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,QACZ;AAAA,QACA,YAAY;AAAA,MACb;AAAA,IACD;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AACD;AAEO,MAAM,eAAgC;AAAA,EAC5C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aACC;AAAA,EACD,SAAS,EAAE,MAAM,QAAQ,OAAO,GAAG;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,IACN;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,QACZ,kBAAkB;AAAA,QAClB,YAAY;AAAA,MACb;AAAA,IACD;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/file/deleteFile.operation.ts"],"sourcesContent":["import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'File',\n\t\tname: 'fileId',\n\t\ttype: 'resourceLocator',\n\t\tdefault: { mode: 'list', value: '' },\n\t\trequired: true,\n\t\tmodes: [\n\t\t\t{\n\t\t\t\tdisplayName: 'From List',\n\t\t\t\tname: 'list',\n\t\t\t\ttype: 'list',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tsearchListMethod: 'fileSearch',\n\t\t\t\t\tsearchable: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'ID',\n\t\t\t\tname: 'id',\n\t\t\t\ttype: 'string',\n\t\t\t\tvalidation: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tregex: 'file-[a-zA-Z0-9]',\n\t\t\t\t\t\t\terrorMessage: 'Not a valid File ID',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tplaceholder: 'e.g. file-1234567890',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['deleteFile'],\n\t\tresource: ['file'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst fileId = this.getNodeParameter('fileId', i, '', { extractValue: true });\n\n\tconst response = await apiRequest.call(this, 'DELETE', `/files/${fileId}`);\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS,EAAE,MAAM,QAAQ,OAAO,GAAG;AAAA,IACnC,UAAU;AAAA,IACV,OAAO;AAAA,MACN;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa;AAAA,UACZ,kBAAkB;AAAA,UAClB,YAAY;AAAA,QACb;AAAA,MACD;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,YAAY;AAAA,UACX;AAAA,YACC,MAAM;AAAA,YACN,YAAY;AAAA,cACX,OAAO;AAAA,cACP,cAAc;AAAA,YACf;AAAA,UACD;AAAA,QACD;AAAA,QACA,aAAa;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,YAAY;AAAA,IACxB,UAAU,CAAC,MAAM;AAAA,EAClB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,SAAS,KAAK,iBAAiB,UAAU,GAAG,IAAI,EAAE,cAAc,KAAK,CAAC;AAE5E,QAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,UAAU,UAAU,MAAM,EAAE;AAEzE,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/file/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as deleteFile from './deleteFile.operation';\nimport * as list from './list.operation';\nimport * as upload from './upload.operation';\n\nexport { upload, deleteFile, list };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Delete a File',\n\t\t\t\tvalue: 'deleteFile',\n\t\t\t\taction: 'Delete a file',\n\t\t\t\tdescription: 'Delete a file from the server',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'List Files',\n\t\t\t\tvalue: 'list',\n\t\t\t\taction: 'List files',\n\t\t\t\tdescription: \"Returns a list of files that belong to the user's organization\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Upload a File',\n\t\t\t\tvalue: 'upload',\n\t\t\t\taction: 'Upload a file',\n\t\t\t\tdescription: 'Upload a file that can be used across various endpoints',\n\t\t\t},\n\t\t],\n\t\tdefault: 'upload',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['file'],\n\t\t\t},\n\t\t},\n\t},\n\n\t...upload.description,\n\t...deleteFile.description,\n\t...list.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAA4B;AAC5B,WAAsB;AACtB,aAAwB;AAIjB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,MAAM;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EAEA,GAAG,OAAO;AAAA,EACV,GAAG,WAAW;AAAA,EACd,GAAG,KAAK;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/file/list.operation.ts"],"sourcesContent":["import type {\n\tIDataObject,\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n} from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Purpose',\n\t\t\t\tname: 'purpose',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'any',\n\t\t\t\tdescription: 'Only return files with the given purpose',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Any [Default]',\n\t\t\t\t\t\tvalue: 'any',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Assistants',\n\t\t\t\t\t\tvalue: 'assistants',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Fine-Tune',\n\t\t\t\t\t\tvalue: 'fine-tune',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['list'],\n\t\tresource: ['file'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst options = this.getNodeParameter('options', i, {});\n\tconst qs: IDataObject = {};\n\n\tif (options.purpose && options.purpose !== 'any') {\n\t\tqs.purpose = options.purpose as string;\n\t}\n\n\tconst { data } = await apiRequest.call(this, 'GET', '/files', { qs });\n\n\treturn (data || []).map((file: IDataObject) => ({\n\t\tjson: file,\n\t\tpairedItem: { item: i },\n\t}));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,QACb,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,MAAM;AAAA,IAClB,UAAU,CAAC,MAAM;AAAA,EAClB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,UAAU,KAAK,iBAAiB,WAAW,GAAG,CAAC,CAAC;AACtD,QAAM,KAAkB,CAAC;AAEzB,MAAI,QAAQ,WAAW,QAAQ,YAAY,OAAO;AACjD,OAAG,UAAU,QAAQ;AAAA,EACtB;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,4BAAW,KAAK,MAAM,OAAO,UAAU,EAAE,GAAG,CAAC;AAEpE,UAAQ,QAAQ,CAAC,GAAG,IAAI,CAAC,UAAuB;AAAA,IAC/C,MAAM;AAAA,IACN,YAAY,EAAE,MAAM,EAAE;AAAA,EACvB,EAAE;AACH;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/file/upload.operation.ts"],"sourcesContent":["import FormData from 'form-data';\nimport type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions, NodeOperationError } from 'n8n-workflow';\n\nimport { getBinaryDataFile } from '../../helpers/binary-data';\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Input Data Field Name',\n\t\tname: 'binaryPropertyName',\n\t\ttype: 'string',\n\t\tdefault: 'data',\n\t\thint: 'The name of the input field containing the binary file data to be processed',\n\t\tplaceholder: 'e.g. data',\n\t\tdescription:\n\t\t\t'Name of the binary property which contains the file. The size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants.',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Purpose',\n\t\t\t\tname: 'purpose',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'assistants',\n\t\t\t\tdescription:\n\t\t\t\t\t\"The intended purpose of the uploaded file, the 'Fine-tuning' only supports .jsonl files\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Assistants',\n\t\t\t\t\t\tvalue: 'assistants',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Fine-Tune',\n\t\t\t\t\t\tvalue: 'fine-tune',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['upload'],\n\t\tresource: ['file'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst formData = new FormData();\n\n\tformData.append('purpose', options.purpose || 'assistants');\n\n\tconst { filename, contentType, fileContent } = await getBinaryDataFile(\n\t\tthis,\n\t\ti,\n\t\tbinaryPropertyName,\n\t);\n\tformData.append('file', fileContent, {\n\t\tfilename,\n\t\tcontentType,\n\t});\n\n\ttry {\n\t\tconst response = await apiRequest.call(this, 'POST', '/files', {\n\t\t\toption: { formData },\n\t\t\theaders: formData.getHeaders(),\n\t\t});\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tjson: response,\n\t\t\t\tpairedItem: { item: i },\n\t\t\t},\n\t\t];\n\t} catch (error) {\n\t\tif (\n\t\t\terror.message.includes('Bad request') &&\n\t\t\terror.description?.includes('Expected file to have JSONL format')\n\t\t) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'The file content is not in JSONL format', {\n\t\t\t\tdescription:\n\t\t\t\t\t'Fine-tuning accepts only files in JSONL format, where every line is a valid JSON dictionary',\n\t\t\t});\n\t\t}\n\t\tthrow error;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqB;AAErB,0BAAyD;AAEzD,yBAAkC;AAClC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aACC;AAAA,EACF;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aACC;AAAA,QACD,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,QAAQ;AAAA,IACpB,UAAU,CAAC,MAAM;AAAA,EAClB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,qBAAqB,KAAK,iBAAiB,sBAAsB,CAAC;AACxE,QAAM,UAAU,KAAK,iBAAiB,WAAW,GAAG,CAAC,CAAC;AAEtD,QAAM,WAAW,IAAI,iBAAAA,QAAS;AAE9B,WAAS,OAAO,WAAW,QAAQ,WAAW,YAAY;AAE1D,QAAM,EAAE,UAAU,aAAa,YAAY,IAAI,UAAM;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,WAAS,OAAO,QAAQ,aAAa;AAAA,IACpC;AAAA,IACA;AAAA,EACD,CAAC;AAED,MAAI;AACH,UAAM,WAAW,MAAM,4BAAW,KAAK,MAAM,QAAQ,UAAU;AAAA,MAC9D,QAAQ,EAAE,SAAS;AAAA,MACnB,SAAS,SAAS,WAAW;AAAA,IAC9B,CAAC;AAED,WAAO;AAAA,MACN;AAAA,QACC,MAAM;AAAA,QACN,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB;AAAA,IACD;AAAA,EACD,SAAS,OAAO;AACf,QACC,MAAM,QAAQ,SAAS,aAAa,KACpC,MAAM,aAAa,SAAS,oCAAoC,GAC/D;AACD,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,2CAA2C;AAAA,QACvF,aACC;AAAA,MACF,CAAC;AAAA,IACF;AACA,UAAM;AAAA,EACP;AACD;","names":["FormData"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/image/analyze.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { updateDisplayOptions, NodeOperationError } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\nimport { modelRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\t...modelRLC('imageModelSearch'),\n\t\tdisplayOptions: { show: { '@version': [{ _cnd: { gte: 1.4 } }] } },\n\t},\n\t{\n\t\tdisplayName: 'Text Input',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tplaceholder: \"e.g. What's in this image?\",\n\t\tdefault: \"What's in this image?\",\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Input Type',\n\t\tname: 'inputType',\n\t\ttype: 'options',\n\t\tdefault: 'url',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Image URL(s)',\n\t\t\t\tvalue: 'url',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Binary File(s)',\n\t\t\t\tvalue: 'base64',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'URL(s)',\n\t\tname: 'imageUrls',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. https://example.com/image.jpeg',\n\t\tdescription: 'URL(s) of the image(s) to analyze, multiple URLs can be added separated by comma',\n\t\tdefault: '',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tinputType: ['url'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Input Data Field Name',\n\t\tname: 'binaryPropertyName',\n\t\ttype: 'string',\n\t\tdefault: 'data',\n\t\tplaceholder: 'e.g. data',\n\t\thint: 'The name of the input field containing the binary file data to be processed',\n\t\tdescription: 'Name of the binary property which contains the image(s)',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tinputType: ['base64'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Simplify Output',\n\t\tname: 'simplify',\n\t\ttype: 'boolean',\n\t\tdefault: true,\n\t\tdescription: 'Whether to simplify the response or not',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Detail',\n\t\t\t\tname: 'detail',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'auto',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Auto',\n\t\t\t\t\t\tvalue: 'auto',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Model will look at the image input size and decide if it should use the low or high setting',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Low',\n\t\t\t\t\t\tvalue: 'low',\n\t\t\t\t\t\tdescription: 'Return faster responses and consume fewer tokens',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'High',\n\t\t\t\t\t\tvalue: 'high',\n\t\t\t\t\t\tdescription: 'Return more detailed responses, consumes more tokens',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Length of Description (Max Tokens)',\n\t\t\t\tdescription: 'Fewer tokens will result in shorter, less detailed image description',\n\t\t\t\tname: 'maxTokens',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 300,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['analyze'],\n\t\tresource: ['image'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tlet model = 'gpt-4-vision-preview';\n\tif (this.getNode().typeVersion >= 1.4) {\n\t\tmodel = this.getNodeParameter('modelId', i, 'gpt-4o', { extractValue: true }) as string;\n\t}\n\n\tconst text = this.getNodeParameter('text', i, '') as string;\n\tconst inputType = this.getNodeParameter('inputType', i) as string;\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst content: IDataObject[] = [\n\t\t{\n\t\t\ttype: 'text',\n\t\t\ttext,\n\t\t},\n\t];\n\n\tconst detail = (options.detail as string) || 'auto';\n\n\tif (inputType === 'url') {\n\t\tconst imageUrls = (this.getNodeParameter('imageUrls', i) as string)\n\t\t\t.split(',')\n\t\t\t.map((url) => url.trim());\n\n\t\tfor (const url of imageUrls) {\n\t\t\tcontent.push({\n\t\t\t\ttype: 'image_url',\n\t\t\t\timage_url: {\n\t\t\t\t\turl,\n\t\t\t\t\tdetail,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t} else {\n\t\tconst binaryPropertyName = this.getNodeParameter('binaryPropertyName', i)\n\t\t\t.split(',')\n\t\t\t.map((propertyName) => propertyName.trim());\n\n\t\tfor (const propertyName of binaryPropertyName) {\n\t\t\tconst binaryData = this.helpers.assertBinaryData(i, propertyName);\n\n\t\t\tlet fileBase64;\n\t\t\tif (binaryData.id) {\n\t\t\t\tconst chunkSize = 256 * 1024;\n\t\t\t\tconst stream = await this.helpers.getBinaryStream(binaryData.id, chunkSize);\n\t\t\t\tconst buffer = await this.helpers.binaryToBuffer(stream);\n\t\t\t\tfileBase64 = buffer.toString('base64');\n\t\t\t} else {\n\t\t\t\tfileBase64 = binaryData.data;\n\t\t\t}\n\n\t\t\tif (!binaryData) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'No binary data exists on item!');\n\t\t\t}\n\n\t\t\tcontent.push({\n\t\t\t\ttype: 'image_url',\n\t\t\t\timage_url: {\n\t\t\t\t\turl: `data:${binaryData.mimeType};base64,${fileBase64}`,\n\t\t\t\t\tdetail,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\tconst body = {\n\t\tmodel,\n\t\tmessages: [\n\t\t\t{\n\t\t\t\trole: 'user',\n\t\t\t\tcontent,\n\t\t\t},\n\t\t],\n\t\tmax_tokens: (options.maxTokens as number) || 300,\n\t};\n\n\tlet response = await apiRequest.call(this, 'POST', '/chat/completions', { body });\n\n\tconst simplify = this.getNodeParameter('simplify', i) as boolean;\n\n\tif (simplify && response.choices) {\n\t\tresponse = { content: response.choices[0].message.content };\n\t}\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAyD;AAEzD,uBAA2B;AAC3B,0BAAyB;AAEzB,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,OAAG,8BAAS,kBAAkB;AAAA,IAC9B,gBAAgB,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,EAAE;AAAA,EAClE;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,WAAW,CAAC,KAAK;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,WAAW,CAAC,QAAQ;AAAA,MACrB;AAAA,IAC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AAQ,aAAwB;AAAA,EAC9C;AAEA,MAAI,WAAW,MAAM,4BAAW,KAAK,MAAM,QAAQ,qBAAqB,EAAE,KAAK,CAAC;AAEhF,QAAM,WAAW,KAAK,iBAAiB,YAAY,CAAC;AAEpD,MAAI,YAAY,SAAS,SAAS;AACjC,eAAW,EAAE,SAAS,SAAS,QAAQ,CAAC,EAAE,QAAQ,QAAQ;AAAA,EAC3D;AAEA,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/image/generate.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Model',\n\t\tname: 'model',\n\t\ttype: 'options',\n\t\tdefault: 'dall-e-3',\n\t\tdescription: 'The model to use for image generation',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'DALL·E 2',\n\t\t\t\tvalue: 'dall-e-2',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'DALL·E 3',\n\t\t\t\tvalue: 'dall-e-3',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'GPT Image 1',\n\t\t\t\tvalue: 'gpt-image-1',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Prompt',\n\t\tname: 'prompt',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. A cute cat eating a dinosaur',\n\t\tdescription:\n\t\t\t'A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.',\n\t\tdefault: '',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Number of Images',\n\t\t\t\tname: 'n',\n\t\t\t\tdefault: 1,\n\t\t\t\tdescription: 'Number of images to generate',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t\tmaxValue: 10,\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Quality',\n\t\t\t\tname: 'dalleQuality',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The quality of the image that will be generated, HD creates images with finer details and greater consistency across the image',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'HD',\n\t\t\t\t\t\tvalue: 'hd',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Standard',\n\t\t\t\t\t\tvalue: 'standard',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'standard',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Quality',\n\t\t\t\tname: 'quality',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The quality of the image that will be generated, High creates images with finer details and greater consistency across the image',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'High',\n\t\t\t\t\t\tvalue: 'high',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Medium',\n\t\t\t\t\t\tvalue: 'medium',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Low',\n\t\t\t\t\t\tvalue: 'low',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'medium',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '256x256',\n\t\t\t\t\t\tvalue: '256x256',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '512x512',\n\t\t\t\t\t\tvalue: '512x512',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1792x1024',\n\t\t\t\t\t\tvalue: '1792x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1792',\n\t\t\t\t\t\tvalue: '1024x1792',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1536',\n\t\t\t\t\t\tvalue: '1024x1536',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1536x1024',\n\t\t\t\t\t\tvalue: '1536x1024',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Style',\n\t\t\t\tname: 'style',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Natural',\n\t\t\t\t\t\tvalue: 'natural',\n\t\t\t\t\t\tdescription: 'Produce more natural looking images',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Vivid',\n\t\t\t\t\t\tvalue: 'vivid',\n\t\t\t\t\t\tdescription: 'Lean towards generating hyper-real and dramatic images',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'vivid',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Respond with Image URL(s)',\n\t\t\t\tname: 'returnImageUrls',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to return image URL(s) instead of binary file(s)',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Put Output in Field',\n\t\t\t\tname: 'binaryPropertyOutput',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'data',\n\t\t\t\thint: 'The name of the output field to put the binary file data in',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\treturnImageUrls: [false],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['generate'],\n\t\tresource: ['image'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('model', i) as string;\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\tconst options = this.getNodeParameter('options', i, {});\n\tlet response_format = 'b64_json';\n\tlet binaryPropertyOutput = 'data';\n\n\tif (options.returnImageUrls) {\n\t\tresponse_format = 'url';\n\t}\n\n\tif (options.binaryPropertyOutput) {\n\t\tbinaryPropertyOutput = options.binaryPropertyOutput as string;\n\t\tdelete options.binaryPropertyOutput;\n\t}\n\n\tif (options.dalleQuality) {\n\t\toptions.quality = options.dalleQuality;\n\t\tdelete options.dalleQuality;\n\t}\n\n\tdelete options.returnImageUrls;\n\tconst body: IDataObject = {\n\t\tprompt,\n\t\tmodel,\n\t\tresponse_format: model !== 'gpt-image-1' ? response_format : undefined, // gpt-image-1 does not support response_format\n\t\t...options,\n\t};\n\n\tconst { data } = await apiRequest.call(this, 'POST', '/images/generations', { body });\n\tif (response_format === 'url') {\n\t\treturn ((data as IDataObject[]) || []).map((entry) => ({\n\t\t\tjson: entry,\n\t\t\tpairedItem: { item: i },\n\t\t}));\n\t} else {\n\t\tconst returnData: INodeExecutionData[] = [];\n\n\t\tfor (const entry of data) {\n\t\t\tconst binaryData = await this.helpers.prepareBinaryData(\n\t\t\t\tBuffer.from(entry.b64_json as string, 'base64'),\n\t\t\t\t'data',\n\t\t\t);\n\t\t\treturnData.push({\n\t\t\t\tjson: Object.assign({}, binaryData, {\n\t\t\t\t\tdata: undefined,\n\t\t\t\t}),\n\t\t\t\tbinary: {\n\t\t\t\t\t[binaryPropertyOutput]: binaryData,\n\t\t\t\t},\n\t\t\t\tpairedItem: { item: i },\n\t\t\t});\n\t\t}\n\n\t\treturn returnData;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aACC;AAAA,IACD,SAAS;AAAA,IACT,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,QACb,MAAM;AAAA,QACN,aAAa;AAAA,UACZ,UAAU;AAAA,UACV,UAAU;AAAA,QACX;AAAA,QACA,gB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AAE1C,eAAW,SAAS,MAAM;AACzB,YAAM,aAAa,MAAM,KAAK,QAAQ;AAAA,QACrC,OAAO,KAAK,MAAM,UAAoB,QAAQ;AAAA,QAC9C;AAAA,MACD;AACA,iBAAW,KAAK;AAAA,QACf,MAAM,OAAO,OAAO,CAAC,GAAG,YAAY;AAAA,UACnC,MAAM;AAAA,QACP,CAAC;AAAA,QACD,QAAQ;AAAA,UACP,CAAC,oBAAoB,GAAG;AAAA,QACzB;AAAA,QACA,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/image/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as analyze from './analyze.operation';\nimport * as generate from './generate.operation';\n\nexport { generate, analyze };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Analyze Image',\n\t\t\t\tvalue: 'analyze',\n\t\t\t\taction: 'Analyze image',\n\t\t\t\tdescription: 'Take in images and answer questions about them',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Generate an Image',\n\t\t\t\tvalue: 'generate',\n\t\t\t\taction: 'Generate an image',\n\t\t\t\tdescription: 'Creates an image from a text prompt',\n\t\t\t},\n\t\t],\n\t\tdefault: 'generate',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['image'],\n\t\t\t},\n\t\t},\n\t},\n\t...generate.description,\n\t...analyze.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,cAAyB;AACzB,eAA0B;AAInB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,OAAO;AAAA,MACnB;AAAA,IACD;AAAA,EACD;AAAA,EACA,GAAG,SAAS;AAAA,EACZ,GAAG,QAAQ;AACZ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/vendors/OpenAi/actions/node.type.ts"],"sourcesContent":["import type { AllEntities } from 'n8n-workflow';\n\ntype NodeMap = {\n\tassistant: 'message' | 'create' | 'deleteAssistant' | 'list' | 'update';\n\taudio: 'generate' | 'transcribe' | 'translate';\n\tfile: 'upload' | 'deleteFile' | 'list';\n\timage: 'generate' | 'analyze';\n\ttext: 'message' | 'classify';\n};\n\nexport type OpenAiType = AllEntities<NodeMap>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/vendors/OpenAi/actions/router.ts"],"sourcesContent":["import {\n\tNodeOperationError,\n\ttype IExecuteFunctions,\n\ttype INodeExecutionData,\n\tNodeApiError,\n} from 'n8n-workflow';\n\nimport * as assistant from './assistant';\nimport * as audio from './audio';\nimport * as file from './file';\nimport * as image from './image';\nimport type { OpenAiType } from './node.type';\nimport * as text from './text';\nimport { getCustomErrorMessage } from '../helpers/error-handling';\n\nexport async function router(this: IExecuteFunctions) {\n\tconst returnData: INodeExecutionData[] = [];\n\n\tconst items = this.getInputData();\n\tconst resource = this.getNodeParameter<OpenAiType>('resource', 0);\n\tconst operation = this.getNodeParameter('operation', 0);\n\n\tconst openAiTypeData = {\n\t\tresource,\n\t\toperation,\n\t} as OpenAiType;\n\n\tlet execute;\n\tswitch (openAiTypeData.resource) {\n\t\tcase 'assistant':\n\t\t\texecute = assistant[openAiTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'audio':\n\t\t\texecute = audio[openAiTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'file':\n\t\t\texecute = file[openAiTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'image':\n\t\t\texecute = image[openAiTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'text':\n\t\t\texecute = text[openAiTypeData.operation].execute;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`The operation \"${operation}\" is not supported!`,\n\t\t\t);\n\t}\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\ttry {\n\t\t\tconst responseData = await execute.call(this, i);\n\n\t\t\treturnData.push(...responseData);\n\t\t} catch (error) {\n\t\t\tif (this.continueOnFail()) {\n\t\t\t\treturnData.push({ json: { error: error.message }, pairedItem: { item: i } });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (error instanceof NodeApiError) {\n\t\t\t\t// If the error is a rate limit error, we want to handle it differently\n\t\t\t\tconst errorCode: string | undefined = (error.cause as any)?.error?.error?.code;\n\t\t\t\tif (errorCode) {\n\t\t\t\t\tconst customErrorMessage = getCustomErrorMessage(errorCode);\n\t\t\t\t\tif (customErrorMessage) {\n\t\t\t\t\t\terror.message = customErrorMessage;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\terror.context = {\n\t\t\t\t\titemIndex: i,\n\t\t\t\t};\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(this.getNode(), error, {\n\t\t\t\titemIndex: i,\n\t\t\t\tdescription: error.description,\n\t\t\t});\n\t\t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OAAe,OAAO,OAAO;AAC1E,YAAI,WAAW;AACd,gBAAM,yBAAqB,6CAAsB,SAAS;AAC1D,cAAI,oBAAoB;AACvB,kBAAM,UAAU;AAAA,UACjB;AAAA,QACD;AAEA,cAAM,UAAU;AAAA,UACf,WAAW;AAAA,QACZ;AAEA,cAAM;AAAA,MACP;AAEA,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,OAAO;AAAA,QACnD,WAAW;AAAA,QACX,aAAa,MAAM;AAAA,MACpB,CAAC;AAAA,IACF;AAAA,EACD;AAEA,SAAO,CAAC,UAAU;AACnB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/text/classify.operation.ts"],"sourcesContent":["import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Text Input',\n\t\tname: 'input',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. Sample text goes here',\n\t\tdescription: 'The input text to classify if it is violates the moderation policy',\n\t\tdefault: '',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Simplify Output',\n\t\tname: 'simplify',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription: 'Whether to return a simplified version of the response instead of the raw data',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Use Stable Model',\n\t\t\t\tname: 'useStableModel',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to use the stable version of the model instead of the latest version, accuracy may be slightly lower',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['classify'],\n\t\tresource: ['text'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst input = this.getNodeParameter('input', i) as string;\n\tconst options = this.getNodeParameter('options', i);\n\tconst model = options.useStableModel ? 'text-moderation-stable' : 'text-moderation-latest';\n\n\tconst body = {\n\t\tinput,\n\t\tmodel,\n\t};\n\n\tconst { results } = await apiRequest.call(this, 'POST', '/moderations', { body });\n\n\tif (!results) return [];\n\n\tconst simplify = this.getNodeParameter('simplify', i) as boolean;\n\n\tif (simplify && results) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tjson: { flagged: results[0].flagged },\n\t\t\t\tpairedItem: { item: i },\n\t\t\t},\n\t\t];\n\t} else {\n\t\treturn [\n\t\t\t{\n\t\t\t\tjson: results[0],\n\t\t\t\tpairedItem: { item: i },\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,SAAS;AAAA,IACT,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aACC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,UAAU;AAAA,IACtB,UAAU,CAAC,MAAM;AAAA,EAClB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,QAAQ,KAAK,iBAAiB,SAAS,CAAC;AAC9C,QAAM,UAAU,KAAK,iBAAiB,WAAW,CAAC;AAClD,QAAM,QAAQ,QAAQ,iBAAiB,2BAA2B;AAElE,QAAM,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,EACD;AAEA,QAAM,EAAE,QAAQ,IAAI,MAAM,4BAAW,KAAK,MAAM,QAAQ,gBAAgB,EAAE,KAAK,CAAC;AAEhF,MAAI,CAAC,QAAS,QAAO,CAAC;AAEtB,QAAM,WAAW,KAAK,iBAAiB,YAAY,CAAC;AAEpD,MAAI,YAAY,SAAS;AACxB,WAAO;AAAA,MACN;AAAA,QACC,MAAM,EAAE,SAAS,QAAQ,CAAC,EAAE,QAAQ;AAAA,QACpC,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB;AAAA,IACD;AAAA,EACD,OAAO;AACN,WAAO;AAAA,MACN;AAAA,QACC,MAAM,QAAQ,CAAC;AAAA,QACf,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/text/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as classify from './classify.operation';\nimport * as message from './message.operation';\n\nexport { classify, message };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Message a Model',\n\t\t\t\tvalue: 'message',\n\t\t\t\taction: 'Message a model',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-excess-final-period\n\t\t\t\tdescription: 'Create a completion with GPT 3, 4, etc.',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Classify Text for Violations',\n\t\t\t\tvalue: 'classify',\n\t\t\t\taction: 'Classify text for violations',\n\t\t\t\tdescription: 'Check whether content complies with usage policies',\n\t\t\t},\n\t\t],\n\t\tdefault: 'message',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['text'],\n\t\t\t},\n\t\t},\n\t},\n\n\t...classify.description,\n\t...message.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAA0B;AAC1B,cAAyB;AAIlB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA;AAAA,QAER,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,MAAM;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EAEA,GAAG,SAAS;AAAA,EACZ,GAAG,QAAQ;AACZ;","names":[]}
|