fix:1.修复部分提示词模板键名不匹配问题
This commit is contained in:
@@ -420,7 +420,7 @@ async def generate_character(
|
||||
"""
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("SINGLE_CHARACTER", user_id, db)
|
||||
template = await PromptService.get_template("SINGLE_CHARACTER_GENERATION", user_id, db)
|
||||
# 格式化提示词
|
||||
prompt = PromptService.format_prompt(
|
||||
template,
|
||||
@@ -829,7 +829,7 @@ async def generate_character_stream(
|
||||
yield await SSEResponse.send_progress("构建AI提示词...", 20)
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("SINGLE_CHARACTER", user_id, db)
|
||||
template = await PromptService.get_template("SINGLE_CHARACTER_GENERATION", user_id, db)
|
||||
# 格式化提示词
|
||||
prompt = PromptService.format_prompt(
|
||||
template,
|
||||
|
||||
@@ -497,7 +497,7 @@ async def generate_organization(
|
||||
"""
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("SINGLE_ORGANIZATION", user_id, db)
|
||||
template = await PromptService.get_template("SINGLE_ORGANIZATION_GENERATION", user_id, db)
|
||||
# 格式化提示词
|
||||
prompt = PromptService.format_prompt(
|
||||
template,
|
||||
@@ -693,7 +693,7 @@ async def generate_organization_stream(
|
||||
yield await SSEResponse.send_progress("构建AI提示词...", 20)
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("SINGLE_ORGANIZATION", user_id, db)
|
||||
template = await PromptService.get_template("SINGLE_ORGANIZATION_GENERATION", user_id, db)
|
||||
# 格式化提示词
|
||||
prompt = PromptService.format_prompt(
|
||||
template,
|
||||
|
||||
@@ -37,7 +37,7 @@ async def polish_text(
|
||||
user_id = getattr(http_request.state, 'user_id', None)
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("DENOISING", user_id, db)
|
||||
template = await PromptService.get_template("AI_DENOISING", user_id, db)
|
||||
# 格式化提示词
|
||||
prompt = PromptService.format_prompt(
|
||||
template,
|
||||
@@ -111,7 +111,7 @@ async def polish_batch(
|
||||
logger.info(f"处理第 {idx+1}/{len(texts)} 个文本")
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("DENOISING", user_id, db)
|
||||
template = await PromptService.get_template("AI_DENOISING", user_id, db)
|
||||
# 格式化提示词
|
||||
prompt = PromptService.format_prompt(template, original_text=text)
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ async def characters_generator(
|
||||
batch_requirements += "\n主要是配角(supporting)和反派(antagonist)"
|
||||
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("CHARACTERS_BATCH", user_id, db)
|
||||
template = await PromptService.get_template("CHARACTERS_BATCH_GENERATION", user_id, db)
|
||||
# 构建基础提示词
|
||||
base_prompt = PromptService.format_prompt(
|
||||
template,
|
||||
|
||||
@@ -178,7 +178,7 @@ class ChapterRegenerator:
|
||||
) -> str:
|
||||
"""构建完整的重新生成提示词"""
|
||||
# 获取自定义提示词模板
|
||||
template = await PromptService.get_template("CHAPTER_REGENERATION", user_id, db)
|
||||
template = await PromptService.get_template("CHAPTER_REGENERATION_SYSTEM", user_id, db)
|
||||
# 格式化提示词
|
||||
return PromptService.format_prompt(
|
||||
template,
|
||||
|
||||
@@ -2081,7 +2081,26 @@ class PromptService:
|
||||
|
||||
# 2. 降级到系统默认模板
|
||||
logger.info(f"⚪ 使用系统默认提示词: user_id={user_id}, template_key={template_key} (未找到自定义模板)")
|
||||
return getattr(cls, template_key, None)
|
||||
|
||||
# 特殊处理灵感模式的提示词(存储在INSPIRATION_PROMPTS字典中)
|
||||
if template_key.startswith("INSPIRATION_"):
|
||||
# 提取步骤名称(如 INSPIRATION_TITLE -> title)
|
||||
step = template_key.replace("INSPIRATION_", "").lower()
|
||||
inspiration_prompt = cls.INSPIRATION_PROMPTS.get(step)
|
||||
if inspiration_prompt:
|
||||
# 返回JSON格式的提示词
|
||||
return json.dumps(inspiration_prompt, ensure_ascii=False)
|
||||
# 如果是INSPIRATION_QUICK_COMPLETE
|
||||
if template_key == "INSPIRATION_QUICK_COMPLETE":
|
||||
return cls.INSPIRATION_QUICK_COMPLETE
|
||||
|
||||
# 其他模板直接从类属性获取
|
||||
template_content = getattr(cls, template_key, None)
|
||||
|
||||
if template_content is None:
|
||||
logger.warning(f"⚠️ 未找到系统默认模板: {template_key}")
|
||||
|
||||
return template_content
|
||||
|
||||
@classmethod
|
||||
def get_all_system_templates(cls) -> list:
|
||||
|
||||
Reference in New Issue
Block a user