UNPKG

@n8n/n8n-nodes-langchain

Version:

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

38 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.apiRequest = apiRequest; async function apiRequest(method, endpoint, parameters) { const { body, qs, option } = parameters ?? {}; const credentials = await this.getCredentials('openAiApi'); let uri = `https://api.openai.com/v1${endpoint}`; let headers = parameters?.headers ?? {}; if (credentials.url) { uri = `${credentials?.url}${endpoint}`; } if (credentials.header && typeof credentials.headerName === 'string' && credentials.headerName && typeof credentials.headerValue === 'string') { headers = { ...headers, [credentials.headerName]: credentials.headerValue, }; } const options = { headers, method, body, qs, uri, json: true, }; if (option && Object.keys(option).length !== 0) { Object.assign(options, option); } const response = await this.helpers.requestWithAuthentication.call(this, 'openAiApi', options); if (response && response.error === null) { response.error = undefined; } return response; } //# sourceMappingURL=index.js.map