added functionality to load and save user-modified settings from a JSON file

This commit is contained in:
uukelele-scratch 2025-03-20 19:52:16 +00:00
parent 2b42f3f6b0
commit 066848b7b8
3 changed files with 65 additions and 1 deletions

47
config.json Normal file
View file

@ -0,0 +1,47 @@
{
"minecraft_version": "1.21.1", // supports up to 1.21.1
"host": "127.0.0.1", // or "localhost", "your.ip.address.here"
"port": 55916,
"auth": "offline", // or "microsoft"
// the mindserver manages all agents and hosts the UI
"host_mindserver": true, // if true, the mindserver will be hosted on this machine. otherwise, specify a public IP address
"mindserver_host": "localhost",
"mindserver_port": 8080,
// the base profile is shared by all bots for default prompts/examples/modes
"base_profile": "./profiles/defaults/survival.json", // also see creative.json, god_mode.json
"profiles": [
"./andy.json",
// "./profiles/gpt.json",
// "./profiles/claude.json",
// "./profiles/gemini.json",
// "./profiles/llama.json",
// "./profiles/qwen.json",
// "./profiles/grok.json",
// "./profiles/mistral.json",
// "./profiles/deepseek.json",
// using more than 1 profile requires you to /msg each bot indivually
// individual profiles override values from the base profile
],
"load_memory": false, // load memory from previous session
"init_message": "Respond with hello world and your name", // sends to all on spawn
"only_chat_with": [], // users that the bots listen to and send general messages to. if empty it will chat publicly
"speak": false, // allows all bots to speak through system text-to-speech. works on windows, mac, on linux you need to `apt install espeak`
"language": "en", // translate to/from this language. Supports these language names: https://cloud.google.com/translate/docs/languages
"show_bot_views": false, // show bot's view in browser at localhost:3000, 3001...
"allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk
"allow_vision": false, // allows vision model to interpret screenshots as inputs
"blocked_actions" : [], // commands to disable and remove from docs. Ex: ["!setMode"]
"code_timeout_mins": -1, // minutes code is allowed to run. -1 for no timeout
"relevant_docs_count": 5, // number of relevant code function docs to select for prompting. -1 for all
"max_messages": 15, // max number of messages to keep in context
"num_examples": 2, // number of examples to give to the model
"max_commands": -1, // max number of commands that can be used in consecutive responses. -1 for no limit
"verbose_commands": true, // show full command syntax
"narrate_behavior": true, // chat simple automatic actions ('Picking up item!')
"chat_bot_messages": true, // publicly chat messages to other bots
}

View file

@ -1,3 +1,6 @@
import fs from 'fs';
import path from 'path';
const settings = { const settings = {
"minecraft_version": "1.21.1", // supports up to 1.21.1 "minecraft_version": "1.21.1", // supports up to 1.21.1
"host": "127.0.0.1", // or "localhost", "your.ip.address.here" "host": "127.0.0.1", // or "localhost", "your.ip.address.here"
@ -46,9 +49,22 @@ const settings = {
"chat_bot_messages": true, // publicly chat messages to other bots "chat_bot_messages": true, // publicly chat messages to other bots
} }
const configPath = path.resolve('./src/server/saved_settings.json'); // This is to save user-modified settings edited via the Mindserver.
if(fs.existsSync(configPath)) {
try {
const newSettings = JSON.parse(fs.readFileSync(configPath, 'utf8'));
Object.assign(settings, newSettings);
} catch (error) {
console.error("Error reading config.json. Using default settings.", error);
}
} else {
fs.writeFileSync(configPath, JSON.stringify(settings, null, 4))
}
// Function to update settings // Function to update settings
export function updateSettings(newSettings) { export function updateSettings(newSettings) {
return Object.assign(settings, newSettings); Object.assign(settings, newSettings);
fs.writeFileSync(configPath, JSON.stringify(settings, null, 4));
} }
// these environment variables override certain settings // these environment variables override certain settings

View file

@ -0,0 +1 @@
{}