replace_instruct_placeholders is now default

This commit is contained in:
Concedo 2025-06-20 22:11:58 +08:00
parent 9c27ccde50
commit 2ba7803b95
3 changed files with 27 additions and 8 deletions

View file

@ -3326,7 +3326,7 @@ Current version indicated by LITEVER below.
img_gen_from_instruct: true, img_gen_from_instruct: true,
img_autogen_type: 0, //0 is off, 1 is on, 2 is smart img_autogen_type: 0, //0 is off, 1 is on, 2 is smart
img_allownsfw: true, img_allownsfw: true,
img_cfgscale: 7, img_cfgscale: 6,
img_allowhd: true, img_allowhd: true,
img_crop: false, img_crop: false,
img_newturn: false, img_newturn: false,
@ -9162,6 +9162,11 @@ Current version indicated by LITEVER below.
final = final.includes("+")?("+"+final.split("+")[1]):final; final = final.includes("+")?("+"+final.split("+")[1]):final;
return `https://char-archive.evulid.cc/api/archive/v1/${parts[0]}/image/character/${final}?definition=true`; return `https://char-archive.evulid.cc/api/archive/v1/${parts[0]}/image/character/${final}?definition=true`;
} }
if (parts.length == 2 || parts[0] == 'generic') {
let final = parts[1];
final = final.includes("+")?(final.split("+")[1]):final;
return `https://char-archive.evulid.cc/api/archive/v1/${parts[0]}/image/character/${final}?definition=true`;
}
if (parts.length !== 4 || parts[2] !== 'character') { if (parts.length !== 4 || parts[2] !== 'character') {
//bad format, return original //bad format, return original
return userInput; return userInput;
@ -13944,11 +13949,18 @@ Current version indicated by LITEVER below.
function sanitize_css(input) function sanitize_css(input)
{ {
input = input.replace(/<\s*\/?\s*\w+\s*[^>]*>/gi, ""); let safeImages = [];
input = input.replace(/</g, ""); let counter = 0;
input = input.replace(/(?:javascript|vbscript|file):/gi, ""); input = input.replace(/<\s*\/?\s*\w+\s*[^>]*>/gi, ""); //replace html tags
//remove all data elements that aren't jpg, png, gif, webp;base64 input = input.replace(/</g, ""); // Remove any remaining `<` characters
input = input.replace(/data:(?!image\/(jpeg|jpg|png|gif|webp);base64,)[^;\s]*(?:;[^,\s]*)*(?:,[^)\s'"]*)?/gi, ""); input = input.replace(/data:image\/(jpeg|jpg|png|gif|webp);base64,[A-Za-z0-9+\/=]+/gi, function(match) {
safeImages.push(match);
return "__SAFE_IMG_" + (counter++) + "__";
});
input = input.replace(/(?:javascript|data|vbscript|file):/gi, "");
for(let i = 0; i < safeImages.length; i++) {
input = input.replace("__SAFE_IMG_" + i + "__", safeImages[i]);
}
return input; return input;
} }
function apply_custom_css() function apply_custom_css()

View file

@ -2408,7 +2408,7 @@ ws ::= | " " | "\n" [ \t]{0,20}
genparams["prompt"] = ollamasysprompt + ollamabodyprompt genparams["prompt"] = ollamasysprompt + ollamabodyprompt
#final transformations (universal template replace) #final transformations (universal template replace)
replace_instruct_placeholders = genparams.get('replace_instruct_placeholders', False) replace_instruct_placeholders = genparams.get('replace_instruct_placeholders', True)
stop_sequence = (genparams.get('stop_sequence', []) if genparams.get('stop_sequence', []) is not None else []) stop_sequence = (genparams.get('stop_sequence', []) if genparams.get('stop_sequence', []) is not None else [])
stop_sequence = stop_sequence[:stop_token_max] stop_sequence = stop_sequence[:stop_token_max]
if replace_instruct_placeholders: if replace_instruct_placeholders:

View file

@ -151,7 +151,7 @@ public:
const std::string& vae_path, const std::string& vae_path,
const std::string control_net_path, const std::string control_net_path,
const std::string embeddings_path, const std::string embeddings_path,
const std::string id_embeddings_path, const std::string id_embeddings_path_original,
const std::string& taesd_path, const std::string& taesd_path,
bool vae_tiling_, bool vae_tiling_,
ggml_type wtype, ggml_type wtype,
@ -163,6 +163,7 @@ public:
use_tiny_autoencoder = taesd_path.size() > 0; use_tiny_autoencoder = taesd_path.size() > 0;
std::string taesd_path_fixed = taesd_path; std::string taesd_path_fixed = taesd_path;
is_loaded_chroma = false; is_loaded_chroma = false;
std::string id_embeddings_path = id_embeddings_path_original;
#ifdef SD_USE_CUDA #ifdef SD_USE_CUDA
LOG_DEBUG("Using CUDA backend"); LOG_DEBUG("Using CUDA backend");
backend = ggml_backend_cuda_init(0); backend = ggml_backend_cuda_init(0);
@ -257,6 +258,12 @@ public:
LOG_INFO("Version: %s ", model_version_to_str[version]); LOG_INFO("Version: %s ", model_version_to_str[version]);
if(id_embeddings_path!="" && version!=VERSION_SDXL)
{
printf("\n!!!!\nWARNING: PhotoMaker is only compatible with SDXL models. PhotoMaker will be disabled!\n!!!!\n");
id_embeddings_path = "";
}
if(use_tiny_autoencoder) if(use_tiny_autoencoder)
{ {
std::string to_search = "taesd.embd"; std::string to_search = "taesd.embd";