"use client"; import { useState, useEffect, useCallback } from "react"; import Card from "@/shared/components/Card"; import Button from "@/shared/components/Button"; import Drawer from "@/shared/components/Drawer"; import Pagination from "@/shared/components/Pagination"; import { cn } from "@/shared/utils/cn"; import { AI_PROVIDERS, getProviderByAlias } from "@/shared/constants/providers"; let providerNameCache = null; let providerNodesCache = null; async function fetchProviderNames() { if (providerNameCache && providerNodesCache) { return { providerNameCache, providerNodesCache }; } const nodesRes = await fetch("/api/provider-nodes"); const nodesData = await nodesRes.json(); const nodes = nodesData.nodes || []; providerNodesCache = {}; for (const node of nodes) { providerNodesCache[node.id] = node.name; } providerNameCache = { ...AI_PROVIDERS, ...providerNodesCache }; return { providerNameCache, providerNodesCache }; } function getProviderName(providerId, cache) { if (!providerId) return providerId; if (!cache) return providerId; const cached = cache[providerId]; if (typeof cached === 'string') { return cached; } if (cached?.name) { return cached.name; } const providerConfig = getProviderByAlias(providerId) || AI_PROVIDERS[providerId]; return providerConfig?.name || providerId; } function CollapsibleSection({ title, children, defaultOpen = false, icon = null }) { const [isOpen, setIsOpen] = useState(defaultOpen); return (
| Timestamp | Model | Provider | Input Tokens | Output Tokens | Latency | Action |
|---|---|---|---|---|---|---|
|
progress_activity
Loading...
|
||||||
| No request details found | ||||||
| {new Date(detail.timestamp).toLocaleString()} | {detail.model} | {getProviderName(detail.provider, providerNameCache)} | {getInputTokens(detail.tokens).toLocaleString()} | {detail.tokens?.completion_tokens?.toLocaleString() || 0} |
TTFT: {detail.latency?.ttft || 0}ms
Total: {detail.latency?.total || 0}ms
|
|
{JSON.stringify(selectedDetail.request, null, 2)}
{JSON.stringify(selectedDetail.providerRequest, null, 2)}
{typeof selectedDetail.providerResponse === 'object'
? JSON.stringify(selectedDetail.providerResponse, null, 2)
: selectedDetail.providerResponse
}
{selectedDetail.response.thinking}
{selectedDetail.response?.content || "[No content]"}