@n8n/n8n-nodes-langchain
Version:
48 lines • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.listModels = listModels;
exports.listInferenceProfiles = listInferenceProfiles;
const listBedrockInferenceProfiles_1 = require("../../../../utils/aws/listBedrockInferenceProfiles");
const resolveBedrockApi_1 = require("../../../../utils/aws/resolveBedrockApi");
async function listModels() {
const api = await (0, resolveBedrockApi_1.resolveBedrockApi)(this);
const [foundationModels, inferenceProfiles] = await Promise.allSettled([
this.helpers.httpRequestWithAuthentication.call(this, api.credentialsType, {
method: 'GET',
baseURL: api.baseURL,
url: '/foundation-models?&byOutputModality=TEXT&byInferenceType=ON_DEMAND',
json: true,
}),
(0, listBedrockInferenceProfiles_1.listBedrockInferenceProfiles)(this, api),
]);
if (foundationModels.status === 'rejected' && inferenceProfiles.status === 'rejected') {
throw foundationModels.reason;
}
if (foundationModels.status === 'rejected') {
this.logger.warn('Bedrock model listing: foundation-models request failed', {
error: foundationModels.reason,
});
}
if (inferenceProfiles.status === 'rejected') {
this.logger.warn('Bedrock model listing: inference-profiles request failed', {
error: inferenceProfiles.reason,
});
}
const options = [];
if (foundationModels.status === 'fulfilled') {
options.push(...(foundationModels.value.modelSummaries ?? []).map((model) => ({
name: model.modelName,
value: model.modelId,
description: model.modelArn,
})));
}
if (inferenceProfiles.status === 'fulfilled') {
options.push(...inferenceProfiles.value.map(listBedrockInferenceProfiles_1.toProfileOption));
}
return options.sort((a, b) => a.name.localeCompare(b.name));
}
async function listInferenceProfiles() {
const profiles = await (0, listBedrockInferenceProfiles_1.listBedrockInferenceProfiles)(this, await (0, resolveBedrockApi_1.resolveBedrockApi)(this));
return profiles.map(listBedrockInferenceProfiles_1.toProfileOption).sort((a, b) => a.name.localeCompare(b.name));
}
//# sourceMappingURL=listModels.js.map