Universal Model Settings

No longer depends on a local config file enabling the configuration to work in --colab mode.
This commit is contained in:
henk717 2022-01-20 10:11:11 +01:00
parent c25e2a33f1
commit 9532b56cb8
1 changed files with 29 additions and 30 deletions

View File

@ -2259,34 +2259,32 @@ def loadsettings():
# Allow the models to override some settings # Allow the models to override some settings
#==================================================================# #==================================================================#
def loadmodelsettings(): def loadmodelsettings():
if(path.exists(vars.custmodpth.replace('/', '_') + "/config.json")): model_js_config = str(model_config).partition(' ')[2]
model_config = open(vars.custmodpth.replace('/', '_') + "/config.json", "r") js = json.loads(model_js_config)
js = json.load(model_config) if("badwordsids" in js):
if("badwordsids" in js): vars.badwordsids = js["badwordsids"]
vars.badwordsids = js["badwordsids"] if("temp" in js):
if("temp" in js): vars.temp = js["temp"]
vars.temp = js["temp"] if("top_p" in js):
if("top_p" in js): vars.top_p = js["top_p"]
vars.top_p = js["top_p"] if("top_k" in js):
if("top_k" in js): vars.top_k = js["top_k"]
vars.top_k = js["top_k"] if("tfs" in js):
if("tfs" in js): vars.tfs = js["tfs"]
vars.tfs = js["tfs"] if("rep_pen" in js):
if("rep_pen" in js): vars.rep_pen = js["rep_pen"]
vars.rep_pen = js["rep_pen"] if("adventure" in js):
if("adventure" in js): vars.adventure = js["adventure"]
vars.adventure = js["adventure"] if("chatmode" in js):
if("chatmode" in js): vars.chatmode = js["chatmode"]
vars.chatmode = js["chatmode"] if("dynamicscan" in js):
if("dynamicscan" in js): vars.dynamicscan = js["dynamicscan"]
vars.dynamicscan = js["dynamicscan"] if("formatoptns" in js):
if("formatoptns" in js): vars.formatoptns = js["formatoptns"]
vars.formatoptns = js["formatoptns"] if("antemplate" in js):
if("antemplate" in js): vars.setauthornotetemplate = js["antemplate"]
vars.setauthornotetemplate = js["antemplate"] if(not vars.gamestarted):
if(not vars.gamestarted): vars.authornotetemplate = vars.setauthornotetemplate
vars.authornotetemplate = vars.setauthornotetemplate
model_config.close()
#==================================================================# #==================================================================#
# Don't save settings unless 2 seconds have passed without modification # Don't save settings unless 2 seconds have passed without modification
@ -4552,8 +4550,9 @@ def randomGameRequest(topic, memory=""):
actionsubmit("", force_submit=True, force_prompt_gen=True) actionsubmit("", force_submit=True, force_prompt_gen=True)
vars.memory = memory vars.memory = memory
# Load settings from client.settings # Load desired settings from both the model and the users config file
loadmodelsettings() if(not vars.model in ["InferKit", "Colab", "OAI", "ReadOnly", "TPUMeshTransformerGPTJ"]):
loadmodelsettings()
loadsettings() loadsettings()
# Prevent tokenizer from taking extra time the first time it's used # Prevent tokenizer from taking extra time the first time it's used