@synthart/synthlite
Version:
A fast, lightweight Gen AI powered synthetic data generator written in TypeScript. 🌞
63 lines (62 loc) • 2.07 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
/**
*
* @file config.ts
* @author Aditya Patange (AdiPat) <contact.adityapatange@gmail.com>
* @description Config class for handling configuration operations.
* @date January 2024
* @version 1.0.0
* @license Affero General Public License v3.0
* ✨ "I can feel your energy from two planets away I got my drink I got my music..." — Kendrick Lamar
*
*/
const printer_1 = require("./printer");
const dotenv_1 = __importDefault(require("dotenv"));
/**
* Config: Handles configuration operations.
* @class Config
*/
class Config {
/**
* Asserts the presence of AI configuration in the environment.
* @returns void
*/
static assertAIConfig() {
if (process.env.ANTHROPIC_API_KEY) {
printer_1.printer.debug("ANTHROPIC_API_KEY found in environment.");
return;
}
else {
printer_1.printer.debug("No ANTHROPIC_API_KEY found in environment. Falling back to GROQ API.");
}
if (process.env.GROQ_API_KEY) {
printer_1.printer.debug("GROQ_API_KEY found in environment.");
return;
}
else {
printer_1.printer.debug("No GROQ_API_KEY found in environment.");
}
printer_1.printer.error("Please add either GROQ_API_KEY or ANTHROPIC_API_KEY to your environment file.");
process.exit(1);
}
/**
* Loads the environment file.
* @param envPath The path to the environment file.
* @returns void
*/
static loadEnv(envPath) {
try {
dotenv_1.default.config({ path: envPath });
}
catch (error) {
printer_1.printer.error("Error loading environment file. Please specify the correct environment file using -env option.");
process.exit(1);
}
}
}
exports.Config = Config;