Path: blob/main/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEventDetailRenderer.ts
13406 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { localize } from '../../../../../nls.js';6import { IChatDebugEvent } from '../../common/chatDebugService.js';7import { safeIntl } from '../../../../../base/common/date.js';89const numberFormatter = safeIntl.NumberFormat();1011/**12* Format the detail text for a debug event (used when no resolved content is available).13*/14export function formatEventDetail(event: IChatDebugEvent): string {15switch (event.kind) {16case 'toolCall': {17const parts = [localize('chatDebug.detail.tool', "Tool: {0}", event.toolName)];18if (event.toolCallId) { parts.push(localize('chatDebug.detail.callId', "Call ID: {0}", event.toolCallId)); }19if (event.result) { parts.push(localize('chatDebug.detail.result', "Result: {0}", event.result)); }20if (event.durationInMillis !== undefined) { parts.push(localize('chatDebug.detail.durationMs', "Duration: {0}ms", numberFormatter.value.format(event.durationInMillis))); }21if (event.input) { parts.push(`\n${localize('chatDebug.detail.input', "Input:")}\n${event.input}`); }22if (event.output) { parts.push(`\n${localize('chatDebug.detail.output', "Output:")}\n${event.output}`); }23return parts.join('\n');24}25case 'modelTurn': {26const parts = [event.model ?? localize('chatDebug.detail.modelTurn', "Model Turn")];27if (event.inputTokens !== undefined) { parts.push(localize('chatDebug.detail.inputTokens', "Input tokens: {0}", numberFormatter.value.format(event.inputTokens))); }28if (event.outputTokens !== undefined) { parts.push(localize('chatDebug.detail.outputTokens', "Output tokens: {0}", numberFormatter.value.format(event.outputTokens))); }29if (event.cachedTokens !== undefined) { parts.push(localize('chatDebug.detail.cachedTokens', "Cached tokens: {0}", numberFormatter.value.format(event.cachedTokens))); }30if (event.totalTokens !== undefined) { parts.push(localize('chatDebug.detail.totalTokens', "Total tokens: {0}", numberFormatter.value.format(event.totalTokens))); }31if (event.durationInMillis !== undefined) { parts.push(localize('chatDebug.detail.durationMs', "Duration: {0}ms", numberFormatter.value.format(event.durationInMillis))); }32return parts.join('\n');33}34case 'generic':35return `${event.name}\n${event.details ?? ''}`;36case 'subagentInvocation': {37const parts = [localize('chatDebug.detail.agent', "Agent: {0}", event.agentName)];38if (event.description) { parts.push(localize('chatDebug.detail.description', "Description: {0}", event.description)); }39if (event.status) { parts.push(localize('chatDebug.detail.status', "Status: {0}", event.status)); }40if (event.durationInMillis !== undefined) { parts.push(localize('chatDebug.detail.durationMs', "Duration: {0}ms", numberFormatter.value.format(event.durationInMillis))); }41if (event.toolCallCount !== undefined) { parts.push(localize('chatDebug.detail.toolCallCount', "Tool calls: {0}", numberFormatter.value.format(event.toolCallCount))); }42if (event.modelTurnCount !== undefined) { parts.push(localize('chatDebug.detail.modelTurnCount', "Model turns: {0}", numberFormatter.value.format(event.modelTurnCount))); }43return parts.join('\n');44}45case 'userMessage': {46const parts = [localize('chatDebug.detail.userMessage', "User Message: {0}", event.message)];47for (const section of event.sections) {48parts.push(`\n--- ${section.name} ---\n${section.content}`);49}50return parts.join('\n');51}52case 'agentResponse': {53const parts = [localize('chatDebug.detail.agentResponse', "Agent Response: {0}", event.message)];54for (const section of event.sections) {55parts.push(`\n--- ${section.name} ---\n${section.content}`);56}57return parts.join('\n');58}59}60}616263