@n8n/n8n-nodes-langchain 1.115.0 → 1.116.0
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 +86 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/message.operation.js +345 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js +777 -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 +17 -13
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAyD;AAEzD,uBAA2B;AAC3B,0BAAyB;AAEzB,MAAM,aAAgC;AAAA,MACrC,8BAAS,aAAa;AAAA,EACtB;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,EACX;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aACC;AAAA,IACD,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,aACC;AAAA,EACF;AAAA,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K,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"]}
|
package/dist/nodes/vendors/OpenAi/{actions → v1/actions}/assistant/deleteAssistant.operation.js
RENAMED
|
@@ -23,7 +23,7 @@ __export(deleteAssistant_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(deleteAssistant_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
var import_descriptions = require("../descriptions");
|
|
28
28
|
const properties = [import_descriptions.assistantRLC];
|
|
29
29
|
const displayOptions = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -23,7 +23,7 @@ __export(list_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(list_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
const properties = [
|
|
28
28
|
{
|
|
29
29
|
displayName: "Simplify Output",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -37,12 +37,12 @@ var import_openai_assistant = require("langchain/experimental/openai_assistant")
|
|
|
37
37
|
var import_omit = __toESM(require("lodash/omit"));
|
|
38
38
|
var import_n8n_workflow = require("n8n-workflow");
|
|
39
39
|
var import_openai = require("openai");
|
|
40
|
-
var import_descriptions = require("
|
|
41
|
-
var import_helpers = require("
|
|
42
|
-
var import_tracing = require("
|
|
43
|
-
var import_utils = require("
|
|
40
|
+
var import_descriptions = require("../../../../../../utils/descriptions");
|
|
41
|
+
var import_helpers = require("../../../../../../utils/helpers");
|
|
42
|
+
var import_tracing = require("../../../../../../utils/tracing");
|
|
43
|
+
var import_utils = require("../../../helpers/utils");
|
|
44
44
|
var import_descriptions2 = require("../descriptions");
|
|
45
|
-
var import_httpProxyAgent = require("
|
|
45
|
+
var import_httpProxyAgent = require("../../../../../../utils/httpProxyAgent");
|
|
46
46
|
const properties = [
|
|
47
47
|
import_descriptions2.assistantRLC,
|
|
48
48
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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,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,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"]}
|
|
@@ -23,7 +23,7 @@ __export(update_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(update_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
var import_descriptions = require("../descriptions");
|
|
28
28
|
const properties = [
|
|
29
29
|
import_descriptions.assistantRLC,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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;AAAA;AAAA;AAMA,0BAA2E;AAE3E,uBAA2B;AAC3B,0BAAuC;AAEvC,MAAM,aAAgC;AAAA,EACrC;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,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS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|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(generate_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
const properties = [
|
|
28
28
|
{
|
|
29
29
|
displayName: "Model",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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;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;AA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AM;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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -34,8 +34,8 @@ __export(transcribe_operation_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(transcribe_operation_exports);
|
|
35
35
|
var import_form_data = __toESM(require("form-data"));
|
|
36
36
|
var import_n8n_workflow = require("n8n-workflow");
|
|
37
|
-
var import_binary_data = require("
|
|
38
|
-
var import_transport = require("
|
|
37
|
+
var import_binary_data = require("../../../helpers/binary-data");
|
|
38
|
+
var import_transport = require("../../../transport");
|
|
39
39
|
const properties = [
|
|
40
40
|
{
|
|
41
41
|
displayName: "Input Data Field Name",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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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(translate_operation_exports);
|
|
35
35
|
var import_form_data = __toESM(require("form-data"));
|
|
36
36
|
var import_n8n_workflow = require("n8n-workflow");
|
|
37
|
-
var import_binary_data = require("
|
|
38
|
-
var import_transport = require("
|
|
37
|
+
var import_binary_data = require("../../../helpers/binary-data");
|
|
38
|
+
var import_transport = require("../../../transport");
|
|
39
39
|
const properties = [
|
|
40
40
|
{
|
|
41
41
|
displayName: "Input Data Field Name",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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}\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,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,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,WAAW;AAAA,IACvB,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,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,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -23,7 +23,7 @@ __export(deleteFile_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(deleteFile_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
const properties = [
|
|
28
28
|
{
|
|
29
29
|
displayName: "File",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -23,7 +23,7 @@ __export(list_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(list_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
const properties = [
|
|
28
28
|
{
|
|
29
29
|
displayName: "Options",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -34,8 +34,8 @@ __export(upload_operation_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(upload_operation_exports);
|
|
35
35
|
var import_form_data = __toESM(require("form-data"));
|
|
36
36
|
var import_n8n_workflow = require("n8n-workflow");
|
|
37
|
-
var import_binary_data = require("
|
|
38
|
-
var import_transport = require("
|
|
37
|
+
var import_binary_data = require("../../../helpers/binary-data");
|
|
38
|
+
var import_transport = require("../../../transport");
|
|
39
39
|
const properties = [
|
|
40
40
|
{
|
|
41
41
|
displayName: "Input Data Field Name",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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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ports = __toCommonJS(analyze_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
var import_descriptions = require("../descriptions");
|
|
28
28
|
const properties = [
|
|
29
29
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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;A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,qBAAa,OAAO,SAAS,QAAQ;AAAA,MACtC,OAAO;AACN,qBAAa,WAAW;AAAA,MACzB;AAEA,UAAI,CAAC,YAAY;AAChB,cAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,gCAAgC;AAAA,MAC9E;AAEA,cAAQ,KAAK;AAAA,QACZ,MAAM;AAAA,QACN,WAAW;AAAA,UACV,KAAK,QAAQ,WAAW,QAAQ,WAAW,UAAU;AAAA,UACrD;AAAA,QACD;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,QAAM,OAAO;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACT;AAAA,QACC,MAAM;AAAA,QACN;AAAA,MACD;AAAA,IACD;AAAA,IACA,YAAa,QAAQ,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":[]}
|
|
@@ -23,7 +23,7 @@ __export(generate_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(generate_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
const properties = [
|
|
28
28
|
{
|
|
29
29
|
displayName: "Model",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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;AA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iB,WAAW,GAAG,CAAC,CAAC;AACtD,MAAI,kBAAkB;AACtB,MAAI,uBAAuB;AAE3B,MAAI,QAAQ,iBAAiB;AAC5B,sBAAkB;AAAA,EACnB;AAEA,MAAI,QAAQ,sBAAsB;AACjC,2BAAuB,QAAQ;AAC/B,WAAO,QAAQ;AAAA,EAChB;AAEA,MAAI,QAAQ,cAAc;AACzB,YAAQ,UAAU,QAAQ;AAC1B,WAAO,QAAQ;AAAA,EAChB;AAEA,SAAO,QAAQ;AACf,QAAM,OAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,iBAAiB,UAAU,gBAAgB,kBAAkB;AAAA;AAAA,IAC7D,GAAG;AAAA,EACJ;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,4BAAW,KAAK,MAAM,QAAQ,uBAAuB,EAAE,KAAK,CAAC;AACpF,MAAI,oBAAoB,OAAO;AAC9B,YAAS,QAA0B,CAAC,GAAG,IAAI,CAAC,WAAW;AAAA,MACtD,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB,EAAE;AAAA,EACH,OAAO;AACN,UAAM,aAAmC,CAAC;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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -37,7 +37,7 @@ var audio = __toESM(require("./audio"));
|
|
|
37
37
|
var file = __toESM(require("./file"));
|
|
38
38
|
var image = __toESM(require("./image"));
|
|
39
39
|
var text = __toESM(require("./text"));
|
|
40
|
-
var import_error_handling = require("
|
|
40
|
+
var import_error_handling = require("../../helpers/error-handling");
|
|
41
41
|
async function router() {
|
|
42
42
|
const returnData = [];
|
|
43
43
|
const items = this.getInputData();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/v1/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}\n\t}\n\n\treturn [returnData];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,gBAA2B;AAC3B,YAAuB;AACvB,WAAsB;AACtB,YAAuB;AAEvB,WAAsB;AACtB,4BAAsC;AAEtC,eAAsB,SAAgC;AACrD,QAAM,aAAmC,C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AQ,GAAG,OAAO;AAAA,QACnD,WAAW;AAAA,QACX,aAAa,MAAM;AAAA,MACpB,CAAC;AAAA,IACF;AAAA,EACD;AAEA,SAAO,CAAC,UAAU;AACnB;","names":[]}
|
|
@@ -23,7 +23,7 @@ __export(classify_operation_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(classify_operation_exports);
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_transport = require("
|
|
26
|
+
var import_transport = require("../../../transport");
|
|
27
27
|
const properties = [
|
|
28
28
|
{
|
|
29
29
|
displayName: "Text Input",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/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":[]}
|
|
@@ -34,10 +34,10 @@ __export(message_operation_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(message_operation_exports);
|
|
35
35
|
var import_omit = __toESM(require("lodash/omit"));
|
|
36
36
|
var import_n8n_workflow = require("n8n-workflow");
|
|
37
|
-
var import_helpers = require("
|
|
38
|
-
var import_constants = require("
|
|
39
|
-
var import_utils = require("
|
|
40
|
-
var import_transport = require("
|
|
37
|
+
var import_helpers = require("../../../../../../utils/helpers");
|
|
38
|
+
var import_constants = require("../../../helpers/constants");
|
|
39
|
+
var import_utils = require("../../../helpers/utils");
|
|
40
|
+
var import_transport = require("../../../transport");
|
|
41
41
|
var import_descriptions = require("../descriptions");
|
|
42
42
|
const properties = [
|
|
43
43
|
(0, import_descriptions.modelRLC)("modelSearch"),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/actions/text/message.operation.ts"],"sourcesContent":["import type { Tool } from '@langchain/core/tools';\nimport _omit from 'lodash/omit';\nimport type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { jsonParse, updateDisplayOptions } from 'n8n-workflow';\n\nimport { getConnectedTools } from '@utils/helpers';\n\nimport { MODELS_NOT_SUPPORT_FUNCTION_CALLS } from '../../../helpers/constants';\nimport type { ChatCompletion } from '../../../helpers/interfaces';\nimport { formatToOpenAIAssistantTool } from '../../../helpers/utils';\nimport { apiRequest } from '../../../transport';\nimport { modelRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [\n\tmodelRLC('modelSearch'),\n\t{\n\t\tdisplayName: 'Messages',\n\t\tname: 'messages',\n\t\ttype: 'fixedCollection',\n\t\ttypeOptions: {\n\t\t\tsortable: true,\n\t\t\tmultipleValues: true,\n\t\t},\n\t\tplaceholder: 'Add Message',\n\t\tdefault: { values: [{ content: '' }] },\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Values',\n\t\t\t\tname: 'values',\n\t\t\t\tvalues: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\t\tname: 'content',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The content of the message to be send',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tplaceholder: 'e.g. Hello, how can you help me?',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\trows: 2,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Role',\n\t\t\t\t\t\tname: 'role',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Role in shaping the model's response, it tells the model how it should behave and interact with the user\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'User',\n\t\t\t\t\t\t\t\tvalue: 'user',\n\t\t\t\t\t\t\t\tdescription: 'Send a message as a user and get a response from the model',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Assistant',\n\t\t\t\t\t\t\t\tvalue: 'assistant',\n\t\t\t\t\t\t\t\tdescription: 'Tell the model to adopt a specific tone or personality',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'System',\n\t\t\t\t\t\t\t\tvalue: 'system',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Usually used to set the model's behavior or context for the next user message\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'user',\n\t\t\t\t\t},\n\t\t\t\t],\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 return a simplified version of the response instead of the raw data',\n\t},\n\t{\n\t\tdisplayName: 'Output Content as JSON',\n\t\tname: 'jsonOutput',\n\t\ttype: 'boolean',\n\t\tdescription:\n\t\t\t'Whether to attempt to return the response in JSON format. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106.',\n\t\tdefault: false,\n\t},\n\t{\n\t\tdisplayName: 'Hide Tools',\n\t\tname: 'hideTools',\n\t\ttype: 'hidden',\n\t\tdefault: 'hide',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tmodelId: MODELS_NOT_SUPPORT_FUNCTION_CALLS,\n\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\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\tdisplayOptions: {\n\t\t\thide: {\n\t\t\t\thideTools: ['hide'],\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: 'Frequency Penalty',\n\t\t\t\tname: 'frequency_penalty',\n\t\t\t\tdefault: 0,\n\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t\"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim\",\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\tname: 'maxTokens',\n\t\t\t\tdefault: 16,\n\t\t\t\tdescription:\n\t\t\t\t\t'The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tmaxValue: 32768,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Number of Completions',\n\t\t\t\tname: 'n',\n\t\t\t\tdefault: 1,\n\t\t\t\tdescription:\n\t\t\t\t\t'How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Presence Penalty',\n\t\t\t\tname: 'presence_penalty',\n\t\t\t\tdefault: 0,\n\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t\"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics\",\n\t\t\t\ttype: 'number',\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\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: 'Reasoning Effort',\n\t\t\t\tname: 'reasoning_effort',\n\t\t\t\tdefault: 'medium',\n\t\t\t\tdescription:\n\t\t\t\t\t'Controls the amount of reasoning tokens to use. A value of \"low\" will favor speed and economical token usage, \"high\" will favor more complete reasoning at the cost of more tokens generated and slower responses.',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\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: 'Favors speed and economical token usage',\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\tdescription: 'Balance between speed and reasoning accuracy',\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:\n\t\t\t\t\t\t\t'Favors more complete reasoning at the cost of more tokens generated and slower responses',\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// reasoning_effort is only available on o1, o1-versioned, or on o3-mini and beyond, and gpt-5 models. Not on o1-mini or other GPT-models.\n\t\t\t\t\t\t'/modelId': [{ _cnd: { regex: '(^o1([-\\\\d]+)?$)|(^o[3-9].*)|(^gpt-5.*)' } }],\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 Tool Calls Iterations',\n\t\t\t\tname: 'maxToolsIterations',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 15,\n\t\t\t\tdescription:\n\t\t\t\t\t'The maximum number of tool iteration cycles the LLM will run before stopping. A single iteration can contain multiple tool calls. Set to 0 for no limit.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.5 } }],\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: ['text'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst nodeVersion = this.getNode().typeVersion;\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true });\n\tlet messages = this.getNodeParameter('messages.values', i, []) as IDataObject[];\n\tconst options = this.getNodeParameter('options', i, {});\n\tconst jsonOutput = this.getNodeParameter('jsonOutput', i, false) as boolean;\n\tconst maxToolsIterations =\n\t\tnodeVersion >= 1.5 ? (this.getNodeParameter('options.maxToolsIterations', i, 15) as number) : 0;\n\n\tconst abortSignal = this.getExecutionCancelSignal();\n\n\tif (options.maxTokens !== undefined) {\n\t\toptions.max_completion_tokens = options.maxTokens;\n\t\tdelete options.maxTokens;\n\t}\n\n\tif (options.topP !== undefined) {\n\t\toptions.top_p = options.topP;\n\t\tdelete options.topP;\n\t}\n\n\tlet response_format;\n\tif (jsonOutput) {\n\t\tresponse_format = { type: 'json_object' };\n\t\tmessages = [\n\t\t\t{\n\t\t\t\trole: 'system',\n\t\t\t\tcontent: 'You are a helpful assistant designed to output JSON.',\n\t\t\t},\n\t\t\t...messages,\n\t\t];\n\t}\n\n\tconst hideTools = this.getNodeParameter('hideTools', i, '') as string;\n\n\tlet tools;\n\tlet externalTools: Tool[] = [];\n\n\tif (hideTools !== 'hide') {\n\t\tconst enforceUniqueNames = nodeVersion > 1;\n\t\texternalTools = await getConnectedTools(this, enforceUniqueNames, false);\n\t}\n\n\tif (externalTools.length) {\n\t\ttools = externalTools.length ? externalTools?.map(formatToOpenAIAssistantTool) : undefined;\n\t}\n\n\tconst body: IDataObject = {\n\t\tmodel,\n\t\tmessages,\n\t\ttools,\n\t\tresponse_format,\n\t\t..._omit(options, ['maxToolsIterations']),\n\t};\n\n\tlet response = (await apiRequest.call(this, 'POST', '/chat/completions', {\n\t\tbody,\n\t})) as ChatCompletion;\n\n\tif (!response) return [];\n\n\tlet currentIteration = 1;\n\tlet toolCalls = response?.choices[0]?.message?.tool_calls;\n\n\twhile (toolCalls?.length) {\n\t\t// Break the loop if the max iterations is reached or the execution is canceled\n\t\tif (\n\t\t\tabortSignal?.aborted ||\n\t\t\t(maxToolsIterations > 0 && currentIteration >= maxToolsIterations)\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tmessages.push(response.choices[0].message);\n\n\t\tfor (const toolCall of toolCalls) {\n\t\t\tconst functionName = toolCall.function.name;\n\t\t\tconst functionArgs = toolCall.function.arguments;\n\n\t\t\tlet functionResponse;\n\t\t\tfor (const tool of externalTools ?? []) {\n\t\t\t\tif (tool.name === functionName) {\n\t\t\t\t\tconst parsedArgs: { input: string } = jsonParse(functionArgs);\n\t\t\t\t\tconst functionInput = parsedArgs.input ?? parsedArgs ?? functionArgs;\n\t\t\t\t\tfunctionResponse = await tool.invoke(functionInput);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof functionResponse === 'object') {\n\t\t\t\tfunctionResponse = JSON.stringify(functionResponse);\n\t\t\t}\n\n\t\t\tmessages.push({\n\t\t\t\ttool_call_id: toolCall.id,\n\t\t\t\trole: 'tool',\n\t\t\t\tcontent: functionResponse,\n\t\t\t});\n\t\t}\n\n\t\tresponse = (await apiRequest.call(this, 'POST', '/chat/completions', {\n\t\t\tbody,\n\t\t})) as ChatCompletion;\n\n\t\ttoolCalls = response.choices[0].message.tool_calls;\n\t\tcurrentIteration += 1;\n\t}\n\n\tif (response_format) {\n\t\tresponse.choices = response.choices.map((choice) => {\n\t\t\ttry {\n\t\t\t\tchoice.message.content = JSON.parse(choice.message.content);\n\t\t\t} catch (error) {}\n\t\t\treturn choice;\n\t\t});\n\t}\n\n\tconst simplify = this.getNodeParameter('simplify', i) as boolean;\n\n\tconst returnData: INodeExecutionData[] = [];\n\n\tif (simplify) {\n\t\tfor (const entry of response.choices) {\n\t\t\treturnData.push({\n\t\t\t\tjson: entry,\n\t\t\t\tpairedItem: { item: i },\n\t\t\t});\n\t\t}\n\t} else {\n\t\treturnData.push({ json: response, pairedItem: { item: i } });\n\t}\n\n\treturn returnData;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAkB;AAOlB,0BAAgD;AAEhD,qBAAkC;AAElC,uBAAkD;AAElD,mBAA4C;AAC5C,uBAA2B;AAC3B,0BAAyB;AAEzB,MAAM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