n8n-nodes-gigachat
Version:
A user-friendly GigaChat AI (Sber) nodes for n8n
34 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGigaChatModels = getGigaChatModels;
const GigaChatApiClient_1 = require("./GigaChatApiClient");
async function getGigaChatModels() {
const credentials = await this.getCredentials('gigaChatApi');
const nodeName = this.getNode().type;
let filterExpression = '';
if (nodeName.indexOf('apiGigaChat') !== -1) {
filterExpression = 'Embeddings.*';
}
if (nodeName.indexOf('gigaChat') !== -1) {
filterExpression = 'Embeddings.*';
}
if (nodeName.indexOf('emGigaChat') !== -1) {
filterExpression = 'Giga.*';
}
const scope = credentials.scope ? String(credentials.scope) : 'GIGACHAT_API_PERS';
await GigaChatApiClient_1.GigaChatApiClient.updateConfig({
credentials: credentials.authorizationKey,
scope: scope,
authUrl: credentials.base_url
? `${credentials.base_url}/api/v2/oauth`
: 'https://ngw.devices.sberbank.ru:9443/api/v2/oauth',
});
const response = await GigaChatApiClient_1.GigaChatApiClient.getModels();
return response.data
.map((model) => ({
name: model.id,
value: model.id,
}))
.filter((model) => !model.value.match(new RegExp(filterExpression, 'gi')));
}
//# sourceMappingURL=GigaChatModels.js.map