feat: 添加缓存 Token 独立展示(cache_creation / cache_read)
从 logs 表 other JSON 字段提取 cache_creation_tokens 和 cache_tokens, 在排名、日志、聚合、详情页分别展示,total_tokens 包含缓存部分。
This commit is contained in:
@@ -11,8 +11,8 @@ import { useI18n } from "@/lib/i18n";
|
||||
interface LogEntry {
|
||||
id: number; created_at: string; display_name: string;
|
||||
real_model: string; channel_name: string; prompt_tokens: number;
|
||||
completion_tokens: number; total_tokens: number;
|
||||
use_time: number; is_stream: boolean;
|
||||
completion_tokens: number; cache_creation_tokens: number; cache_read_tokens: number;
|
||||
total_tokens: number; use_time: number; is_stream: boolean;
|
||||
}
|
||||
|
||||
export default function LogsPage() {
|
||||
@@ -37,7 +37,7 @@ export default function LogsPage() {
|
||||
useEffect(() => { startTransition(() => setPage(1)); }, [getEffectiveRange, filters]);
|
||||
const totalPages = Math.ceil(total / pageSize);
|
||||
|
||||
const headers = [t("th.time"), t("th.user"), t("th.realModel"), t("th.channel"), t("th.input"), t("th.output"), t("th.totalToken"), t("th.latency"), ""];
|
||||
const headers = [t("th.time"), t("th.user"), t("th.realModel"), t("th.channel"), t("th.input"), t("th.cacheCreation"), t("th.cacheRead"), t("th.output"), t("th.totalToken"), t("th.latency"), ""];
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -78,7 +78,7 @@ export default function LogsPage() {
|
||||
</thead>
|
||||
<tbody>
|
||||
{loading ? (
|
||||
<tr><td colSpan={9} className="px-3 py-16 text-center"><div className="inline-block h-5 w-5 animate-spin rounded-full spinner" /></td></tr>
|
||||
<tr><td colSpan={11} className="px-3 py-16 text-center"><div className="inline-block h-5 w-5 animate-spin rounded-full spinner" /></td></tr>
|
||||
) : logs.map((log) => (
|
||||
<tr key={log.id} className="row-glow transition-colors" style={{ borderBottom: "1px solid var(--surface-border)" }}>
|
||||
<td className="px-3 py-2.5 text-xs font-[family-name:var(--font-geist-mono)]" style={{ color: "var(--text-muted)" }}>{formatDate(log.created_at)}</td>
|
||||
@@ -86,6 +86,8 @@ export default function LogsPage() {
|
||||
<td className="px-3 py-2.5 font-[family-name:var(--font-geist-mono)] text-xs" style={{ color: "var(--text-accent)", opacity: 0.7 }}>{log.real_model}</td>
|
||||
<td className="px-3 py-2.5" style={{ color: "var(--text-muted)" }}>{log.channel_name}</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums font-[family-name:var(--font-geist-mono)] text-xs" style={{ color: "var(--text-muted)" }}>{formatNumber(log.prompt_tokens)}</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums font-[family-name:var(--font-geist-mono)] text-xs" style={{ color: "var(--text-muted)" }}>{formatNumber(log.cache_creation_tokens)}</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums font-[family-name:var(--font-geist-mono)] text-xs" style={{ color: "var(--text-muted)" }}>{formatNumber(log.cache_read_tokens)}</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums font-[family-name:var(--font-geist-mono)] text-xs" style={{ color: "var(--text-muted)" }}>{formatNumber(log.completion_tokens)}</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums font-medium font-[family-name:var(--font-geist-mono)] text-xs" style={{ color: "var(--text-primary)" }}>{formatNumber(log.total_tokens)}</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums text-xs" style={{ color: "var(--text-muted)" }}>{log.use_time}ms</td>
|
||||
|
||||
Reference in New Issue
Block a user