feat: add model and skill admin pages

This commit is contained in:
hailin
2026-07-14 14:08:04 +08:00
parent 9d4fae58bd
commit 92b7af118e
15 changed files with 669 additions and 9 deletions

View File

@@ -1,12 +1,26 @@
import type * as React from 'react'
import { CheckCircle2, CircleAlert, Clock3 } from 'lucide-react'
import { Badge } from '@/components/ui/badge'
import type { AgentStep } from '@/features/prototype/types'
export type TraceTimelineItem = {
id: React.Key
step_name: string
step_type?: 'model' | 'retrieval' | 'skill' | 'tool' | 'approval'
status: 'success' | 'succeeded' | 'failed' | 'waiting' | 'queued' | 'running' | 'cancelled'
input_summary?: string
output_summary?: string
latency_ms?: number
}
const statusConfig = {
success: { label: '成功', variant: 'success' },
failed: { label: '失败', variant: 'danger' },
waiting: { label: '等待确认', variant: 'warning' }
waiting: { label: '等待确认', variant: 'warning' },
succeeded: { label: '成功', variant: 'success' },
queued: { label: '排队中', variant: 'secondary' },
running: { label: '执行中', variant: 'info' },
cancelled: { label: '已取消', variant: 'secondary' }
} as const
const typeLabels = {
@@ -17,7 +31,7 @@ const typeLabels = {
approval: '人工确认'
} as const
export function AppTraceTimeline({ items }: { items: AgentStep[] }) {
export function AppTraceTimeline({ items }: { items: TraceTimelineItem[] }) {
return (
<ol className="grid gap-3">
{items.map((item) => {
@@ -32,12 +46,12 @@ export function AppTraceTimeline({ items }: { items: AgentStep[] }) {
<div className="grid gap-2">
<div className="flex flex-wrap items-center gap-2">
<p className="font-medium text-foreground">{item.step_name}</p>
<Badge variant="outline">{typeLabels[item.step_type]}</Badge>
<Badge variant="outline">{item.step_type ? typeLabels[item.step_type] : 'Skill'}</Badge>
<Badge variant={status.variant}>{status.label}</Badge>
</div>
<p className="text-sm text-muted-foreground">输入:{item.input_summary}</p>
<p className="text-sm text-foreground">输出:{item.output_summary}</p>
<p className="text-xs text-muted-foreground">耗时 {item.latency_ms} ms</p>
{item.input_summary ? <p className="text-sm text-muted-foreground">输入:{item.input_summary}</p> : null}
{item.output_summary ? <p className="text-sm text-foreground">输出:{item.output_summary}</p> : null}
{item.latency_ms !== undefined ? <p className="text-xs text-muted-foreground">耗时 {item.latency_ms} ms</p> : null}
</div>
</li>
)