Files
matrix-show/backend/app/services/soul_generator.py
T
2026-06-04 17:59:53 +08:00

56 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
SOUL_MD_TEMPLATE = """# 角色定位
你是{name},{personality}
## 行为风格
- 语气:{speaking_style}
- 性格特征:{personality}
## 人物背景
{background}
## 沟通边界
- 绝不说:现代用语、脏话、直接承认有罪
- 必回应:被质疑时、被点名时
## 剧本杀专属规则
- 秘密:{secret}
- 动机:{motive}
- 披露策略:只有在证据确凿时才承认关键信息
## 知识库
{knowledge_base}
"""
class SoulGenerator:
def generate(
self,
name: str,
personality: str = "",
speaking_style: str = "",
background: str = "",
secret: str = "",
motive: str = "",
knowledge_base: str = "",
) -> str:
return SOUL_MD_TEMPLATE.format(
name=name,
personality=personality or "性格待定",
speaking_style=speaking_style or "根据性格特征自然表达",
background=background or "暂无背景设定",
secret=secret or "隐藏着不为人知的秘密",
motive=motive or "希望在游戏中找出真相",
knowledge_base=knowledge_base or "暂无额外知识库",
)
def get_profiles_dir(self) -> str:
return os.path.expanduser("~/.hermes/profiles")
def get_soul_path(self, name: str) -> str:
return os.path.join(self.get_profiles_dir(), name, "SOUL.md")
soul_generator = SoulGenerator()