This commit is contained in:
bridge
2025-11-22 17:14:36 +08:00
parent 1c49d27c82
commit d7dbe8a0da
4 changed files with 39 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
"""
长期目标模块
为角色生成和管理长期目标3-5年)
为角色生成和管理长期目标3-10年)
"""
from __future__ import annotations
from dataclasses import dataclass
@@ -35,8 +35,8 @@ def can_generate_long_term_objective(avatar: "Avatar") -> bool:
1. 已有用户设定的目标,永不自动生成
2. 无目标时,可以生成
3. 距离上次设定 <3年不生成
4. 距离上次设定 ≥5年,必定生成
5. 距离上次设定 3-5年,按概率生成(渐进概率)
4. 距离上次设定 ≥10年,必定生成
5. 距离上次设定 3-10年,按概率生成(渐进概率)
Args:
avatar: 要检查的角色
@@ -58,11 +58,11 @@ def can_generate_long_term_objective(avatar: "Avatar") -> bool:
if years_passed < 3:
return False
elif years_passed >= 5:
elif years_passed >= 10:
return True
else: # 3-5年之间
# 渐进概率3年时10%4年时50%,接近5年时接近100%
probability = (years_passed - 3) / 2 * 0.9 + 0.1
else: # 3-10年之间
# 渐进概率3年时10%随时间推移逐渐增加,接近10年时接近100%
probability = (years_passed - 3) / 7 * 0.9 + 0.1
return random.random() < probability
@@ -93,7 +93,7 @@ async def generate_long_term_objective(avatar: "Avatar") -> Optional[LongTermObj
}
# 调用LLM并自动解析JSON使用fast模型
response_data = await call_llm_with_template(template_path, infos, LLMMode.FAST)
response_data = await call_llm_with_template(template_path, infos, LLMMode.NORMAL)
content = response_data.get("long_term_objective", "").strip()

View File

@@ -13,7 +13,7 @@
返回JSON格式
{{
"thinking": "思考。",
"thinking": "思考角色会有怎么样的长期目标,但也不用过度思考。",
"long_term_objective": "目标内容简洁清晰明快15字以内。"
}}

View File

@@ -13,7 +13,7 @@
返回JSON格式
{{
"thinking": "分析角色特点、主要事迹、性格特质,思考什么绰号最能体现这个人物...",
"thinking": "分析角色特点、主要事迹、性格特质,思考什么绰号最能体现这个人物...但也不用过度思考",
"nickname": "绰号"
}}

View File

@@ -81,6 +81,35 @@ export const useWorldStore = defineStore('world', () => {
if (!isLoaded.value) return;
setTime(payload.year, payload.month);
// 检查并处理死亡事件,移除已死亡的角色
if (payload.events && Array.isArray(payload.events)) {
const deathEvents = payload.events.filter((e: any) => {
const c = e.content || '';
return c.includes('身亡') || c.includes('老死');
});
if (deathEvents.length > 0) {
const next = new Map(avatars.value);
let changed = false;
for (const de of deathEvents) {
if (de.related_avatar_ids && Array.isArray(de.related_avatar_ids)) {
for (const id of de.related_avatar_ids) {
if (next.has(id)) {
next.delete(id);
changed = true;
}
}
}
}
if (changed) {
avatars.value = next;
}
}
}
if (payload.avatars) updateAvatars(payload.avatars);
if (payload.events) addEvents(payload.events);
}