interface RecentRequestsProps {
requests: {
request_id: string;
timestamp: string;
model: string;
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
total_cost: string;
response_time: number;
response_status: number;
client_ip: string;
stream: boolean;
}[];
}
export default function RecentRequests({ requests }: RecentRequestsProps) {
if (!requests || requests.length === 0) {
return (
);
}
return (
Recent Requests
| Timestamp |
Model |
Tokens |
Cost |
Response Time |
Status |
Client IP |
Stream |
{requests.map((req) => (
|
{new Date(req.timestamp).toLocaleString()}
|
{req.model}
|
{req.prompt_tokens} + {req.completion_tokens} = {req.total_tokens}
|
${Number.parseFloat(req.total_cost).toFixed(4)} |
{req.response_time}ms |
{req.response_status}
|
{req.client_ip} |
{req.stream ? '✓' : '✗'} |
))}
);
}
const styles = {
container: {
marginBottom: '2rem',
},
title: {
fontSize: '1.5rem',
marginBottom: '1.5rem',
color: '#2c3e50',
},
card: {
backgroundColor: '#fff',
borderRadius: '8px',
boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
overflow: 'hidden',
},
tableWrapper: {
overflowX: 'auto' as const,
},
table: {
width: '100%',
borderCollapse: 'collapse' as const,
minWidth: '1000px',
},
headerRow: {
backgroundColor: '#f8f9fa',
},
th: {
padding: '1rem',
textAlign: 'left' as const,
fontSize: '0.85rem',
fontWeight: 600,
color: '#2c3e50',
borderBottom: '2px solid #e9ecef',
},
row: {
borderBottom: '1px solid #e9ecef',
},
td: {
padding: '0.75rem 1rem',
fontSize: '0.85rem',
color: '#495057',
},
modelBadge: {
backgroundColor: '#e3f2fd',
color: '#1976d2',
padding: '0.25rem 0.5rem',
borderRadius: '4px',
fontSize: '0.8rem',
fontWeight: 500,
},
tokenBreakdown: {
display: 'flex',
flexDirection: 'column' as const,
},
tokenDetail: {
color: '#7f8c8d',
fontSize: '0.75rem',
},
statusBadge: {
padding: '0.25rem 0.5rem',
borderRadius: '4px',
fontSize: '0.8rem',
fontWeight: 500,
},
statusSuccess: {
backgroundColor: '#d4edda',
color: '#155724',
},
statusError: {
backgroundColor: '#f8d7da',
color: '#721c24',
},
noData: {
padding: '2rem',
textAlign: 'center' as const,
color: '#7f8c8d',
},
};