comfyui-discord/lib/settings.py

47 lines
1.4 KiB
Python

import os
from lib.helpers import *
def get_settings(initialize=False):
settings_path = "settings.json"
default_settings = {
"handler_name": "default",
"token": "PASTE_TOKEN_HERE",
"api_url": "http://127.0.0.1:8188",
"config_dir": "conf/",
"allow_repeat": True,
"show_repeat": True,
"repeat_emoji": "♻️",
"waiting_emoji": "🕒",
"use_spoiler": True,
"defaults": {
"checkpoint_1": "v1-5-pruned-emaonly.safetensors",
"width": 512,
"height": 512,
"cfg": 7,
"steps": 20,
"seed": None,
"positive": "",
"negative": "",
"positive_prefix": "",
"positive_suffix": "",
"negative_prefix": "",
"negative_suffix": "",
"forced_negative_prefix": "((nsfw, nudity))"
},
}
if initialize:
if not os.path.isfile(settings_path):
write_json(settings_path, default_settings)
print(f"A bot token is required, please modify {settings_path} to include the token and rerun this Python script.")
exit()
settings = default_settings.copy()
settings = merge_dicts(settings, read_json(settings_path))
if initialize:
write_json(settings_path, settings)
return settings