auto-gpt-ts
Version:
my take of Auto-GPT in typescript
113 lines • 5.65 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkOpenaiApiKey = exports.Config = void 0;
const singelton_1 = require("../singelton");
const logging_1 = require("../logging");
let Config = class Config extends logging_1.Loggable {
constructor() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
super(...arguments);
this.disabledCommandCategories = [];
this.workspacePath = "./workspace";
this.fileLoggerPath = "./logs/gpt.log";
this.aiRole = "assistant";
this.debugMode = false;
this.continuousMode = false;
this.continuousLimit = 0;
this.speakMode = false;
this.skipReprompt = false;
this.allowDownloads = false;
this.skipNews = false;
this.currentGeoLocation = process.env.CURRENT_GEO_LOCATION || "";
this.currentTimeZone = process.env.CURRENT_TIMEZONE || Intl.DateTimeFormat().resolvedOptions().timeZone;
this.useMacOsTts = process.env.USE_MAC_OS_TTS === "True";
this.chatMessagesEnabled = process.env.CHAT_MESSAGES_ENABLED === "True";
this.useBrianTts = process.env.USE_BRIAN_TTS === "True";
this.githubApiKey = process.env.GITHUB_API_KEY;
this.githubUsername = process.env.GITHUB_USERNAME;
this.googleApiKey = process.env.GOOGLE_API_KEY;
this.customSearchEngineId = process.env.CUSTOM_SEARCH_ENGINE_ID;
this.authoriseKey = (_a = process.env.AUTHORISE_COMMAND_KEY) !== null && _a !== void 0 ? _a : "y";
this.exitKey = (_b = process.env.EXIT_KEY) !== null && _b !== void 0 ? _b : "n";
this.aiSettingsFile = (_c = process.env.AI_SETTINGS_FILE) !== null && _c !== void 0 ? _c : "ai_settings.yaml";
this.fastLlmModel = (_d = process.env.FAST_LLM_MODEL) !== null && _d !== void 0 ? _d : "gpt-3.5-turbo";
this.smartLlmModel = (_e = process.env.SMART_LLM_MODEL) !== null && _e !== void 0 ? _e : "gpt-4";
this.fastTokenLimit = parseInt((_f = process.env.FAST_TOKEN_LIMIT) !== null && _f !== void 0 ? _f : "3000", 10);
this.smartTokenLimit = parseInt((_g = process.env.SMART_TOKEN_LIMIT) !== null && _g !== void 0 ? _g : "8000", 10);
this.browseChunkMaxLength = parseInt((_h = process.env.BROWSE_CHUNK_MAX_LENGTH) !== null && _h !== void 0 ? _h : "3000", 10);
this.browseSpacyLanguageModel = (_j = process.env.BROWSE_SPACY_LANGUAGE_MODEL) !== null && _j !== void 0 ? _j : "en_core_web_sm";
this.openaiApiKey = process.env.OPENAI_API_KEY;
this.temperature = parseFloat((_k = process.env.TEMPERATURE) !== null && _k !== void 0 ? _k : "0");
this.useAzure = process.env.USE_AZURE === "True";
this.executeLocalCommands = process.env.EXECUTE_LOCAL_COMMANDS === "True";
this.restrictToWorkspace = process.env.RESTRICT_TO_WORKSPACE === "True";
// User agent header to use when making HTTP requests
// Some websites might just completely deny request with an error code if
// no user agent was found.
this.userAgent = (_l = process.env.USER_AGENT) !== null && _l !== void 0 ? _l : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36";
this.memoryBackend = (_m = process.env.MEMORY_BACKEND) !== null && _m !== void 0 ? _m : "local";
this.memoryIndex = (_o = process.env.MEMORY_INDEX) !== null && _o !== void 0 ? _o : "PGT";
}
;
setContinuousMode(value) {
this.continuousMode = value;
}
setContinuousLimit(value) {
this.continuousLimit = value;
}
setSpeakMode(value) {
this.speakMode = value;
}
setFastLlmModel(value) {
this.fastLlmModel = value;
}
setSmartLlmModel(value) {
this.smartLlmModel = value;
}
setFastTokenLimit(value) {
this.fastTokenLimit = value;
}
setSmartTokenLimit(value) {
this.smartTokenLimit = value;
}
setBrowseChunkMaxLength(value) {
this.browseChunkMaxLength = value;
}
setOpenaiApiKey(value) {
this.openaiApiKey = value;
}
setGoogleApiKey(value) {
this.googleApiKey = value;
}
setCustomSearchEngineId(value) {
this.customSearchEngineId = value;
}
setDebugMode(value) {
console.log("Setting debug mode to", value);
logging_1.Logger.logLevel = value ? logging_1.LogLevel.DEBUG : logging_1.LogLevel.INFO;
this.debugMode = value;
}
setTemperature(value) {
this.temperature = value;
}
};
Config = __decorate([
singelton_1.Singleton
], Config);
exports.Config = Config;
function checkOpenaiApiKey() {
const cfg = new Config();
if (!cfg.openaiApiKey) {
console.log("\x1b[31m%s\x1b[0m", "Please set your OpenAI API key in .env or as an environment variable.");
console.log("You can get your key from https://platform.openai.com/account/api-keys");
process.exit(1);
}
}
exports.checkOpenaiApiKey = checkOpenaiApiKey;
//# sourceMappingURL=config.js.map