@n8n/n8n-nodes-langchain
Version:

32 lines • 1.07 kB
JavaScript
;
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('ollamaApi');
const apiKey = credentials.apiKey;
if (apiKey !== undefined && typeof apiKey !== 'string') {
throw new Error('API key must be a string');
}
const url = new URL(endpoint, credentials.baseUrl).toString();
const headers = parameters?.headers ?? {};
if (apiKey) {
headers.Authorization = `Bearer ${apiKey}`;
}
const options = {
headers: {
'Content-Type': 'application/json',
...headers,
},
method,
body,
qs,
url,
json: true,
};
if (option && Object.keys(option).length !== 0) {
Object.assign(options, option);
}
return await this.helpers.httpRequestWithAuthentication.call(this, 'ollamaApi', options);
}
//# sourceMappingURL=index.js.map