feat: display inference statistics in chat UI

Add InferenceStats proto message and InferenceStatsPanel component that
displays token counts, throughput, and context window utilization as a
collapsible panel below assistant messages after orchestration completes.

Closes #43

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shahondin1624
2026-03-13 14:44:12 +01:00
parent e93158f670
commit 52eaf661c4
7 changed files with 223 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import type { ChatMessage } from '$lib/types';
import type { SubagentResult } from '$lib/proto/llm_multiverse/v1/common_pb';
import type { SubagentResult, InferenceStats } from '$lib/proto/llm_multiverse/v1/common_pb';
import type { SessionConfig } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
import { processRequest, OrchestratorError, friendlyMessage } from '$lib/services/orchestrator';
import { OrchestrationState } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
@@ -15,6 +15,7 @@ export function createOrchestration() {
let orchestrationState: OrchestrationState = $state(OrchestrationState.UNSPECIFIED);
let intermediateResult: string = $state('');
let finalResult: SubagentResult | null = $state(null);
let inferenceStats: InferenceStats | null = $state(null);
async function send(
sessionId: string,
@@ -27,6 +28,7 @@ export function createOrchestration() {
orchestrationState = OrchestrationState.UNSPECIFIED;
intermediateResult = '';
finalResult = null;
inferenceStats = null;
let lastAuditState = OrchestrationState.UNSPECIFIED;
@@ -72,6 +74,9 @@ export function createOrchestration() {
if (response.intermediateResult) {
intermediateResult = response.intermediateResult;
}
if (response.inferenceStats) {
inferenceStats = response.inferenceStats;
}
if (response.finalResult) {
finalResult = response.finalResult;
if (response.finalResult.newMemoryCandidates.length > 0) {
@@ -145,6 +150,7 @@ export function createOrchestration() {
function reset() {
error = null;
finalResult = null;
inferenceStats = null;
}
return {
@@ -154,6 +160,7 @@ export function createOrchestration() {
get orchestrationState() { return orchestrationState; },
get intermediateResult() { return intermediateResult; },
get finalResult() { return finalResult; },
get inferenceStats() { return inferenceStats; },
send,
retry,
reset