补上“原生工具阶段”的 thought 读取逻辑:现在会优先读 response.Thought(reasoning_content/thought/reasoning),没有再回退解析 content 里的 thought JSON,然后写入思考 UI。
文件:AIIntelligenceCore.cs、SimpleAIClient.cs
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -50,6 +50,7 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
{
|
||||
public string Content;
|
||||
public List<ToolCallRequest> ToolCalls;
|
||||
public string Thought;
|
||||
}
|
||||
|
||||
public class SimpleAIClient
|
||||
@@ -435,10 +436,14 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
}
|
||||
|
||||
string content = TryGetString(message, "content");
|
||||
string thought = TryGetString(message, "reasoning_content");
|
||||
if (string.IsNullOrWhiteSpace(thought)) thought = TryGetString(message, "thought");
|
||||
if (string.IsNullOrWhiteSpace(thought)) thought = TryGetString(message, "reasoning");
|
||||
var result = new ChatCompletionResult
|
||||
{
|
||||
Content = content,
|
||||
ToolCalls = ParseToolCalls(message)
|
||||
ToolCalls = ParseToolCalls(message),
|
||||
Thought = thought
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -622,9 +622,13 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
DrawReactTracePanel(traceRect, liveTraceEntry);
|
||||
}
|
||||
}
|
||||
else if (thinkingY + 40f >= viewTop && thinkingY <= viewBottom)
|
||||
else
|
||||
{
|
||||
DrawThinkingIndicator(new Rect(innerPadding, thinkingY, contentWidth, 35f));
|
||||
float indicatorHeight = (_core != null && !string.IsNullOrWhiteSpace(_core.LatestThought)) ? 55f : 35f;
|
||||
if (thinkingY + indicatorHeight >= viewTop && thinkingY <= viewBottom)
|
||||
{
|
||||
DrawThinkingIndicator(new Rect(innerPadding, thinkingY, contentWidth, indicatorHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,7 +868,16 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
Text.Font = GameFont.Small;
|
||||
Text.Anchor = TextAnchor.MiddleLeft;
|
||||
|
||||
Widgets.Label(rect, BuildThinkingStatus());
|
||||
Rect statusRect = new Rect(rect.x, rect.y, rect.width, 22f);
|
||||
Widgets.Label(statusRect, BuildThinkingStatus());
|
||||
|
||||
string thought = _core?.LatestThought;
|
||||
if (!string.IsNullOrWhiteSpace(thought))
|
||||
{
|
||||
Text.Font = GameFont.Tiny;
|
||||
Rect thoughtRect = new Rect(rect.x, statusRect.yMax + 2f, rect.width, 22f);
|
||||
Widgets.Label(thoughtRect, $"??: {thought}");
|
||||
}
|
||||
|
||||
GUI.color = originalColor;
|
||||
Text.Anchor = originalAnchor;
|
||||
|
||||
@@ -673,8 +673,9 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect thinkingRect = new Rect(0, thinkingY, width, 30f);
|
||||
if (thinkingY + 30f >= viewTop && thinkingY <= viewBottom)
|
||||
float indicatorHeight = (_core != null && !string.IsNullOrWhiteSpace(_core.LatestThought)) ? 50f : 30f;
|
||||
Rect thinkingRect = new Rect(0, thinkingY, width, indicatorHeight);
|
||||
if (thinkingY + indicatorHeight >= viewTop && thinkingY <= viewBottom)
|
||||
{
|
||||
DrawThinkingIndicator(thinkingRect);
|
||||
}
|
||||
@@ -1044,11 +1045,19 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
Text.Anchor = TextAnchor.MiddleLeft;
|
||||
GUI.color = Color.gray;
|
||||
Rect iconRect = new Rect(rect.x + 60f, rect.y, 24f, 24f);
|
||||
Rect labelRect = new Rect(iconRect.xMax + 5f, rect.y, 400f, 24f);
|
||||
Rect labelRect = new Rect(iconRect.xMax + 5f, rect.y, rect.width - iconRect.xMax - 5f, 24f);
|
||||
|
||||
// Draw a simple box as thinking indicator if TexUI is missing
|
||||
Widgets.DrawBoxSolid(iconRect, Color.gray);
|
||||
Widgets.Label(labelRect, BuildThinkingStatus());
|
||||
|
||||
string thought = _core?.LatestThought;
|
||||
if (!string.IsNullOrWhiteSpace(thought))
|
||||
{
|
||||
Text.Font = GameFont.Tiny;
|
||||
Rect thoughtRect = new Rect(labelRect.x, labelRect.yMax + 2f, labelRect.width, 22f);
|
||||
Widgets.Label(thoughtRect, $"??: {thought}");
|
||||
}
|
||||
|
||||
Text.Anchor = TextAnchor.UpperLeft;
|
||||
GUI.color = Color.white;
|
||||
|
||||
Reference in New Issue
Block a user