/* Copyright (C) 2023-2026 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { CircleAlert } from 'lucide-react' import { useTranslation } from 'react-i18next' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip' import { formatUseTime } from '@/lib/format' import { cn } from '@/lib/utils' import type { LogOtherData } from '../types' interface TimingMetricsCellProps { useTimeSec: number frtMs?: number isStream: boolean className?: string } export function TimingMetricsCell(props: TimingMetricsCellProps) { const { t } = useTranslation() const showFirstToken = props.isStream const hasFrt = props.frtMs != null && props.frtMs > 0 const firstTokenLabel = hasFrt ? formatUseTime(props.frtMs! / 1000) : t('N/A') const totalTimeLabel = formatUseTime(props.useTimeSec) return (
{t('First token')} {showFirstToken ? firstTokenLabel : '—'}
{t('Duration')} {totalTimeLabel}
) } interface StreamTpsCellProps { isStream: boolean tokensPerSecond?: number | null streamStatus?: LogOtherData['stream_status'] className?: string } export function StreamTpsCell(props: StreamTpsCellProps) { const { t } = useTranslation() const showStreamError = props.isStream && props.streamStatus && props.streamStatus.status !== 'ok' const tpsLabel = props.tokensPerSecond != null ? `${Math.round(props.tokensPerSecond)} t/s` : '—' return (
{props.isStream ? t('Stream') : t('Non-stream')} {showStreamError && ( } />

{t('Stream Status')}: {t('Error')}

{props.streamStatus?.end_reason || 'unknown'}

{(props.streamStatus?.error_count ?? 0) > 0 && (

{t('Soft Errors')}: {props.streamStatus?.error_count}

)}
)}
{tpsLabel}
) }