""" 小说生成器配置文件 包含各种高级配置选项和预设模板 """ from dataclasses import dataclass from typing import Dict, List, Any, Optional @dataclass class AdvancedNovelConfig: """高级小说生成配置""" # 基础配置 genre: str target_total_chars: int model: str = "qwen-turbo" temperature: float = 0.8 # 质量控制 enable_logic_check: bool = True max_logic_iterations: int = 3 enable_emotion_enhancement: bool = True enable_dialogue_optimization: bool = True # 写作风格 writing_style: str = "balanced" # balanced, literary, commercial, dramatic narrative_perspective: str = "third" # first, third, mixed tone: str = "neutral" # light, neutral, serious, humorous # 内容控制 max_characters: int = 8 # 最大角色数量 min_dialogue_ratio: float = 0.3 # 对话占比最小值 max_description_ratio: float = 0.4 # 描写占比最大值 # 技术参数 segment_size: int = 2000 # 分段处理大小 parallel_workers: int = 3 # 并行处理线程数 retry_attempts: int = 3 # 重试次数 # 预设配置模板 PRESET_CONFIGS = { "精品长篇": AdvancedNovelConfig( genre="都市逆袭", target_total_chars=25000, model="qwen-max", temperature=0.9, enable_logic_check=True, max_logic_iterations=5, writing_style="literary", enable_emotion_enhancement=True, enable_dialogue_optimization=True, max_characters=12, parallel_workers=4 ) } # 写作风格配置 WRITING_STYLES = { "balanced": { "description": "平衡风格,适合大众阅读", "dialogue_ratio": 0.35, "description_ratio": 0.30, "action_ratio": 0.35, "complexity": "medium" }, "literary": { "description": "文学风格,注重深度和内涵", "dialogue_ratio": 0.25, "description_ratio": 0.45, "action_ratio": 0.30, "complexity": "high" }, "commercial": { "description": "商业风格,节奏快,易读", "dialogue_ratio": 0.45, "description_ratio": 0.25, "action_ratio": 0.30, "complexity": "low" }, "dramatic": { "description": "戏剧风格,冲突强烈", "dialogue_ratio": 0.50, "description_ratio": 0.20, "action_ratio": 0.30, "complexity": "medium" } } # 语调配置 TONE_CONFIGS = { "light": { "description": "轻松愉快的语调", "keywords": ["温馨", "轻松", "幽默", "治愈"], "avoid_keywords": ["沉重", "压抑", "悲伤"] }, "neutral": { "description": "中性平衡的语调", "keywords": ["自然", "真实", "平衡"], "avoid_keywords": ["过于夸张", "过于沉重"] }, "serious": { "description": "严肃深刻的语调", "keywords": ["深刻", "思考", "内省", "成长"], "avoid_keywords": ["轻浮", "肤浅"] }, "humorous": { "description": "幽默风趣的语调", "keywords": ["幽默", "风趣", "机智", "轻松"], "avoid_keywords": ["严肃", "沉重", "悲伤"] } } # 题材扩展配置 EXTENDED_GENRES = { "都市逆袭": { "core": "底层主角通过智慧和机遇逐步崛起,每一步都有合理动机和代价", "typical_characters": ["奋斗主角", "贵人导师", "竞争对手", "支持朋友", "家人"], "common_conflicts": ["阶层差距", "能力质疑", "机遇选择", "道德考验"], "emotional_themes": ["自我证明", "成长蜕变", "责任担当", "情感成熟"] }, "甜宠先婚后爱": { "core": "两个有血有肉的人从陌生到相知相爱的心理变化过程", "typical_characters": ["独立女主", "温柔男主", "闺蜜", "家人", "工作伙伴"], "common_conflicts": ["误解矛盾", "价值观差异", "外界阻力", "内心恐惧"], "emotional_themes": ["信任建立", "情感觉醒", "相互理解", "共同成长"] }, "悬疑推理": { "core": "通过逻辑推理和线索收集,逐步揭开真相的智力较量过程", "typical_characters": ["推理主角", "神秘反派", "关键证人", "警方助手", "受害者"], "common_conflicts": ["线索迷雾", "逻辑陷阱", "时间压力", "真相冲击"], "emotional_themes": ["真相追求", "正义坚持", "智慧较量", "人性探索"] }, "末世生存": { "core": "在绝望环境中求生,展现人性光辉与黑暗的生存史诗", "typical_characters": ["生存主角", "幸存团队", "资源争夺者", "希望守护者", "堕落者"], "common_conflicts": ["资源争夺", "环境威胁", "人性考验", "道德选择"], "emotional_themes": ["生存意志", "人性光辉", "团队协作", "希望重燃"] }, "玄幻升级": { "core": "在奇幻世界中通过修炼和历练不断突破自我的成长之路", "typical_characters": ["修炼主角", "师父导师", "同门师兄", "强敌对手", "红颜知己"], "common_conflicts": ["境界瓶颈", "强敌挑战", "门派争斗", "天道考验"], "emotional_themes": ["修炼感悟", "师徒情深", "友情考验", "爱情升华"] }, "校园青春": { "core": "青春期的成长、友情、初恋和自我发现的故事", "typical_characters": ["青涩主角", "初恋对象", "好友团体", "老师", "家长"], "common_conflicts": ["学业压力", "情感困惑", "友情考验", "家庭期待"], "emotional_themes": ["青春迷茫", "初恋美好", "友情珍贵", "成长痛苦"] }, "职场励志": { "core": "职场新人或转型者在工作中的成长和突破", "typical_characters": ["职场新人", "严厉上司", "竞争同事", "导师前辈", "客户"], "common_conflicts": ["工作挑战", "人际关系", "职业选择", "价值冲突"], "emotional_themes": ["专业成长", "自我价值", "团队合作", "领导力"] }, "家庭温情": { "core": "家庭成员之间的情感纠葛和最终和解", "typical_characters": ["家庭成员", "长辈", "晚辈", "亲戚", "邻居"], "common_conflicts": ["代沟问题", "价值观差异", "生活压力", "情感隔阂"], "emotional_themes": ["亲情珍贵", "理解包容", "传承责任", "家庭和谐"] } } def get_preset_config(preset_name: str) -> Optional[AdvancedNovelConfig]: """获取预设配置""" return PRESET_CONFIGS.get(preset_name) def get_writing_style_info(style: str) -> Dict[str, Any]: """获取写作风格信息""" return WRITING_STYLES.get(style, WRITING_STYLES["balanced"]) def get_tone_info(tone: str) -> Dict[str, Any]: """获取语调信息""" return TONE_CONFIGS.get(tone, TONE_CONFIGS["neutral"]) def get_genre_info(genre: str) -> Dict[str, Any]: """获取题材信息""" return EXTENDED_GENRES.get(genre, EXTENDED_GENRES["都市逆袭"]) def list_available_presets() -> List[str]: """列出可用的预设配置""" return list(PRESET_CONFIGS.keys()) def list_available_genres() -> List[str]: """列出可用的题材""" return list(EXTENDED_GENRES.keys()) def list_available_styles() -> List[str]: """列出可用的写作风格""" return list(WRITING_STYLES.keys()) def list_available_tones() -> List[str]: """列出可用的语调""" return list(TONE_CONFIGS.keys())