This commit is contained in:
wailovet
2024-04-30 23:03:36 +08:00
parent cc50ac71e5
commit 1a14e7de8f
2 changed files with 12 additions and 10 deletions
+2 -2
View File
@@ -83,8 +83,8 @@ class MZ_CustomizeInstruct:
"required": {
"system": ("STRING", {"multiline": True, "default": mz_prompts.Long_prompt}),
"instruct": ("STRING", {"multiline": True, "default": "Short: {text}"}),
"prefix": ("STRING", {"default": "Long: "}),
"suffix": ("STRING", {"default": ""}),
"start_str": ("STRING", {"default": "Long: "}),
"end_str": ("STRING", {"default": ""}),
},
}
+10 -8
View File
@@ -529,15 +529,17 @@ def base_query_beautify_prompt_text(args_dict):
options=options,
)
prefix = customize_instruct.get("prefix", "")
# 去除前缀
if prefix != "":
full_response = full_response.lstrip(prefix)
start_str = customize_instruct.get("start_str", "")
if start_str != "" and full_response.find(start_str) != -1:
full_response_list = full_response.split(start_str)
full_response_list[0] = ""
full_response = start_str.join(full_response_list)
suffix = customize_instruct.get("suffix", "")
# 去除后缀
if suffix != "":
full_response = full_response.rstrip(suffix)
end_str = customize_instruct.get("end_str", "")
if end_str != "" and full_response.find(end_str) != -1:
full_response_list = full_response.split(end_str)
full_response_list[-1] = ""
full_response = end_str.join(full_response_list)
if keep_device is False: