@n8n/n8n-nodes-langchain 1.117.0 → 1.119.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/McpOAuth2Api.credentials.js +45 -0
- package/dist/credentials/McpOAuth2Api.credentials.js.map +1 -0
- package/dist/known/credentials.json +10 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/Guardrails/Guardrails.node.js +73 -0
- package/dist/nodes/Guardrails/Guardrails.node.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/jailbreak.js +50 -0
- package/dist/nodes/Guardrails/actions/checks/jailbreak.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/keywords.js +66 -0
- package/dist/nodes/Guardrails/actions/checks/keywords.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/nsfw.js +53 -0
- package/dist/nodes/Guardrails/actions/checks/nsfw.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/pii.js +232 -0
- package/dist/nodes/Guardrails/actions/checks/pii.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/secretKeys.js +201 -0
- package/dist/nodes/Guardrails/actions/checks/secretKeys.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/topicalAlignment.js +38 -0
- package/dist/nodes/Guardrails/actions/checks/topicalAlignment.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/urls.js +245 -0
- package/dist/nodes/Guardrails/actions/checks/urls.js.map +1 -0
- package/dist/nodes/Guardrails/actions/process.js +220 -0
- package/dist/nodes/Guardrails/actions/process.js.map +1 -0
- package/dist/nodes/Guardrails/actions/types.js +35 -0
- package/dist/nodes/Guardrails/actions/types.js.map +1 -0
- package/dist/nodes/Guardrails/description.js +454 -0
- package/dist/nodes/Guardrails/description.js.map +1 -0
- package/dist/nodes/Guardrails/guardrails.svg +11 -0
- package/dist/nodes/Guardrails/helpers/base.js +67 -0
- package/dist/nodes/Guardrails/helpers/base.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/common.js +45 -0
- package/dist/nodes/Guardrails/helpers/common.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/configureNodeInputs.js +50 -0
- package/dist/nodes/Guardrails/helpers/configureNodeInputs.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/mappers.js +100 -0
- package/dist/nodes/Guardrails/helpers/mappers.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/model.js +144 -0
- package/dist/nodes/Guardrails/helpers/model.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/preflight.js +61 -0
- package/dist/nodes/Guardrails/helpers/preflight.js.map +1 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js +6 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +8 -0
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V3/AgentV3.node.js +8 -0
- package/dist/nodes/agents/Agent/V3/AgentV3.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/description.js +10 -0
- package/dist/nodes/agents/Agent/agents/SqlAgent/description.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +22 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js +8 -3
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/config.js +4 -0
- package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -1
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +6 -0
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js +19 -4
- package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +448 -24
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/common.js +155 -0
- package/dist/nodes/llms/LMChatOpenAi/common.js.map +1 -0
- package/dist/nodes/llms/LMChatOpenAi/types.js +17 -0
- package/dist/nodes/llms/LMChatOpenAi/types.js.map +1 -0
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +21 -10
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +48 -3
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js +2 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/types.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/utils.js +66 -4
- package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +45 -2
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/helpers/utils.js +5 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js +6 -12
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js +31 -6
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js.map +1 -1
- package/dist/types/credentials.json +1 -0
- package/dist/types/nodes.json +12 -11
- package/dist/utils/descriptions.js +18 -0
- package/dist/utils/descriptions.js.map +1 -1
- package/dist/utils/helpers.js +4 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/httpProxyAgent.js +14 -1
- package/dist/utils/httpProxyAgent.js.map +1 -1
- package/package.json +13 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/llms/LMChatOpenAi/LmChatOpenAi.node.ts"],"sourcesContent":["import { ChatOpenAI, type ClientOptions } from '@langchain/openai';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { searchModels } from './methods/loadModels';\nimport { openAiFailedAttemptHandler } from '../../vendors/OpenAi/helpers/error-handling';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatOpenAi implements INodeType {\n\tmethods = {\n\t\tlistSearch: {\n\t\t\tsearchModels,\n\t\t},\n\t};\n\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'OpenAI Chat Model',\n\n\t\tname: 'lmChatOpenAi',\n\t\ticon: { light: 'file:openAiLight.svg', dark: 'file:openAiLight.dark.svg' },\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2],\n\t\tdescription: 'For advanced usage with an AI chain',\n\t\tdefaults: {\n\t\t\tname: 'OpenAI Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'openAiApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL:\n\t\t\t\t'={{ $parameter.options?.baseURL?.split(\"/\").slice(0,-1).join(\"/\") || $credentials?.url?.split(\"/\").slice(0,-1).join(\"/\") || \"https://api.openai.com\" }}',\n\t\t},\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/options.responseFormat': ['json_object'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The model which will generate the completion. <a href=\"https://beta.openai.com/docs/models/overview\">Learn more</a>.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptions: {\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '={{ $parameter.options?.baseURL?.split(\"/\").slice(-1).pop() || $credentials?.url?.split(\"/\").slice(-1).pop() || \"v1\" }}/models',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tproperty: 'data',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'filter',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\t// If the baseURL is not set or is set to api.openai.com, include only chat models\n\t\t\t\t\t\t\t\t\t\t\tpass: `={{\n\t\t\t\t\t\t\t\t\t\t\t\t($parameter.options?.baseURL && !$parameter.options?.baseURL?.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t\t\t\t($credentials?.url && !$credentials.url.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t\t\t\t$responseItem.id.startsWith('ft:') ||\n\t\t\t\t\t\t\t\t\t\t\t\t$responseItem.id.startsWith('o1') ||\n\t\t\t\t\t\t\t\t\t\t\t\t$responseItem.id.startsWith('o3') ||\n\t\t\t\t\t\t\t\t\t\t\t\t($responseItem.id.startsWith('gpt-') && !$responseItem.id.includes('instruct'))\n\t\t\t\t\t\t\t\t\t\t\t}}`,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tname: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t\t\t\t\tvalue: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trouting: {\n\t\t\t\t\tsend: {\n\t\t\t\t\t\ttype: 'body',\n\t\t\t\t\t\tproperty: 'model',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'gpt-4o-mini',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.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: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: 'gpt-4.1-mini' },\n\t\t\t\trequired: true,\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\tplaceholder: 'Select a model...',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'searchModels',\n\t\t\t\t\t\t\tsearchable: true,\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: 'ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tplaceholder: 'gpt-4.1-mini',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdescription: 'The model. Choose from the list, or specify an ID.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.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:\n\t\t\t\t\t'When using non-OpenAI models via \"Base URL\" override, not all models might be chat-compatible or support other features, like tools calling or JSON response format',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/options.baseURL': [{ _cnd: { exists: true } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\t\t\tname: 'baseURL',\n\t\t\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t\t\t},\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: 'Frequency Penalty',\n\t\t\t\t\t\tname: 'frequencyPenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokens',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tmaxValue: 32768,\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: 'Response Format',\n\t\t\t\t\t\tname: 'responseFormat',\n\t\t\t\t\t\tdefault: 'text',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Text',\n\t\t\t\t\t\t\t\tvalue: 'text',\n\t\t\t\t\t\t\t\tdescription: 'Regular text response',\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: 'JSON',\n\t\t\t\t\t\t\t\tvalue: 'json_object',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Enables JSON mode, which should guarantee the message the model generates is valid JSON',\n\t\t\t\t\t\t\t},\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: 'Presence Penalty',\n\t\t\t\t\t\tname: 'presencePenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Reasoning Effort',\n\t\t\t\t\t\tname: 'reasoningEffort',\n\t\t\t\t\t\tdefault: 'medium',\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Low',\n\t\t\t\t\t\t\t\tvalue: 'low',\n\t\t\t\t\t\t\t\tdescription: 'Favors speed and economical token usage',\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: 'Medium',\n\t\t\t\t\t\t\t\tvalue: 'medium',\n\t\t\t\t\t\t\t\tdescription: 'Balance between speed and reasoning accuracy',\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: 'High',\n\t\t\t\t\t\t\t\tvalue: 'high',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\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\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\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\t\t'/model': [{ _cnd: { regex: '(^o1([-\\\\d]+)?$)|(^o[3-9].*)|(^gpt-5.*)' } }],\n\t\t\t\t\t\t\t},\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: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: 60000,\n\t\t\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\t\t\tname: 'maxRetries',\n\t\t\t\t\t\tdefault: 2,\n\t\t\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Top P',\n\t\t\t\t\t\tname: 'topP',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'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\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('openAiApi');\n\n\t\tconst version = this.getNode().typeVersion;\n\t\tconst modelName =\n\t\t\tversion >= 1.2\n\t\t\t\t? (this.getNodeParameter('model.value', itemIndex) as string)\n\t\t\t\t: (this.getNodeParameter('model', itemIndex) as string);\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tbaseURL?: string;\n\t\t\tfrequencyPenalty?: number;\n\t\t\tmaxTokens?: number;\n\t\t\tmaxRetries: number;\n\t\t\ttimeout: number;\n\t\t\tpresencePenalty?: number;\n\t\t\ttemperature?: number;\n\t\t\ttopP?: number;\n\t\t\tresponseFormat?: 'text' | 'json_object';\n\t\t\treasoningEffort?: 'low' | 'medium' | 'high';\n\t\t};\n\n\t\tconst configuration: ClientOptions = {};\n\n\t\tif (options.baseURL) {\n\t\t\tconfiguration.baseURL = options.baseURL;\n\t\t} else if (credentials.url) {\n\t\t\tconfiguration.baseURL = credentials.url as string;\n\t\t}\n\n\t\tif (configuration.baseURL) {\n\t\t\tconfiguration.fetchOptions = {\n\t\t\t\tdispatcher: getProxyAgent(configuration.baseURL ?? 'https://api.openai.com/v1'),\n\t\t\t};\n\t\t}\n\t\tif (\n\t\t\tcredentials.header &&\n\t\t\ttypeof credentials.headerName === 'string' &&\n\t\t\tcredentials.headerName &&\n\t\t\ttypeof credentials.headerValue === 'string'\n\t\t) {\n\t\t\tconfiguration.defaultHeaders = {\n\t\t\t\t[credentials.headerName]: credentials.headerValue,\n\t\t\t};\n\t\t}\n\n\t\t// Extra options to send to OpenAI, that are not directly supported by LangChain\n\t\tconst modelKwargs: {\n\t\t\tresponse_format?: object;\n\t\t\treasoning_effort?: 'low' | 'medium' | 'high';\n\t\t} = {};\n\t\tif (options.responseFormat) modelKwargs.response_format = { type: options.responseFormat };\n\t\tif (options.reasoningEffort && ['low', 'medium', 'high'].includes(options.reasoningEffort))\n\t\t\tmodelKwargs.reasoning_effort = options.reasoningEffort;\n\n\t\tconst model = new ChatOpenAI({\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\tmodel: modelName,\n\t\t\t...options,\n\t\t\ttimeout: options.timeout ?? 60000,\n\t\t\tmaxRetries: options.maxRetries ?? 2,\n\t\t\tconfiguration,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tmodelKwargs,\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this, openAiFailedAttemptHandler),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,0BAMO;AAEP,4BAA8B;AAC9B,0BAA6C;AAE7C,wBAA6B;AAC7B,4BAA2C;AAC3C,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,aAAkC;AAAA,EAAxC;AACN,mBAAU;AAAA,MACT,YAAY;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAEA,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;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|
+
{"version":3,"sources":["../../../../nodes/llms/LMChatOpenAi/LmChatOpenAi.node.ts"],"sourcesContent":["import { ChatOpenAI, type ChatOpenAIFields, type ClientOptions } from '@langchain/openai';\nimport pick from 'lodash/pick';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeProperties,\n\ttype IDataObject,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { openAiFailedAttemptHandler } from '../../vendors/OpenAi/helpers/error-handling';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\nimport { formatBuiltInTools, prepareAdditionalResponsesParams } from './common';\nimport { searchModels } from './methods/loadModels';\nimport type { ModelOptions } from './types';\n\nconst INCLUDE_JSON_WARNING: INodeProperties = {\n\tdisplayName:\n\t\t'If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n};\n\nconst completionsResponseFormat: INodeProperties = {\n\tdisplayName: 'Response Format',\n\tname: 'responseFormat',\n\tdefault: 'text',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'Text',\n\t\t\tvalue: 'text',\n\t\t\tdescription: 'Regular text response',\n\t\t},\n\t\t{\n\t\t\tname: 'JSON',\n\t\t\tvalue: 'json_object',\n\t\t\tdescription:\n\t\t\t\t'Enables JSON mode, which should guarantee the message the model generates is valid JSON',\n\t\t},\n\t],\n};\n\nconst jsonSchemaExample = `{\n \"type\": \"object\",\n \"properties\": {\n \"message\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false,\n \"required\": [\"message\"]\n}`;\n\nexport class LmChatOpenAi implements INodeType {\n\tmethods = {\n\t\tlistSearch: {\n\t\t\tsearchModels,\n\t\t},\n\t};\n\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'OpenAI Chat Model',\n\n\t\tname: 'lmChatOpenAi',\n\t\ticon: { light: 'file:openAiLight.svg', dark: 'file:openAiLight.dark.svg' },\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'For advanced usage with an AI chain',\n\t\tdefaults: {\n\t\t\tname: 'OpenAI Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'openAiApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL:\n\t\t\t\t'={{ $parameter.options?.baseURL?.split(\"/\").slice(0,-1).join(\"/\") || $credentials?.url?.split(\"/\").slice(0,-1).join(\"/\") || \"https://api.openai.com\" }}',\n\t\t},\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\t...INCLUDE_JSON_WARNING,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/options.responseFormat': ['json_object'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...INCLUDE_JSON_WARNING,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/options.textFormat.textOptions.type': ['json_object'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The model which will generate the completion. <a href=\"https://beta.openai.com/docs/models/overview\">Learn more</a>.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptions: {\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '={{ $parameter.options?.baseURL?.split(\"/\").slice(-1).pop() || $credentials?.url?.split(\"/\").slice(-1).pop() || \"v1\" }}/models',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tproperty: 'data',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'filter',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\t// If the baseURL is not set or is set to api.openai.com, include only chat models\n\t\t\t\t\t\t\t\t\t\t\tpass: `={{\n\t\t\t\t\t\t\t\t\t\t\t\t($parameter.options?.baseURL && !$parameter.options?.baseURL?.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t\t\t\t($credentials?.url && !$credentials.url.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t\t\t\t$responseItem.id.startsWith('ft:') ||\n\t\t\t\t\t\t\t\t\t\t\t\t$responseItem.id.startsWith('o1') ||\n\t\t\t\t\t\t\t\t\t\t\t\t$responseItem.id.startsWith('o3') ||\n\t\t\t\t\t\t\t\t\t\t\t\t($responseItem.id.startsWith('gpt-') && !$responseItem.id.includes('instruct'))\n\t\t\t\t\t\t\t\t\t\t\t}}`,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tname: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t\t\t\t\tvalue: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trouting: {\n\t\t\t\t\tsend: {\n\t\t\t\t\t\ttype: 'body',\n\t\t\t\t\t\tproperty: 'model',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'gpt-4o-mini',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.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: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: 'gpt-4.1-mini' },\n\t\t\t\trequired: true,\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\tplaceholder: 'Select a model...',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'searchModels',\n\t\t\t\t\t\t\tsearchable: true,\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: 'ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tplaceholder: 'gpt-4.1-mini',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdescription: 'The model. Choose from the list, or specify an ID.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.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:\n\t\t\t\t\t'When using non-OpenAI models via \"Base URL\" override, not all models might be chat-compatible or support other features, like tools calling or JSON response format',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/options.baseURL': [{ _cnd: { exists: true } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Use Responses API',\n\t\t\t\tname: 'responsesApiEnabled',\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 use the Responses API to generate the response. <a href=\"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatopenai/#use-responses-api\">Learn more</a>.',\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\t{\n\t\t\t\tdisplayName: 'Built-in Tools',\n\t\t\t\tname: 'builtInTools',\n\t\t\t\tplaceholder: 'Add Built-in Tool',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Web Search',\n\t\t\t\t\t\tname: 'webSearch',\n\t\t\t\t\t\ttype: 'collection',\n\t\t\t\t\t\tdefault: { searchContextSize: 'medium' },\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Search Context Size',\n\t\t\t\t\t\t\t\tname: 'searchContextSize',\n\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\tdefault: 'medium',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'High level guidance for the amount of context window space to use for the search',\n\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t{ name: 'Low', value: 'low' },\n\t\t\t\t\t\t\t\t\t{ name: 'Medium', value: 'medium' },\n\t\t\t\t\t\t\t\t\t{ name: 'High', value: 'high' },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Web Search Allowed Domains',\n\t\t\t\t\t\t\t\tname: 'allowedDomains',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Comma-separated list of domains to search. Only domains in this list will be searched.',\n\t\t\t\t\t\t\t\tplaceholder: 'e.g. google.com, wikipedia.org',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Country',\n\t\t\t\t\t\t\t\tname: 'country',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\tplaceholder: 'e.g. US, GB',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'City',\n\t\t\t\t\t\t\t\tname: 'city',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\tplaceholder: 'e.g. New York, London',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Region',\n\t\t\t\t\t\t\t\tname: 'region',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\tplaceholder: 'e.g. New York, London',\n\t\t\t\t\t\t\t},\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: 'File Search',\n\t\t\t\t\t\tname: 'fileSearch',\n\t\t\t\t\t\ttype: 'collection',\n\t\t\t\t\t\tdefault: { vectorStoreIds: '[]' },\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Vector Store IDs',\n\t\t\t\t\t\t\t\tname: 'vectorStoreIds',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'The vector store IDs to use for the file search. Vector stores are managed via OpenAI Dashboard. <a href=\"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatopenai/#built-in-tools\">Learn more</a>.',\n\t\t\t\t\t\t\t\ttype: 'json',\n\t\t\t\t\t\t\t\tdefault: '[]',\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Filters',\n\t\t\t\t\t\t\t\tname: 'filters',\n\t\t\t\t\t\t\t\ttype: 'json',\n\t\t\t\t\t\t\t\tdefault: '{}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Max Results',\n\t\t\t\t\t\t\t\tname: 'maxResults',\n\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\t\t\ttypeOptions: { minValue: 1, maxValue: 50 },\n\t\t\t\t\t\t\t},\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: 'Code Interpreter',\n\t\t\t\t\t\tname: 'codeInterpreter',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: true,\n\t\t\t\t\t\tdescription: 'Whether to allow the model to execute code in a sandboxed environment',\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'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\t\t\tname: 'baseURL',\n\t\t\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t\t\t},\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: 'Frequency Penalty',\n\t\t\t\t\t\tname: 'frequencyPenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokens',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tmaxValue: 32768,\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\t...completionsResponseFormat,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { lt: 1.3 } }],\n\t\t\t\t\t\t\t},\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\t...completionsResponseFormat,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [false],\n\t\t\t\t\t\t\t},\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: 'Response Format',\n\t\t\t\t\t\tname: 'textFormat',\n\t\t\t\t\t\ttype: 'fixedCollection',\n\t\t\t\t\t\tdefault: { textOptions: [{ type: 'text' }] },\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Text',\n\t\t\t\t\t\t\t\tname: 'textOptions',\n\t\t\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Type',\n\t\t\t\t\t\t\t\t\t\tname: 'type',\n\t\t\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\t\t{ name: 'Text', value: 'text' },\n\t\t\t\t\t\t\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\t\t\t\t\t\t\t{ name: 'JSON Schema (recommended)', value: 'json_schema' },\n\t\t\t\t\t\t\t\t\t\t\t{ name: 'JSON Object', value: 'json_object' },\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Verbosity',\n\t\t\t\t\t\t\t\t\t\tname: 'verbosity',\n\t\t\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\t\t\tdefault: 'medium',\n\t\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\t\t{ name: 'Low', value: 'low' },\n\t\t\t\t\t\t\t\t\t\t\t{ name: 'Medium', value: 'medium' },\n\t\t\t\t\t\t\t\t\t\t\t{ name: 'High', value: 'high' },\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Name',\n\t\t\t\t\t\t\t\t\t\tname: 'name',\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdefault: 'my_schema',\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: ['json_schema'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t\t\t\t\t\t'All properties in the schema must be set to \"required\", when using \"strict\" mode.',\n\t\t\t\t\t\t\t\t\t\tname: 'requiredNotice',\n\t\t\t\t\t\t\t\t\t\ttype: 'notice',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\tstrict: [true],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Schema',\n\t\t\t\t\t\t\t\t\t\tname: 'schema',\n\t\t\t\t\t\t\t\t\t\ttype: 'json',\n\t\t\t\t\t\t\t\t\t\tdefault: jsonSchemaExample,\n\t\t\t\t\t\t\t\t\t\tdescription: 'The schema of the response format',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: ['json_schema'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Description',\n\t\t\t\t\t\t\t\t\t\tname: 'description',\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The description of the response format',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: ['json_schema'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Strict',\n\t\t\t\t\t\t\t\t\t\tname: 'strict',\n\t\t\t\t\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'Whether to require that the AI will always generate responses that match the provided JSON Schema',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: ['json_schema'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Presence Penalty',\n\t\t\t\t\t\tname: 'presencePenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Reasoning Effort',\n\t\t\t\t\t\tname: 'reasoningEffort',\n\t\t\t\t\t\tdefault: 'medium',\n\t\t\t\t\t\tdescription:\n\t\t\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\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Low',\n\t\t\t\t\t\t\t\tvalue: 'low',\n\t\t\t\t\t\t\t\tdescription: 'Favors speed and economical token usage',\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: 'Medium',\n\t\t\t\t\t\t\t\tvalue: 'medium',\n\t\t\t\t\t\t\t\tdescription: 'Balance between speed and reasoning accuracy',\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: 'High',\n\t\t\t\t\t\t\t\tvalue: 'high',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\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\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\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\t\t'/model': [{ _cnd: { regex: '(^o1([-\\\\d]+)?$)|(^o[3-9].*)|(^gpt-5.*)' } }],\n\t\t\t\t\t\t\t},\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: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: 60000,\n\t\t\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\t\t\tname: 'maxRetries',\n\t\t\t\t\t\tdefault: 2,\n\t\t\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Top P',\n\t\t\t\t\t\tname: 'topP',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'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\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Conversation ID',\n\t\t\t\t\t\tname: 'conversationId',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The conversation that this response belongs to. Input items and output items from this response are automatically added to this conversation after this response completes.',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Prompt Cache Key',\n\t\t\t\t\t\tname: 'promptCacheKey',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Used by OpenAI to cache responses for similar requests to optimize your cache hit rates',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Safety Identifier',\n\t\t\t\t\t\tname: 'safetyIdentifier',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user.\",\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Service Tier',\n\t\t\t\t\t\tname: 'serviceTier',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\tdefault: 'auto',\n\t\t\t\t\t\tdescription: 'The service tier to use for the request',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: 'Auto', value: 'auto' },\n\t\t\t\t\t\t\t{ name: 'Flex', value: 'flex' },\n\t\t\t\t\t\t\t{ name: 'Default', value: 'default' },\n\t\t\t\t\t\t\t{ name: 'Priority', value: 'priority' },\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Metadata',\n\t\t\t\t\t\tname: 'metadata',\n\t\t\t\t\t\ttype: 'json',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.',\n\t\t\t\t\t\tdefault: '{}',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Top Logprobs',\n\t\t\t\t\t\tname: 'topLogprobs',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tminValue: 0,\n\t\t\t\t\t\t\tmaxValue: 20,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\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: 'Prompt',\n\t\t\t\t\t\tname: 'promptConfig',\n\t\t\t\t\t\ttype: 'fixedCollection',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Configure the reusable prompt template configured via OpenAI Dashboard. <a href=\"https://platform.openai.com/docs/guides/prompt-engineering#reusable-prompts\">Learn more</a>.',\n\t\t\t\t\t\tdefault: { promptOptions: [{ promptId: '' }] },\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\t\t\t\tname: 'promptOptions',\n\t\t\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Prompt ID',\n\t\t\t\t\t\t\t\t\t\tname: 'promptId',\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The unique identifier of the prompt template to use',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Version',\n\t\t\t\t\t\t\t\t\t\tname: 'version',\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\tdescription: 'Optional version of the prompt template',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Variables',\n\t\t\t\t\t\t\t\t\t\tname: 'variables',\n\t\t\t\t\t\t\t\t\t\ttype: 'json',\n\t\t\t\t\t\t\t\t\t\tdefault: '{}',\n\t\t\t\t\t\t\t\t\t\tdescription: 'Variables to be substituted into the prompt template',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t\t\t\t'/responsesApiEnabled': [true],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('openAiApi');\n\n\t\tconst version = this.getNode().typeVersion;\n\t\tconst modelName =\n\t\t\tversion >= 1.2\n\t\t\t\t? (this.getNodeParameter('model.value', itemIndex) as string)\n\t\t\t\t: (this.getNodeParameter('model', itemIndex) as string);\n\n\t\tconst responsesApiEnabled = this.getNodeParameter('responsesApiEnabled', itemIndex, false);\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as ModelOptions;\n\n\t\tconst configuration: ClientOptions = {};\n\n\t\tif (options.baseURL) {\n\t\t\tconfiguration.baseURL = options.baseURL;\n\t\t} else if (credentials.url) {\n\t\t\tconfiguration.baseURL = credentials.url as string;\n\t\t}\n\n\t\tif (configuration.baseURL) {\n\t\t\tconfiguration.fetchOptions = {\n\t\t\t\tdispatcher: getProxyAgent(configuration.baseURL ?? 'https://api.openai.com/v1'),\n\t\t\t};\n\t\t}\n\t\tif (\n\t\t\tcredentials.header &&\n\t\t\ttypeof credentials.headerName === 'string' &&\n\t\t\tcredentials.headerName &&\n\t\t\ttypeof credentials.headerValue === 'string'\n\t\t) {\n\t\t\tconfiguration.defaultHeaders = {\n\t\t\t\t[credentials.headerName]: credentials.headerValue,\n\t\t\t};\n\t\t}\n\n\t\t// Extra options to send to OpenAI, that are not directly supported by LangChain\n\t\tconst modelKwargs: Record<string, unknown> = {};\n\t\tif (responsesApiEnabled) {\n\t\t\tconst kwargs = prepareAdditionalResponsesParams(options);\n\t\t\tObject.assign(modelKwargs, kwargs);\n\t\t} else {\n\t\t\tif (options.responseFormat) modelKwargs.response_format = { type: options.responseFormat };\n\t\t\tif (options.reasoningEffort && ['low', 'medium', 'high'].includes(options.reasoningEffort)) {\n\t\t\t\tmodelKwargs.reasoning_effort = options.reasoningEffort;\n\t\t\t}\n\t\t}\n\n\t\tconst includedOptions = pick(options, [\n\t\t\t'frequencyPenalty',\n\t\t\t'maxTokens',\n\t\t\t'presencePenalty',\n\t\t\t'temperature',\n\t\t\t'topP',\n\t\t\t'baseURL',\n\t\t]);\n\n\t\tconst fields: ChatOpenAIFields = {\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\tmodel: modelName,\n\t\t\t...includedOptions,\n\t\t\ttimeout: options.timeout ?? 60000,\n\t\t\tmaxRetries: options.maxRetries ?? 2,\n\t\t\tconfiguration,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tmodelKwargs,\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this, openAiFailedAttemptHandler),\n\t\t};\n\n\t\t// by default ChatOpenAI can switch to responses API automatically, so force it only on 1.3 and above to keep backwards compatibility\n\t\tif (responsesApiEnabled) {\n\t\t\tfields.useResponsesApi = true;\n\t\t}\n\n\t\tconst model = new ChatOpenAI(fields);\n\n\t\tif (responsesApiEnabled) {\n\t\t\tconst tools = formatBuiltInTools(\n\t\t\t\tthis.getNodeParameter('builtInTools', itemIndex, {}) as IDataObject,\n\t\t\t);\n\t\t\t// pass tools to the model metadata, ToolAgent will use it to create agent configuration\n\t\t\tif (tools.length) {\n\t\t\t\tmodel.metadata = {\n\t\t\t\t\t...model.metadata,\n\t\t\t\t\ttools,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsE;AACtE,kBAAiB;AACjB,0BAQO;AAEP,4BAA8B;AAC9B,0BAA6C;AAE7C,4BAA2C;AAC3C,wCAA+C;AAC/C,2BAA8B;AAC9B,oBAAqE;AACrE,wBAA6B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AAAA,MAChC,QAAQ,YAAY;AAAA,MACpB,OAAO;AAAA,MACP,GAAG;AAAA,MACH,SAAS,QAAQ,WAAW;AAAA,MAC5B,YAAY,QAAQ,cAAc;AAAA,MAClC;AAAA,MACA,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,MACnC;AAAA,MACA,qBAAiB,kEAA+B,MAAM,gDAA0B;AAAA,IACjF;AAGA,QAAI,qBAAqB;AACxB,aAAO,kBAAkB;AAAA,IAC1B;AAEA,UAAM,QAAQ,IAAI,yBAAW,MAAM;AAEnC,QAAI,qBAAqB;AACxB,YAAM,YAAQ;AAAA,QACb,KAAK,iBAAiB,gBAAgB,WAAW,CAAC,CAAC;AAAA,MACpD;AAEA,UAAI,MAAM,QAAQ;AACjB,cAAM,WAAW;AAAA,UAChB,GAAG,MAAM;AAAA,UACT;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":["pick"]}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var common_exports = {};
|
|
30
|
+
__export(common_exports, {
|
|
31
|
+
formatBuiltInTools: () => formatBuiltInTools,
|
|
32
|
+
prepareAdditionalResponsesParams: () => prepareAdditionalResponsesParams
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(common_exports);
|
|
35
|
+
var import_get = __toESM(require("lodash/get"));
|
|
36
|
+
var import_isObject = __toESM(require("lodash/isObject"));
|
|
37
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
38
|
+
const removeEmptyProperties = (rest) => {
|
|
39
|
+
return Object.keys(rest).filter(
|
|
40
|
+
(k) => rest[k] !== "" && rest[k] !== void 0 && !((0, import_isObject.default)(rest[k]) && (0, import_n8n_workflow.isObjectEmpty)(rest[k]))
|
|
41
|
+
).reduce((a, k) => ({ ...a, [k]: rest[k] }), {});
|
|
42
|
+
};
|
|
43
|
+
const toArray = (str) => str.split(",").map((e) => e.trim()).filter(Boolean);
|
|
44
|
+
const formatBuiltInTools = (builtInTools) => {
|
|
45
|
+
const tools = [];
|
|
46
|
+
if (builtInTools) {
|
|
47
|
+
const webSearchOptions = (0, import_get.default)(builtInTools, "webSearch");
|
|
48
|
+
if (webSearchOptions) {
|
|
49
|
+
let allowedDomains;
|
|
50
|
+
const allowedDomainsRaw = (0, import_get.default)(webSearchOptions, "allowedDomains", "");
|
|
51
|
+
if (allowedDomainsRaw) {
|
|
52
|
+
allowedDomains = toArray(allowedDomainsRaw);
|
|
53
|
+
}
|
|
54
|
+
let userLocation;
|
|
55
|
+
if (webSearchOptions.country || webSearchOptions.city || webSearchOptions.region) {
|
|
56
|
+
userLocation = {
|
|
57
|
+
type: "approximate",
|
|
58
|
+
country: webSearchOptions.country,
|
|
59
|
+
city: webSearchOptions.city,
|
|
60
|
+
region: webSearchOptions.region
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
tools.push({
|
|
64
|
+
type: "web_search",
|
|
65
|
+
search_context_size: (0, import_get.default)(webSearchOptions, "searchContextSize", "medium"),
|
|
66
|
+
user_location: userLocation,
|
|
67
|
+
...allowedDomains && { filters: { allowed_domains: allowedDomains } }
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (builtInTools.codeInterpreter) {
|
|
71
|
+
tools.push({
|
|
72
|
+
type: "code_interpreter",
|
|
73
|
+
container: {
|
|
74
|
+
type: "auto"
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (builtInTools.fileSearch) {
|
|
79
|
+
const vectorStoreIds = (0, import_get.default)(builtInTools.fileSearch, "vectorStoreIds", "[]");
|
|
80
|
+
const filters = (0, import_get.default)(builtInTools.fileSearch, "filters", "{}");
|
|
81
|
+
tools.push({
|
|
82
|
+
type: "file_search",
|
|
83
|
+
vector_store_ids: (0, import_n8n_workflow.jsonParse)(vectorStoreIds, {
|
|
84
|
+
errorMessage: "Failed to parse vector store IDs"
|
|
85
|
+
}),
|
|
86
|
+
filters: filters ? (0, import_n8n_workflow.jsonParse)(filters, { errorMessage: "Failed to parse filters" }) : void 0,
|
|
87
|
+
max_num_results: (0, import_get.default)(builtInTools.fileSearch, "maxResults")
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return tools;
|
|
92
|
+
};
|
|
93
|
+
const prepareAdditionalResponsesParams = (options) => {
|
|
94
|
+
const body = {
|
|
95
|
+
prompt_cache_key: options.promptCacheKey,
|
|
96
|
+
safety_identifier: options.safetyIdentifier,
|
|
97
|
+
service_tier: options.serviceTier,
|
|
98
|
+
top_logprobs: options.topLogprobs
|
|
99
|
+
};
|
|
100
|
+
if (options.conversationId) {
|
|
101
|
+
body.conversation = options.conversationId;
|
|
102
|
+
}
|
|
103
|
+
if (options.metadata) {
|
|
104
|
+
body.metadata = (0, import_n8n_workflow.jsonParse)(options.metadata, {
|
|
105
|
+
errorMessage: "Failed to parse metadata"
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (options.promptConfig) {
|
|
109
|
+
const prompt = (0, import_get.default)(options, "promptConfig.promptOptions", {});
|
|
110
|
+
body.prompt = removeEmptyProperties({
|
|
111
|
+
id: prompt.promptId,
|
|
112
|
+
version: prompt.version,
|
|
113
|
+
...prompt.variables && {
|
|
114
|
+
variables: (0, import_n8n_workflow.jsonParse)(prompt.variables, {
|
|
115
|
+
errorMessage: "Failed to parse prompt variables"
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (options.textFormat) {
|
|
121
|
+
const textOptions = (0, import_get.default)(options, "textFormat.textOptions", {});
|
|
122
|
+
const textConfig = {
|
|
123
|
+
verbosity: textOptions.verbosity
|
|
124
|
+
};
|
|
125
|
+
if (textOptions.type === "json_schema") {
|
|
126
|
+
textConfig.format = {
|
|
127
|
+
type: textOptions.type,
|
|
128
|
+
name: textOptions.name,
|
|
129
|
+
schema: (0, import_n8n_workflow.jsonParse)(textOptions.schema, {
|
|
130
|
+
errorMessage: "Failed to parse schema"
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
textConfig.format = {
|
|
135
|
+
type: textOptions.type
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (textConfig.format) {
|
|
139
|
+
textConfig.format = removeEmptyProperties(textConfig.format);
|
|
140
|
+
}
|
|
141
|
+
body.text = textConfig;
|
|
142
|
+
}
|
|
143
|
+
if (options.reasoningEffort) {
|
|
144
|
+
body.reasoning = {
|
|
145
|
+
effort: options.reasoningEffort
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return body;
|
|
149
|
+
};
|
|
150
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
+
0 && (module.exports = {
|
|
152
|
+
formatBuiltInTools,
|
|
153
|
+
prepareAdditionalResponsesParams
|
|
154
|
+
});
|
|
155
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/llms/LMChatOpenAi/common.ts"],"sourcesContent":["import type { OpenAIClient } from '@langchain/openai';\nimport type { ChatOpenAIToolType } from '@langchain/openai/dist/utils/tools';\nimport get from 'lodash/get';\nimport isObject from 'lodash/isObject';\nimport { isObjectEmpty, jsonParse } from 'n8n-workflow';\n\nimport type {\n\tBuiltInTools,\n\tChatResponseRequest,\n\tModelOptions,\n\tPromptOptions,\n\tTextOptions,\n} from './types';\n\nconst removeEmptyProperties = <T>(rest: { [key: string]: any }): T => {\n\treturn Object.keys(rest)\n\t\t.filter(\n\t\t\t(k) =>\n\t\t\t\trest[k] !== '' && rest[k] !== undefined && !(isObject(rest[k]) && isObjectEmpty(rest[k])),\n\t\t)\n\t\t.reduce((a, k) => ({ ...a, [k]: rest[k] }), {}) as unknown as T;\n};\n\nconst toArray = (str: string) =>\n\tstr\n\t\t.split(',')\n\t\t.map((e) => e.trim())\n\t\t.filter(Boolean);\n\nexport const formatBuiltInTools = (builtInTools: BuiltInTools) => {\n\tconst tools: ChatOpenAIToolType[] = [];\n\tif (builtInTools) {\n\t\tconst webSearchOptions = get(builtInTools, 'webSearch');\n\t\tif (webSearchOptions) {\n\t\t\tlet allowedDomains: string[] | undefined;\n\t\t\tconst allowedDomainsRaw = get(webSearchOptions, 'allowedDomains', '');\n\t\t\tif (allowedDomainsRaw) {\n\t\t\t\tallowedDomains = toArray(allowedDomainsRaw);\n\t\t\t}\n\n\t\t\tlet userLocation: OpenAIClient.Responses.WebSearchTool.UserLocation | undefined;\n\t\t\tif (webSearchOptions.country || webSearchOptions.city || webSearchOptions.region) {\n\t\t\t\tuserLocation = {\n\t\t\t\t\ttype: 'approximate',\n\t\t\t\t\tcountry: webSearchOptions.country as string,\n\t\t\t\t\tcity: webSearchOptions.city as string,\n\t\t\t\t\tregion: webSearchOptions.region as string,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\ttools.push({\n\t\t\t\ttype: 'web_search',\n\t\t\t\tsearch_context_size: get(webSearchOptions, 'searchContextSize', 'medium'),\n\t\t\t\tuser_location: userLocation,\n\t\t\t\t...(allowedDomains && { filters: { allowed_domains: allowedDomains } }),\n\t\t\t});\n\t\t}\n\n\t\tif (builtInTools.codeInterpreter) {\n\t\t\ttools.push({\n\t\t\t\ttype: 'code_interpreter',\n\t\t\t\tcontainer: {\n\t\t\t\t\ttype: 'auto',\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tif (builtInTools.fileSearch) {\n\t\t\tconst vectorStoreIds = get(builtInTools.fileSearch, 'vectorStoreIds', '[]');\n\t\t\tconst filters = get(builtInTools.fileSearch, 'filters', '{}');\n\t\t\ttools.push({\n\t\t\t\ttype: 'file_search',\n\t\t\t\tvector_store_ids: jsonParse(vectorStoreIds, {\n\t\t\t\t\terrorMessage: 'Failed to parse vector store IDs',\n\t\t\t\t}),\n\t\t\t\tfilters: filters\n\t\t\t\t\t? jsonParse(filters, { errorMessage: 'Failed to parse filters' })\n\t\t\t\t\t: undefined,\n\t\t\t\tmax_num_results: get(builtInTools.fileSearch, 'maxResults') as number,\n\t\t\t});\n\t\t}\n\t}\n\treturn tools;\n};\n\nexport const prepareAdditionalResponsesParams = (options: ModelOptions) => {\n\tconst body: Partial<ChatResponseRequest> = {\n\t\tprompt_cache_key: options.promptCacheKey,\n\t\tsafety_identifier: options.safetyIdentifier,\n\t\tservice_tier: options.serviceTier,\n\t\ttop_logprobs: options.topLogprobs,\n\t};\n\n\tif (options.conversationId) {\n\t\tbody.conversation = options.conversationId;\n\t}\n\n\tif (options.metadata) {\n\t\tbody.metadata = jsonParse(options.metadata, {\n\t\t\terrorMessage: 'Failed to parse metadata',\n\t\t});\n\t}\n\n\tif (options.promptConfig) {\n\t\tconst prompt = get(options, 'promptConfig.promptOptions', {} as PromptOptions);\n\t\tbody.prompt = removeEmptyProperties({\n\t\t\tid: prompt.promptId,\n\t\t\tversion: prompt.version,\n\t\t\t...(prompt.variables && {\n\t\t\t\tvariables: jsonParse(prompt.variables, {\n\t\t\t\t\terrorMessage: 'Failed to parse prompt variables',\n\t\t\t\t}),\n\t\t\t}),\n\t\t});\n\t}\n\n\tif (options.textFormat) {\n\t\tconst textOptions = get(options, 'textFormat.textOptions', {} as TextOptions);\n\t\tconst textConfig: OpenAIClient.Responses.ResponseTextConfig = {\n\t\t\tverbosity: textOptions.verbosity as OpenAIClient.Responses.ResponseTextConfig['verbosity'],\n\t\t};\n\t\tif (textOptions.type === 'json_schema') {\n\t\t\ttextConfig.format = {\n\t\t\t\ttype: textOptions.type,\n\t\t\t\tname: textOptions.name as string,\n\t\t\t\tschema: jsonParse(textOptions.schema as string, {\n\t\t\t\t\terrorMessage: 'Failed to parse schema',\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\ttextConfig.format = {\n\t\t\t\ttype: textOptions.type as 'json_object' | 'text',\n\t\t\t};\n\t\t}\n\n\t\tif (textConfig.format) {\n\t\t\ttextConfig.format = removeEmptyProperties(textConfig.format);\n\t\t}\n\n\t\tbody.text = textConfig;\n\t}\n\n\tif (options.reasoningEffort) {\n\t\tbody.reasoning = {\n\t\t\teffort: options.reasoningEffort,\n\t\t};\n\t}\n\n\treturn body;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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UAAM,aAAwD;AAAA,MAC7D,WAAW,YAAY;AAAA,IACxB;AACA,QAAI,YAAY,SAAS,eAAe;AACvC,iBAAW,SAAS;AAAA,QACnB,MAAM,YAAY;AAAA,QAClB,MAAM,YAAY;AAAA,QAClB,YAAQ,+BAAU,YAAY,QAAkB;AAAA,UAC/C,cAAc;AAAA,QACf,CAAC;AAAA,MACF;AAAA,IACD,OAAO;AACN,iBAAW,SAAS;AAAA,QACnB,MAAM,YAAY;AAAA,MACnB;AAAA,IACD;AAEA,QAAI,WAAW,QAAQ;AACtB,iBAAW,SAAS,sBAAsB,WAAW,MAAM;AAAA,IAC5D;AAEA,SAAK,OAAO;AAAA,EACb;AAEA,MAAI,QAAQ,iBAAiB;AAC5B,SAAK,YAAY;AAAA,MAChB,QAAQ,QAAQ;AAAA,IACjB;AAAA,EACD;AAEA,SAAO;AACR;","names":["isObject","get"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/llms/LMChatOpenAi/types.ts"],"sourcesContent":["import type { OpenAIClient } from '@langchain/openai';\n\nexport type BuiltInTools = {\n\twebSearch?: {\n\t\tsearchContextSize?: 'low' | 'medium' | 'high';\n\t\tallowedDomains?: string;\n\t\tcountry?: string;\n\t\tcity?: string;\n\t\tregion?: string;\n\t};\n\tfileSearch?: {\n\t\tvectorStoreIds?: string;\n\t\tfilters?: string;\n\t\tmaxResults?: number;\n\t};\n\tcodeInterpreter?: boolean;\n};\n\nexport type ModelOptions = {\n\tbaseURL?: string;\n\tfrequencyPenalty?: number;\n\tmaxTokens?: number;\n\tresponseFormat?: 'text' | 'json_object';\n\tpresencePenalty?: number;\n\ttemperature?: number;\n\treasoningEffort?: 'low' | 'medium' | 'high';\n\ttimeout?: number;\n\tmaxRetries?: number;\n\ttopP?: number;\n\tconversationId?: string;\n\tmetadata?: string;\n\tpromptCacheKey?: string;\n\tsafetyIdentifier?: string;\n\tserviceTier?: 'auto' | 'flex' | 'default' | 'priority';\n\ttopLogprobs?: number;\n\ttextFormat?: {\n\t\ttextOptions?: TextOptions;\n\t};\n\tpromptConfig?: {\n\t\tpromptOptions?: PromptOptions;\n\t};\n};\n\nexport type PromptOptions = {\n\tpromptId?: string;\n\tversion?: string;\n\tvariables?: string;\n};\n\nexport type TextOptions = {\n\ttype?: 'text' | 'json_schema' | 'json_object';\n\tverbosity?: 'low' | 'medium' | 'high';\n\tname?: string;\n\tschema?: string;\n\tdescription?: string;\n\tstrict?: boolean;\n};\nexport type ChatResponseRequest = OpenAIClient.Responses.ResponseCreateParamsNonStreaming & {\n\tconversation?: { id: string } | string;\n\ttop_logprobs?: number;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -21,10 +21,12 @@ __export(LmChatAwsBedrock_node_exports, {
|
|
|
21
21
|
LmChatAwsBedrock: () => LmChatAwsBedrock
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(LmChatAwsBedrock_node_exports);
|
|
24
|
+
var import_client_bedrock_runtime = require("@aws-sdk/client-bedrock-runtime");
|
|
24
25
|
var import_aws = require("@langchain/aws");
|
|
25
|
-
var
|
|
26
|
+
var import_node_http_handler = require("@smithy/node-http-handler");
|
|
26
27
|
var import_httpProxyAgent = require("../../../utils/httpProxyAgent");
|
|
27
28
|
var import_sharedFields = require("../../../utils/sharedFields");
|
|
29
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
28
30
|
var import_n8nLlmFailedAttemptHandler = require("../n8nLlmFailedAttemptHandler");
|
|
29
31
|
var import_N8nLlmTracing = require("../N8nLlmTracing");
|
|
30
32
|
class LmChatAwsBedrock {
|
|
@@ -233,19 +235,28 @@ class LmChatAwsBedrock {
|
|
|
233
235
|
const credentials = await this.getCredentials("aws");
|
|
234
236
|
const modelName = this.getNodeParameter("model", itemIndex);
|
|
235
237
|
const options = this.getNodeParameter("options", itemIndex, {});
|
|
236
|
-
const
|
|
238
|
+
const proxyAgent = (0, import_httpProxyAgent.getNodeProxyAgent)();
|
|
239
|
+
const clientConfig = {
|
|
237
240
|
region: credentials.region,
|
|
238
|
-
model: modelName,
|
|
239
|
-
temperature: options.temperature,
|
|
240
|
-
maxTokens: options.maxTokensToSample,
|
|
241
|
-
clientConfig: {
|
|
242
|
-
httpAgent: (0, import_httpProxyAgent.getProxyAgent)()
|
|
243
|
-
},
|
|
244
241
|
credentials: {
|
|
245
242
|
secretAccessKey: credentials.secretAccessKey,
|
|
246
243
|
accessKeyId: credentials.accessKeyId,
|
|
247
|
-
sessionToken: credentials.sessionToken
|
|
248
|
-
}
|
|
244
|
+
...credentials.sessionToken && { sessionToken: credentials.sessionToken }
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
if (proxyAgent) {
|
|
248
|
+
clientConfig.requestHandler = new import_node_http_handler.NodeHttpHandler({
|
|
249
|
+
httpAgent: proxyAgent,
|
|
250
|
+
httpsAgent: proxyAgent
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
const client = new import_client_bedrock_runtime.BedrockRuntimeClient(clientConfig);
|
|
254
|
+
const model = new import_aws.ChatBedrockConverse({
|
|
255
|
+
client,
|
|
256
|
+
model: modelName,
|
|
257
|
+
region: credentials.region,
|
|
258
|
+
temperature: options.temperature,
|
|
259
|
+
maxTokens: options.maxTokensToSample,
|
|
249
260
|
callbacks: [new import_N8nLlmTracing.N8nLlmTracing(this)],
|
|
250
261
|
onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this)
|
|
251
262
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.ts"],"sourcesContent":["import { ChatBedrockConverse } from '@langchain/aws';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatAwsBedrock implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'AWS Bedrock Chat Model',\n\n\t\tname: 'lmChatAwsBedrock',\n\t\ticon: 'file:bedrock.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Language Model AWS Bedrock',\n\t\tdefaults: {\n\t\t\tname: 'AWS Bedrock Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatawsbedrock/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'aws',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL: '=https://bedrock.{{$credentials?.region ?? \"eu-central-1\"}}.amazonaws.com',\n\t\t},\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Model Source',\n\t\t\t\tname: 'modelSource',\n\t\t\t\ttype: 'options',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'On-Demand Models',\n\t\t\t\t\t\tvalue: 'onDemand',\n\t\t\t\t\t\tdescription: 'Standard foundation models with on-demand pricing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Inference Profiles',\n\t\t\t\t\t\tvalue: 'inferenceProfile',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Cross-region inference profiles (required for models like Claude Sonnet 4 and others)',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'onDemand',\n\t\t\t\tdescription: 'Choose between on-demand foundation models or inference profiles',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'options',\n\t\t\t\tallowArbitraryValues: true, // Hide issues when model name is specified in the expression and does not match any of the options\n\t\t\t\tdescription:\n\t\t\t\t\t'The model which will generate the completion. <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/foundation-models.html\">Learn more</a>.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\tmodelSource: ['inferenceProfile'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['modelSource'],\n\t\t\t\t\tloadOptions: {\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '/foundation-models?&byOutputModality=TEXT&byInferenceType=ON_DEMAND',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tproperty: 'modelSummaries',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tname: '={{$responseItem.modelName}}',\n\t\t\t\t\t\t\t\t\t\t\tdescription: '={{$responseItem.modelArn}}',\n\t\t\t\t\t\t\t\t\t\t\tvalue: '={{$responseItem.modelId}}',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trouting: {\n\t\t\t\t\tsend: {\n\t\t\t\t\t\ttype: 'body',\n\t\t\t\t\t\tproperty: 'model',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'options',\n\t\t\t\tallowArbitraryValues: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'The inference profile which will generate the completion. <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-use.html\">Learn more</a>.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmodelSource: ['inferenceProfile'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['modelSource'],\n\t\t\t\t\tloadOptions: {\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '/inference-profiles?maxResults=1000',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tproperty: 'inferenceProfileSummaries',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tname: '={{$responseItem.inferenceProfileName}}',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'={{$responseItem.description || $responseItem.inferenceProfileArn}}',\n\t\t\t\t\t\t\t\t\t\t\tvalue: '={{$responseItem.inferenceProfileId}}',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trouting: {\n\t\t\t\t\tsend: {\n\t\t\t\t\t\ttype: 'body',\n\t\t\t\t\t\tproperty: 'model',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokensToSample',\n\t\t\t\t\t\tdefault: 2000,\n\t\t\t\t\t\tdescription: 'The maximum number of tokens to generate in the completion',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('aws');\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\ttemperature: number;\n\t\t\tmaxTokensToSample: number;\n\t\t};\n\n\t\tconst model = new ChatBedrockConverse({\n\t\t\tregion: credentials.region as string,\n\t\t\tmodel: modelName,\n\t\t\ttemperature: options.temperature,\n\t\t\tmaxTokens: options.maxTokensToSample,\n\t\t\tclientConfig: {\n\t\t\t\thttpAgent: getProxyAgent(),\n\t\t\t},\n\t\t\tcredentials: {\n\t\t\t\tsecretAccessKey: credentials.secretAccessKey as string,\n\t\t\t\taccessKeyId: credentials.accessKeyId as string,\n\t\t\t\tsessionToken: credentials.sessionToken as string,\n\t\t\t},\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoC;AACpC,0BAMO;AAEP,4BAA8B;AAC9B,0BAA6C;AAE7C,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,2BAA2B;A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mChatAwsBedrock/LmChatAwsBedrock.node.ts"],"sourcesContent":["import type { BedrockRuntimeClientConfig } from '@aws-sdk/client-bedrock-runtime';\nimport { BedrockRuntimeClient } from '@aws-sdk/client-bedrock-runtime';\nimport { ChatBedrockConverse } from '@langchain/aws';\nimport { NodeHttpHandler } from '@smithy/node-http-handler';\nimport { getNodeProxyAgent } from '@utils/httpProxyAgent';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatAwsBedrock implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'AWS Bedrock Chat Model',\n\n\t\tname: 'lmChatAwsBedrock',\n\t\ticon: 'file:bedrock.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Language Model AWS Bedrock',\n\t\tdefaults: {\n\t\t\tname: 'AWS Bedrock Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatawsbedrock/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'aws',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL: '=https://bedrock.{{$credentials?.region ?? \"eu-central-1\"}}.amazonaws.com',\n\t\t},\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Model Source',\n\t\t\t\tname: 'modelSource',\n\t\t\t\ttype: 'options',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'On-Demand Models',\n\t\t\t\t\t\tvalue: 'onDemand',\n\t\t\t\t\t\tdescription: 'Standard foundation models with on-demand pricing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Inference Profiles',\n\t\t\t\t\t\tvalue: 'inferenceProfile',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Cross-region inference profiles (required for models like Claude Sonnet 4 and others)',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'onDemand',\n\t\t\t\tdescription: 'Choose between on-demand foundation models or inference profiles',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'options',\n\t\t\t\tallowArbitraryValues: true, // Hide issues when model name is specified in the expression and does not match any of the options\n\t\t\t\tdescription:\n\t\t\t\t\t'The model which will generate the completion. <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/foundation-models.html\">Learn more</a>.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\tmodelSource: ['inferenceProfile'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['modelSource'],\n\t\t\t\t\tloadOptions: {\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '/foundation-models?&byOutputModality=TEXT&byInferenceType=ON_DEMAND',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tproperty: 'modelSummaries',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tname: '={{$responseItem.modelName}}',\n\t\t\t\t\t\t\t\t\t\t\tdescription: '={{$responseItem.modelArn}}',\n\t\t\t\t\t\t\t\t\t\t\tvalue: '={{$responseItem.modelId}}',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trouting: {\n\t\t\t\t\tsend: {\n\t\t\t\t\t\ttype: 'body',\n\t\t\t\t\t\tproperty: 'model',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'options',\n\t\t\t\tallowArbitraryValues: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'The inference profile which will generate the completion. <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-use.html\">Learn more</a>.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmodelSource: ['inferenceProfile'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['modelSource'],\n\t\t\t\t\tloadOptions: {\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '/inference-profiles?maxResults=1000',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tproperty: 'inferenceProfileSummaries',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tname: '={{$responseItem.inferenceProfileName}}',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'={{$responseItem.description || $responseItem.inferenceProfileArn}}',\n\t\t\t\t\t\t\t\t\t\t\tvalue: '={{$responseItem.inferenceProfileId}}',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trouting: {\n\t\t\t\t\tsend: {\n\t\t\t\t\t\ttype: 'body',\n\t\t\t\t\t\tproperty: 'model',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokensToSample',\n\t\t\t\t\t\tdefault: 2000,\n\t\t\t\t\t\tdescription: 'The maximum number of tokens to generate in the completion',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\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.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tregion: string;\n\t\t\tsecretAccessKey: string;\n\t\t\taccessKeyId: string;\n\t\t\tsessionToken: string;\n\t\t}>('aws');\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\ttemperature: number;\n\t\t\tmaxTokensToSample: number;\n\t\t};\n\n\t\t// We set-up client manually to pass httpAgent and httpsAgent\n\t\tconst proxyAgent = getNodeProxyAgent();\n\t\tconst clientConfig: BedrockRuntimeClientConfig = {\n\t\t\tregion: credentials.region,\n\t\t\tcredentials: {\n\t\t\t\tsecretAccessKey: credentials.secretAccessKey,\n\t\t\t\taccessKeyId: credentials.accessKeyId,\n\t\t\t\t...(credentials.sessionToken && { sessionToken: credentials.sessionToken }),\n\t\t\t},\n\t\t};\n\n\t\tif (proxyAgent) {\n\t\t\tclientConfig.requestHandler = new NodeHttpHandler({\n\t\t\t\thttpAgent: proxyAgent,\n\t\t\t\thttpsAgent: proxyAgent,\n\t\t\t});\n\t\t}\n\n\t\t// Pass the pre-configured client to avoid credential resolution proxy issues\n\t\tconst client = new BedrockRuntimeClient(clientConfig);\n\n\t\tconst model = new ChatBedrockConverse({\n\t\t\tclient,\n\t\t\tmodel: modelName,\n\t\t\tregion: credentials.region,\n\t\t\ttemperature: options.temperature,\n\t\t\tmaxTokens: options.maxTokensToSample,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAqC;AACrC,iBAAoC;AACpC,+BAAgC;AAChC,4BAAkC;AAClC,0BAA6C;AAC7C,0BAMO;AAEP,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;A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,IAAI,mDAAqB,YAAY;AAEpD,UAAM,QAAQ,IAAI,+BAAoB;AAAA,MACrC;AAAA,MACA,OAAO;AAAA,MACP,QAAQ,YAAY;AAAA,MACpB,aAAa,QAAQ;AAAA,MACrB,WAAW,QAAQ;AAAA,MACnB,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,MACnC,qBAAiB,kEAA+B,IAAI;AAAA,IACrD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
@@ -64,7 +64,8 @@ async function connectAndGetTools(ctx, config) {
|
|
|
64
64
|
endpointUrl: config.endpointUrl,
|
|
65
65
|
headers,
|
|
66
66
|
name: node.type,
|
|
67
|
-
version: node.typeVersion
|
|
67
|
+
version: node.typeVersion,
|
|
68
|
+
onUnauthorized: async (headers2) => await (0, import_utils.tryRefreshOAuth2Token)(ctx, config.authentication, headers2)
|
|
68
69
|
});
|
|
69
70
|
if (!client.ok) {
|
|
70
71
|
return { client, mcpTools: null, error: client.error };
|
|
@@ -128,6 +129,15 @@ class McpClientTool {
|
|
|
128
129
|
authentication: ["headerAuth"]
|
|
129
130
|
}
|
|
130
131
|
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "mcpOAuth2Api",
|
|
135
|
+
required: true,
|
|
136
|
+
displayOptions: {
|
|
137
|
+
show: {
|
|
138
|
+
authentication: ["mcpOAuth2Api"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
],
|
|
133
143
|
properties: [
|
|
@@ -195,7 +205,42 @@ class McpClientTool {
|
|
|
195
205
|
}
|
|
196
206
|
],
|
|
197
207
|
default: "none",
|
|
198
|
-
description: "The way to authenticate with your endpoint"
|
|
208
|
+
description: "The way to authenticate with your endpoint",
|
|
209
|
+
displayOptions: {
|
|
210
|
+
show: {
|
|
211
|
+
"@version": [{ _cnd: { lt: 1.2 } }]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
displayName: "Authentication",
|
|
217
|
+
name: "authentication",
|
|
218
|
+
type: "options",
|
|
219
|
+
options: [
|
|
220
|
+
{
|
|
221
|
+
name: "MCP OAuth2",
|
|
222
|
+
value: "mcpOAuth2Api"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "Bearer Auth",
|
|
226
|
+
value: "bearerAuth"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "Header Auth",
|
|
230
|
+
value: "headerAuth"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "None",
|
|
234
|
+
value: "none"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
default: "none",
|
|
238
|
+
description: "The way to authenticate with your endpoint",
|
|
239
|
+
displayOptions: {
|
|
240
|
+
show: {
|
|
241
|
+
"@version": [{ _cnd: { gte: 1.2 } }]
|
|
242
|
+
}
|
|
243
|
+
}
|
|
199
244
|
},
|
|
200
245
|
{
|
|
201
246
|
displayName: "Credentials",
|
|
@@ -204,7 +249,7 @@ class McpClientTool {
|
|
|
204
249
|
default: "",
|
|
205
250
|
displayOptions: {
|
|
206
251
|
show: {
|
|
207
|
-
authentication: ["headerAuth", "bearerAuth"]
|
|
252
|
+
authentication: ["headerAuth", "bearerAuth", "mcpOAuth2Api"]
|
|
208
253
|
}
|
|
209
254
|
}
|
|
210
255
|
},
|