From 2f48fc1d4c80a4c25a04d5f4e1e6c19fbb3528db Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Thu, 23 Apr 2026 11:53:33 +0800
Subject: [PATCH] fix: add kimi to models.ts

---
 aigc-director/aigc-claw/backend/prompts/loader.py |   86 +++++++------------------------------------
 1 files changed, 14 insertions(+), 72 deletions(-)

diff --git a/aigc-director/aigc-claw/backend/prompts/loader.py b/aigc-director/aigc-claw/backend/prompts/loader.py
index a4222b3..40a06e3 100644
--- a/aigc-director/aigc-claw/backend/prompts/loader.py
+++ b/aigc-director/aigc-claw/backend/prompts/loader.py
@@ -24,7 +24,7 @@
         提示词内容字符串
 
     Example:
-        prompt = load_prompt('logline', 'generate', 'zh')
+        prompt = load_prompt('script', 'logline_generate', 'zh')
     """
     # 尝试加载语言版本
     file_path = os.path.join(PROMPTS_DIR, category, f"{name}_{lang}.txt")
@@ -32,7 +32,13 @@
         with open(file_path, 'r', encoding='utf-8') as f:
             return f.read().strip()
 
-    # 回退到中文版本
+    # 回退到带 _zh 的版本
+    file_path = os.path.join(PROMPTS_DIR, category, f"{name}_zh.txt")
+    if os.path.exists(file_path):
+        with open(file_path, 'r', encoding='utf-8') as f:
+            return f.read().strip()
+
+    # 回退到不带后缀的通用版本
     file_path = os.path.join(PROMPTS_DIR, category, f"{name}.txt")
     if os.path.exists(file_path):
         with open(file_path, 'r', encoding='utf-8') as f:
@@ -64,6 +70,12 @@
             with open(file_path, 'r', encoding='utf-8') as f:
                 return f.read().strip()
 
+    # 最后尝试不带后缀的版本
+    file_path = os.path.join(PROMPTS_DIR, category, f"{name}.txt")
+    if os.path.exists(file_path):
+        with open(file_path, 'r', encoding='utf-8') as f:
+            return f.read().strip()
+
     raise FileNotFoundError(f"Prompt not found: {category}/{name}_{lang}.txt")
 
 
@@ -82,73 +94,3 @@
         prompt = format_prompt("Hello {name}, you are {age} years old", name="John", age=30)
     """
     return template.format(**kwargs)
-
-
-# 风格提示词缓存
-_STYLE_PROMPTS_CACHE = {}
-
-
-def load_style_prompt(category: str, style: str) -> str:
-    """
-    加载指定风格的提示词
-
-    Args:
-        category: 提示词分类 (character, setting)
-        style: 风格名称 (realistic, anime, comic-book, 3d-disney, watercolor, oil-painting, cyberpunk, chinese-ink)
-
-    Returns:
-        风格提示词模板
-
-    Example:
-        prompt = load_style_prompt('character', 'realistic')
-    """
-    # 先检查缓存
-    cache_key = f"{category}:{style}"
-    if cache_key in _STYLE_PROMPTS_CACHE:
-        return _STYLE_PROMPTS_CACHE[cache_key]
-
-    # 加载风格提示词文件
-    file_path = os.path.join(PROMPTS_DIR, category, f"{style}_styles.txt")
-    if not os.path.exists(file_path):
-        # 回退到通用的风格文件 (character_styles.txt 或 setting_styles.txt)
-        fallback_file = "character_styles.txt" if category == "character" else "setting_styles.txt"
-        file_path = os.path.join(PROMPTS_DIR, category, fallback_file)
-
-    if not os.path.exists(file_path):
-        fallback_file = "character_styles.txt" if category == "character" else "setting_styles.txt"
-        raise FileNotFoundError(f"Style prompt file not found: {category}/{fallback_file}")
-
-    with open(file_path, 'r', encoding='utf-8') as f:
-        content = f.read()
-
-    # 解析风格块
-    current_style = None
-    style_templates = {}
-    for line in content.split('\n'):
-        line = line.strip()
-        # Skip empty lines and comment lines
-        if not line or line.startswith('#'):
-            continue
-        if line.startswith('[') and line.endswith(']'):
-            current_style = line[1:-1]
-            style_templates[current_style] = []
-        elif current_style and line:
-            style_templates[current_style].append(line)
-
-    # 转换为字符串
-    for s in style_templates:
-        style_templates[s] = '\n'.join(style_templates[s])
-
-    # 缓存所有风格
-    _STYLE_PROMPTS_CACHE.update(style_templates)
-
-    # 返回指定风格的提示词
-    if style in style_templates:
-        return style_templates[style]
-
-    # 回退到 anime 或第一个可用风格
-    if 'anime' in style_templates:
-        return style_templates['anime']
-
-    # 返回第一个可用的风格
-    return list(style_templates.values())[0] if style_templates else ""

--
Gitblit v1.8.0