CFG: Add per-character support

Adds per-character CFG as a drop-in replacement for global CFG. If
the use character CFG checkbox isn't checked, the global one will be
used.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2023-08-09 23:42:04 -04:00
parent 0c94740560
commit 63ee7d4e10
3 changed files with 110 additions and 17 deletions

View File

@@ -1,9 +1,18 @@
import { extension_settings } from "../../extensions.js"
import { getCharaFilename } from "../../utils.js";
// TODO: Update to use per-chat and per-character CFG
export function getCfg() {
return {
guidanceScale: extension_settings.cfg.global.guidance_scale,
negativePrompt: extension_settings.cfg.global.negative_prompt
const charaCfg = extension_settings.cfg.chara.find((e) => e.name === getCharaFilename());
if (charaCfg && charaCfg?.useChara) {
return {
guidanceScale: charaCfg.guidance_scale ?? 1.00,
negativePrompt: charaCfg.negative_prompt ?? ''
}
} else {
return {
guidanceScale: extension_settings.cfg.global.guidance_scale ?? 1.00,
negativePrompt: extension_settings.cfg.global.negative_prompt ?? ''
}
}
}
}