n8n-nodes-gigachat
Version:
A user-friendly GigaChat AI (Sber) nodes for n8n
37 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLangchainGigaChatModels = getLangchainGigaChatModels;
exports.supplyLangchainGigaChatInstance = supplyLangchainGigaChatInstance;
const GigaChatApiClient_1 = require("../../shared/GigaChatApiClient");
const GigaChatLcClient_1 = require("../../shared/GigaChatLcClient");
async function getLangchainGigaChatModels() {
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 === 'chat')
.map((model) => ({
name: model.id,
value: model.id,
}));
}
async function supplyLangchainGigaChatInstance(itemIndex) {
const credentials = await this.getCredentials('gigaChatApi');
const modelName = this.getNodeParameter('model', itemIndex);
await GigaChatLcClient_1.GigaChatLcClient.updateConfig({
credentials: credentials.authorizationKey,
model: modelName,
scope: credentials.scope,
authUrl: credentials.base_url || 'https://ngw.devices.sberbank.ru:9443/api/v2/oauth',
});
return {
response: GigaChatLcClient_1.GigaChatLcClient,
};
}
//# sourceMappingURL=utils.js.map