datasquirel/dist/package-shared/utils/grab-user-ai-info.js
Benjamin Toby 8ac8b8eb51 Updates
2025-07-28 07:23:45 +01:00

24 lines
1.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = grabUserAIInfo;
const types_1 = require("../types");
function grabUserAIInfo({ userConfig: passedConfig, }) {
const userConfig = passedConfig
? passedConfig
: undefined;
if (!userConfig)
return undefined;
const targetAI = userConfig === null || userConfig === void 0 ? void 0 : userConfig.main.target_ai;
if (!(targetAI === null || targetAI === void 0 ? void 0 : targetAI.name) || !(userConfig === null || userConfig === void 0 ? void 0 : userConfig.main.api_keys))
return undefined;
const targetAIAPIKey = userConfig.main.api_keys[targetAI.name].key;
if (!targetAIAPIKey)
return undefined;
const targetAIOption = types_1.AIOptions.find((aiOpt) => aiOpt.name == targetAI.name);
targetAI.apiKey = targetAIAPIKey;
if (targetAIOption === null || targetAIOption === void 0 ? void 0 : targetAIOption.baseUrl) {
targetAI.baseUrl = targetAIOption.baseUrl;
}
return targetAI;
}