UNPKG

n8n-nodes-gigachat

Version:

A user-friendly GigaChat AI (Sber) nodes for n8n

39 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.emLoadGigaChatModels = emLoadGigaChatModels; exports.supplyEmbeddingsModel = supplyEmbeddingsModel; const GigaChatEmbeddingsLcClient_1 = require("../../shared/GigaChatEmbeddingsLcClient"); const GigaChatApiClient_1 = require("../../shared/GigaChatApiClient"); async function emLoadGigaChatModels() { const credentials = await this.getCredentials('gigaChatApi'); await GigaChatApiClient_1.GigaChatApiClient.updateConfig({ credentials: credentials.authorizationKey, scope: credentials.scope || 'GIGACHAT_API_PERS', 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 .filter((model) => model.type === 'embedder') .map((model) => ({ name: model.id, value: model.id, })); } async function supplyEmbeddingsModel(itemIndex) { const credentials = await this.getCredentials('gigaChatApi'); const modelName = this.getNodeParameter('model', itemIndex); await GigaChatEmbeddingsLcClient_1.GigaChatEmbeddingsLcClient.updateConfig({ credentials: credentials.authorizationKey, model: modelName, scope: credentials.scope, authUrl: credentials.base_url ? `${credentials.base_url}/api/v2/oauth` : 'https://ngw.devices.sberbank.ru:9443/api/v2/oauth', }); return { response: GigaChatEmbeddingsLcClient_1.GigaChatEmbeddingsLcClient, }; } //# sourceMappingURL=utils.js.map