auto-gpt-ts
Version:
my take of Auto-GPT in typescript
78 lines • 3.58 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConfig = void 0;
const logging_1 = require("./logging");
const config_1 = require("./config/config");
const chalk_1 = __importDefault(require("chalk"));
const utils_1 = require("./utils");
const memory_1 = require("./memory");
const CFG = new config_1.Config();
const logger = (0, logging_1.getLogger)('Configurator');
function createConfig(continuous, continuousLimit, aiSettingsFile, skipReprompt, speak, debug, gpt3only, gpt4only, memoryType, browserName, allowDownloads, skipNews) {
// CFG.set_speak_mode(false); // TODO: implement speak mode
if (debug) {
logger.info("Debug Mode: " + `${chalk_1.default.green("ENABLED")}`);
CFG.setDebugMode(true);
}
if (continuous) {
logger.info("Continuous Mode: " + `${chalk_1.default.red("ENABLED")}`);
logger.warn("WARNING: " +
chalk_1.default.yellow("Continuous mode is not recommended. It is potentially dangerous and may" +
" cause your AI to run forever or carry out actions you would not usually" +
" authorise. Use at your own risk."));
CFG.setContinuousMode(true);
if (continuousLimit) {
logger.info("Continuous Limit: " + chalk_1.default.green(`${continuousLimit}`));
CFG.setContinuousLimit(continuousLimit);
}
}
// Check if continuous limit is used without continuous mode
if (continuousLimit && !continuous) {
throw new Error("--continuous-limit can only be used with --continuous");
}
if (gpt3only) {
logger.info("GPT3.5 Only Mode: " + `${chalk_1.default.green("ENABLED")}`);
CFG.setSmartLlmModel(CFG.fastLlmModel);
}
if (gpt4only) {
logger.info("GPT4 Only Mode: " + `${chalk_1.default.green("ENABLED")}`);
CFG.setFastLlmModel(CFG.smartLlmModel);
}
if (memoryType) {
const supportedMemory = memory_1.supportedMemoryTypes.map((m) => m.memoryName);
const chosen = memoryType;
if (!supportedMemory.includes(chosen)) {
logger.info("ONLY THE FOLLOWING MEMORY BACKENDS ARE SUPPORTED: " + chalk_1.default.red(`${supportedMemory}`));
logger.info("Defaulting to: " + chalk_1.default.yellow(CFG.memoryBackend));
}
else {
CFG.memoryBackend = chosen;
}
}
if (skipReprompt) {
logger.info("Skip Re-prompt: " + `${chalk_1.default.green("ENABLED")}`);
CFG.skipReprompt = true;
}
if (aiSettingsFile) {
const file = aiSettingsFile;
// Validate file
const [validated, message] = (0, utils_1.validateYamlFile)(file);
if (!validated) {
logger.info("FAILED FILE VALIDATION " + `${chalk_1.default.red(message)}`);
process.exit(1);
}
logger.info("Using AI Settings File:" + chalk_1.default.green(`${file}`));
CFG.aiSettingsFile = file;
CFG.skipReprompt = true;
}
if (allowDownloads) {
logger.info("Native Downloading:" + `${chalk_1.default.green("ENABLED")}`);
logger.info("WARNING: " + chalk_1.default.yellow(`Auto-GPT will now be able to download and save files to your machine. It is recommended that you monitor any files it downloads carefully.`));
CFG.allowDownloads = true;
}
}
exports.createConfig = createConfig;
//# sourceMappingURL=configurator.js.map