import { DashboardData, RequestLog } from './types'; import { subMinutes, format } from 'date-fns'; function generateHistory(points: number, baseValue: number, variance: number): { time: string; value: number }[] { return Array.from({ length: points }).map((_, i) => { const time = subMinutes(new Date(), points - 1 - i); return { time: format(time, 'HH:mm'), value: Math.max(0, Math.floor(baseValue + (Math.random() - 0.5) * variance)), }; }); } function generateRequests(count: number): RequestLog[] { const models = ['gpt-4-turbo', 'gpt-3.5-turbo', 'claude-3-opus', 'claude-3-sonnet']; return Array.from({ length: count }).map(() => { const isError = Math.random() > 0.98; const status: "success" | "error" = isError ? "error" : "success"; return { id: `req_${Math.random().toString(36).substr(2, 9)}`, timestamp: subMinutes(new Date(), Math.floor(Math.random() * 60)).toISOString(), model: models[Math.floor(Math.random() * models.length)], tokensPrompt: Math.floor(Math.random() * 1000) + 50, tokensCompletion: Math.floor(Math.random() * 2000) + 100, latency: Math.floor(Math.random() * 2000) + 200, status, cost: Math.random() * 0.1, }; }).sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()); } export function getMockData(): DashboardData { return { rpm: { id: 'rpm', name: 'Requests Per Minute', value: 342, unit: 'RPM', change: 12.5, trend: 'up', history: generateHistory(20, 340, 50), }, tps: { id: 'tps', name: 'Tokens Per Second', value: 8450, unit: 'TPS', change: -2.1, trend: 'down', history: generateHistory(20, 8500, 1000), }, tpsInput: { id: 'tpsInput', name: 'Input TPS', value: 6450, unit: 'TPS', change: -1.1, trend: 'down', history: generateHistory(20, 6500, 800), }, tpsOutput: { id: 'tpsOutput', name: 'Output TPS', value: 2000, unit: 'TPS', change: -4.1, trend: 'down', history: generateHistory(20, 2000, 200), }, tpm: { id: 'tpm', name: 'Tokens Per Minute', value: 507000, unit: 'TPM', change: 5.4, trend: 'up', history: generateHistory(20, 500000, 50000), }, latency: { id: 'latency', name: 'Avg Latency', value: 450, unit: 'ms', change: -15, trend: 'down', // down is good for latency history: generateHistory(20, 450, 100), }, cost: { id: 'cost', name: 'Est. Cost', value: 45.20, unit: '$', change: 8.2, trend: 'up', history: generateHistory(20, 45, 5), }, requests: generateRequests(50), }; }