This commit is contained in:
2025-12-28 17:06:35 +08:00
parent 167ced5f57
commit 9ef8e9188a
5 changed files with 38 additions and 7 deletions

View File

@@ -196,6 +196,7 @@
<!-- Personality Settings -->
<Wula_ExtraPersonality_Title>附加人格指令</Wula_ExtraPersonality_Title>
<Wula_ExtraPersonality_Desc>在此输入额外的人格提示词或要求。这些内容将拼接到 AI 的核心指令之后,影响其回复风格和行为方式</Wula_ExtraPersonality_Desc>
<Wula_ExtraPersonality_Desc>在此输入 AI 的人格提示词。如果此处不为空,它将完全覆盖 XML 中的默认设置。如果为空,则使用 XML 默认值</Wula_ExtraPersonality_Desc>
<Wula_Save>保存</Wula_Save>
<Wula_Reset>重置为默认</Wula_Reset>
</LanguageData>

View File

@@ -517,13 +517,16 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
}
private string GetSystemInstruction(bool toolsEnabled, string toolsForThisPhase)
{
var def = GetActiveEventDef();
string persona = def != null && !string.IsNullOrEmpty(def.aiSystemInstruction) ? def.aiSystemInstruction : DefaultPersona;
var settings = WulaFallenEmpireMod.settings;
string persona;
if (settings != null && !string.IsNullOrWhiteSpace(settings.extraPersonalityPrompt))
{
persona += "\n" + settings.extraPersonalityPrompt;
persona = settings.extraPersonalityPrompt;
}
else
{
var def = GetActiveEventDef();
persona = def != null && !string.IsNullOrEmpty(def.aiSystemInstruction) ? def.aiSystemInstruction : DefaultPersona;
}
string fullInstruction = toolsEnabled
@@ -550,6 +553,12 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
$"You will produce the natural-language reply later and MUST use: {language}.";
}
public string GetEffectiveBasePersona()
{
var def = GetActiveEventDef();
return def != null && !string.IsNullOrEmpty(def.aiSystemInstruction) ? def.aiSystemInstruction : DefaultPersona;
}
private string GetToolSystemInstruction(RequestPhase phase, bool hasImage)
{
string phaseInstruction = GetPhaseInstruction(phase).TrimEnd();

View File

@@ -16,7 +16,18 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
this.doWindowBackground = true;
this.absorbInputAroundWindow = true;
this.closeOnClickedOutside = true;
_tempPrompt = WulaFallenEmpireMod.settings?.extraPersonalityPrompt ?? "";
// 如果目前是空的,默认显示当前 XML/Def 的内容供玩家修改
if (string.IsNullOrWhiteSpace(_tempPrompt))
{
var core = Find.World?.GetComponent<AIIntelligenceCore>();
if (core != null)
{
_tempPrompt = core.GetEffectiveBasePersona();
}
}
}
public override void DoWindowContents(Rect inRect)
@@ -32,8 +43,8 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
Rect textRect = new Rect(0, curY, inRect.width, inRect.height - curY - 50f);
_tempPrompt = Widgets.TextArea(textRect, _tempPrompt);
Rect btnRect = new Rect(inRect.width / 2 - 60f, inRect.height - 40f, 120f, 35f);
if (Widgets.ButtonText(btnRect, "Wula_Save".Translate()))
Rect saveBtnRect = new Rect(inRect.width / 2 - 130f, inRect.height - 40f, 120f, 35f);
if (Widgets.ButtonText(saveBtnRect, "Wula_Save".Translate()))
{
if (WulaFallenEmpireMod.settings != null)
{
@@ -42,6 +53,16 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
}
this.Close();
}
Rect resetBtnRect = new Rect(inRect.width / 2 + 10f, inRect.height - 40f, 120f, 35f);
if (Widgets.ButtonText(resetBtnRect, "Wula_Reset".Translate()))
{
var core = Find.World?.GetComponent<AIIntelligenceCore>();
if (core != null)
{
_tempPrompt = core.GetEffectiveBasePersona();
}
}
}
}
}