feat: 添加角色事件评论系统

- 新增 Opinion 模型,记录角色对事件的观点
- 新增 opinions.py,基于规则生成观点(支持5种事件×3种情绪)
- 同一事件生命周期内每个 agent 只生成一次观点
- 观点同时记录到 agent.memory
- 新增 3 个测试用例

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2025-12-30 10:42:59 +08:00
parent 8b90d55f02
commit af279bedd9
4 changed files with 238 additions and 0 deletions

View File

@@ -31,10 +31,20 @@ class WorldEffect(BaseModel):
mood_modifier: int = 0
class Opinion(BaseModel):
"""角色对事件的观点"""
about: str # 事件类型 (effect_type)
text: str # 观点内容
tick: int # 生成时的 tick
class AgentState(BaseModel):
emotion: Emotion = Emotion.CALM
goal: str = ""
memory: List[str] = Field(default_factory=list)
opinion: Optional[Opinion] = None
# 记录已评论过的事件,防止重复生成
commented_effects: List[str] = Field(default_factory=list)
class WorldState(BaseModel):