From 327b043b898c9146b86efa9ecda6545b36a657a1 Mon Sep 17 00:00:00 2001 From: guke Date: Tue, 14 Jul 2026 14:38:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(comparison-records):=20=E6=AF=94=E4=BB=B7?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=B1=95=E7=A4=BA=20LLM=20=E5=AE=9E=E9=99=85?= =?UTF-8?q?=E6=88=90=E6=9C=AC(=E5=88=97=E8=A1=A8=E5=88=97=20+=20=E8=AF=A6?= =?UTF-8?q?=E6=83=85=20+=20=E4=BB=B7=E6=A0=BC=E5=BF=AB=E7=85=A7)=20(#48)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整LLM价格快照展示样式 --------- Co-authored-by: guke Reviewed-on: https://gitea.shaguabijia.com/WonderableAI/shaguabijia-admin-web/pulls/48 --- src/app/(main)/comparison-records/page.tsx | 13 +++++++++++-- src/app/(main)/config/page.tsx | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/(main)/comparison-records/page.tsx b/src/app/(main)/comparison-records/page.tsx index b365460..6d57be6 100644 --- a/src/app/(main)/comparison-records/page.tsx +++ b/src/app/(main)/comparison-records/page.tsx @@ -38,6 +38,15 @@ const fmtCost = (c: number | null) => (c == null ? '-' : `¥${c.toFixed(4)}`); const fmtTok = (inTok: number | null, outTok: number | null) => inTok == null && outTok == null ? '-' : `${inTok ?? 0}/${outTok ?? 0}`; +// LLM 价格快照只展示 prices 里各模型的单价(元/每百万 token),忽略 mode/_source 等元字段。 +function llmPriceRows(snapshot: Record | null): string[] { + const prices = snapshot?.prices; + if (!prices || typeof prices !== 'object') return []; + return Object.entries(prices as Record).map( + ([model, p]) => `${model} 输入 ${p?.input_per_1m ?? '-'}元/每百万tokens,输出${p?.output_per_1m ?? '-'}元/每百万tokens`, + ); +} + // LLM message content 常是 json.dumps 的卡片列表;能 parse 成 JSON 就缩进展开,否则原样。 function pretty(s: string | null): string { if (!s) return ''; @@ -357,8 +366,8 @@ export default function ComparisonRecordsPage() { )} {detail.llm_price_snapshot ? ( - -
{JSON.stringify(detail.llm_price_snapshot, null, 2)}
+ + {llmPriceRows(detail.llm_price_snapshot).map((r) =>
{r}
)}
) : null} {detail.source_platform_name || '-'}({cents(detail.source_price_cents)}) diff --git a/src/app/(main)/config/page.tsx b/src/app/(main)/config/page.tsx index 4d2070d..3f48f83 100644 --- a/src/app/(main)/config/page.tsx +++ b/src/app/(main)/config/page.tsx @@ -11,7 +11,7 @@ interface ConfigItem { key: string; label: string; group: string; - type: string; // int / int_list / dict_str_int / bool + type: string; // int / int_list / dict_str_int / bool / json help: string | null; // eslint-disable-next-line @typescript-eslint/no-explicit-any default: any; @@ -24,7 +24,7 @@ interface ConfigItem { // eslint-disable-next-line @typescript-eslint/no-explicit-any function toEdit(item: ConfigItem): any { if (item.type === 'int_list') return (item.value as number[]).join(', '); - if (item.type === 'dict_str_int') return JSON.stringify(item.value); + if (item.type === 'dict_str_int' || item.type === 'json') return JSON.stringify(item.value); return item.value; } @@ -37,7 +37,7 @@ function fromEdit(type: string, raw: any): any { .split(',') .map((s) => parseInt(s.trim(), 10)); } - if (type === 'dict_str_int') return JSON.parse(raw); + if (type === 'dict_str_int' || type === 'json') return JSON.parse(raw); return raw; }