feat: support old title placeholder in title prompts
This commit is contained in:
@@ -127,11 +127,7 @@ def gen_title(
|
||||
payload = _chat_payload(
|
||||
model,
|
||||
[
|
||||
{"role": "system", "content": str(title_prompt or "").strip()},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "旧标题:\n%s\n\n请只返回新标题,不要解释。" % str(old_title or ""),
|
||||
},
|
||||
{"role": "user", "content": _compose_title_prompt(title_prompt, old_title)},
|
||||
],
|
||||
)
|
||||
attempts = _attempt_count(ai_cfg, retry)
|
||||
@@ -840,7 +836,7 @@ def _gen_title_cmhub(
|
||||
resolution = _normalize_cmhub_resolution(ai_cfg.get("resolution", "1k"))
|
||||
_notify_step(on_step, "title_build_request")
|
||||
payload = {
|
||||
"prompt": _cmhub_title_prompt(title_prompt, old_title),
|
||||
"prompt": _compose_title_prompt(title_prompt, old_title),
|
||||
"model": runtime["alias"],
|
||||
"resolution": resolution,
|
||||
}
|
||||
@@ -1045,11 +1041,16 @@ def _cmhub_runtime(config, operation, cmhub_config_path):
|
||||
}
|
||||
|
||||
|
||||
def _cmhub_title_prompt(title_prompt, old_title):
|
||||
return "%s\n\n旧标题:\n%s\n\n请只返回新标题,不要解释。" % (
|
||||
str(title_prompt or "").strip(),
|
||||
str(old_title or ""),
|
||||
)
|
||||
def _compose_title_prompt(title_prompt, old_title):
|
||||
prompt = str(title_prompt or "").strip()
|
||||
old_title_text = str(old_title or "")
|
||||
if "{旧标题}" in prompt:
|
||||
body = prompt.replace("{旧标题}", old_title_text).strip()
|
||||
else:
|
||||
body = "%s\n\n旧标题:\n%s" % (prompt, old_title_text)
|
||||
if body:
|
||||
return "%s\n\n请只返回新标题,不要解释。" % body
|
||||
return "请只返回新标题,不要解释。"
|
||||
|
||||
|
||||
def _normalize_cmhub_resolution(resolution):
|
||||
|
||||
Reference in New Issue
Block a user