From 2a64e505cc903ca1afa4f7824d4f752e4e405623 Mon Sep 17 00:00:00 2001 From: orangeboyChen Date: Fri, 4 Sep 2026 17:49:59 +0800 Subject: [PATCH] fix: show actual debug upstream format --- app/debug/debug.tsx | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/debug/debug.tsx b/app/debug/debug.tsx index e2d11f8..b292177 100644 --- a/app/debug/debug.tsx +++ b/app/debug/debug.tsx @@ -245,9 +245,14 @@ const getStreamingEventText = (event: unknown): string | null => { const choiceText = getText(event.choices); if (choiceText) return choiceText; - return event.type === 'response.output_text.delta' - ? getText(event.delta) - : null; + if ( + event.type === 'response.output_text.delta' || + event.type === 'content_block_delta' + ) { + return getText(event.delta); + } + + return null; }; const getToolName = (tool: JsonRecord): string => { @@ -293,12 +298,19 @@ const formatToolName = (value: string): string => { .join(' '); }; -const getResponseFormat = (route: string): string => { +const getDownstreamFormat = (route: string): string => { if (route === '/v1/responses') return 'OpenAI Responses'; if (route === '/v1/messages') return 'Anthropic Messages'; return 'OpenAI Chat'; }; +const getUpstreamFormat = ( + upstreamRequest: DebugLogEntry['upstreamRequest'], +): string => { + if (upstreamRequest?.url.endsWith('/responses')) return 'OpenAI Responses'; + return 'OpenAI Chat'; +}; + const formatMaskedRequestKey = (value: string): string => { return value.replace(/^Bearer\s+/i, '').replaceAll('...', '****'); }; @@ -883,7 +895,7 @@ const Debug = () => { const formatOptions = useMemo( () => [ - ...new Set(debug.items.map((item) => getResponseFormat(item.route))), + ...new Set(debug.items.map((item) => getDownstreamFormat(item.route))), ].map((format) => ({ label: format, value: format })), [debug.items], ); @@ -932,7 +944,7 @@ const Debug = () => { const filteredItems = useMemo( () => debug.items.filter((item) => { - const format = getResponseFormat(item.route); + const format = getDownstreamFormat(item.route); const credential = item.credentialFilename ?? EMPTY_FILTER_VALUE; const model = item.model ?? EMPTY_FILTER_VALUE; const requestKey = item.requestKey ?? EMPTY_FILTER_VALUE; @@ -1152,25 +1164,25 @@ const Debug = () => { ) : ( <>