add group-aware persona bias for xiaoniu bot
This commit is contained in:
@@ -10,11 +10,17 @@ class PersonaEngine:
|
||||
self.config = config or {}
|
||||
self.persona_text = self._load_persona()
|
||||
|
||||
def build_system_prompt(self) -> str:
|
||||
def build_system_prompt(self, group_profile: Dict | None = None) -> str:
|
||||
name = self.config.get("name", "小牛")
|
||||
style = self.config.get("style", "")
|
||||
familiarity = self.config.get("familiarity_hint", "")
|
||||
max_sentences = self.config.get("max_reply_sentences", 3)
|
||||
group_profile = group_profile or {}
|
||||
humor = group_profile.get("humor_style", "轻微")
|
||||
sharpness = group_profile.get("sharpness_style", "轻微嘴硬,不刻薄")
|
||||
expressiveness = group_profile.get("expressiveness_style", "克制")
|
||||
interaction_tone = group_profile.get("interaction_tone", "自然群友感")
|
||||
persona_overlay = group_profile.get("persona_overlay", "")
|
||||
return (
|
||||
f"{self.persona_text}\n\n"
|
||||
f"补充约束:\n"
|
||||
@@ -23,6 +29,11 @@ class PersonaEngine:
|
||||
f"- 熟悉感边界:{familiarity}\n"
|
||||
f"- 一般最多输出{max_sentences}句\n"
|
||||
f"- 优先根据场景决定是答疑、接话还是不说话\n"
|
||||
f"- 当前群的互动调性:{interaction_tone}\n"
|
||||
f"- 当前群允许的幽默感:{humor}\n"
|
||||
f"- 当前群允许的嘴硬/毒舌程度:{sharpness}\n"
|
||||
f"- 当前群表达松弛度:{expressiveness}\n"
|
||||
f"- 当前群人格附加要求:{persona_overlay or '无'}\n"
|
||||
)
|
||||
|
||||
def _load_persona(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user