UNPKG

@n8n/n8n-nodes-langchain

Version:
29 lines • 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.apiRequest = apiRequest; const n8n_workflow_1 = require("n8n-workflow"); async function apiRequest(method, endpoint, parameters) { const { body, qs } = parameters ?? {}; const credentials = await this.getCredentials('ollamaApi'); const apiKey = credentials.apiKey; if (apiKey !== undefined && typeof apiKey !== 'string') { throw new Error('API key must be a string'); } const headers = parameters?.headers ?? {}; if (apiKey) { headers.Authorization = `Bearer ${apiKey}`; } const options = { headers: { 'Content-Type': 'application/json', ...headers, }, method, body, qs, url: (0, n8n_workflow_1.requestUrl) `${credentials.baseUrl}${endpoint}`, json: true, }; return await this.helpers.httpRequestWithAuthentication.call(this, 'ollamaApi', options); } //# sourceMappingURL=index.js.map