From 0a5a7c92791c5a29e0714dfb2ab1b9ddb09b7b9b Mon Sep 17 00:00:00 2001 From: Rin Date: Fri, 9 Jan 2026 02:28:02 +0800 Subject: [PATCH] chore(minecraft): time llm call duration --- .../src/cognitive/conscious/brain.ts | 3 +- services/minecraft/src/debug-server.ts | 11 +- services/minecraft/src/web/dashboard.html | 803 +++++++++--------- 3 files changed, 423 insertions(+), 394 deletions(-) diff --git a/services/minecraft/src/cognitive/conscious/brain.ts b/services/minecraft/src/cognitive/conscious/brain.ts index bead50ab0..a17dc7737 100644 --- a/services/minecraft/src/cognitive/conscious/brain.ts +++ b/services/minecraft/src/cognitive/conscious/brain.ts @@ -52,7 +52,6 @@ export class Brain { public init(bot: MineflayerWithAgents): void { this.log('INFO', 'Brain: Initializing...') - // Listen to Stimuli (Chat/Voice) // We treat these as "Sensory Inputs" that trigger the Cognitive Cycle this.deps.eventManager.on('stimulus', async (event) => { if (event.handled) { @@ -207,6 +206,7 @@ export class Brain { private async decide(sysPrompt: string, userMsg: string): Promise { try { + const request_start = Date.now() const response = await this.deps.neuri.handleStateless( [ system(sysPrompt), @@ -225,6 +225,7 @@ export class Brain { content: completion?.choices?.[0]?.message?.content, usage: completion?.usage, model: config.openai.model, + duration: Date.now() - request_start, }) if (!completion || !completion.choices?.[0]?.message?.content) { diff --git a/services/minecraft/src/debug-server.ts b/services/minecraft/src/debug-server.ts index fc867aae8..1f841eb46 100644 --- a/services/minecraft/src/debug-server.ts +++ b/services/minecraft/src/debug-server.ts @@ -18,6 +18,15 @@ interface DebugEvent { timestamp: number } +interface LlmTrace { + route: string + messages: any + content: any + usage?: any + model?: string + duration?: number // ms +} + export class DebugService { private static instance: DebugService private clients: Set = new Set() @@ -102,7 +111,7 @@ export class DebugService { this.emit('log', { level, message, fields, timestamp: Date.now() }) } - public traceLLM(trace: any) { + public traceLLM(trace: LlmTrace) { this.emit('llm', { ...trace, timestamp: Date.now() }) } diff --git a/services/minecraft/src/web/dashboard.html b/services/minecraft/src/web/dashboard.html index 41a62d183..753fe9d3d 100644 --- a/services/minecraft/src/web/dashboard.html +++ b/services/minecraft/src/web/dashboard.html @@ -1,372 +1,389 @@ + - - - Minecraft Service Debugger - + .message-content { + white-space: pre-wrap; + line-height: 1.4; + } + + .role-system { + border-left-color: #e91e63; + background-color: #2a1a20; + } + + .role-user { + border-left-color: #4caf50; + background-color: #1a2a1a; + } + + .role-assistant { + border-left-color: #2196f3; + background-color: #1a202a; + } + + -
-
Minecraft Service Debugger
-
- - Disconnected - -
-
-
- - -
-
-

System Overview

-
-
- -
-
Event Queue (0)
-
-
Queue is empty
-
-
+
+
Minecraft Service Debugger
+
+ + Disconnected + +
+
+
+ - -
-
Currently Processing
-
-
Idle
-
-
-
+
+
+

System Overview

+
+
+ +
+
Event Queue (0)
+
+
Queue is empty
+
-
-
-

Blackboard State

-
-
-
{}
-
+ +
+
Currently Processing
+
+
Idle
+
+
+
-
-
- - -
-
-
+
+
+

Blackboard State

+
+
+
{}
+
+
-
-
- -
-
-
-
+
+
+ + +
+
+
- + sseClient.addEventListener('blackboard', (e) => { + try { + updateBlackboard(JSON.parse(e.data)); + } catch (e) { console.error(e); } + }); + } + + connectSSE(); + +