feat: benchmark list

This commit is contained in:
jialin
2026-01-30 18:48:55 +08:00
parent 8b282afb03
commit 37b814b70a
29 changed files with 1034 additions and 19 deletions
@@ -0,0 +1,20 @@
import { PageActionType } from '@/config/types';
import { createContext, useContext } from 'react';
interface FormContextProps {
action: PageActionType;
}
const FormContext = createContext<FormContextProps>({} as FormContextProps);
export const useFormContext = () => {
const context = useContext(FormContext);
if (!context) {
throw new Error(
'useFormContext must be used within a FormContext.Provider'
);
}
return context;
};
export default FormContext;
+29
View File
@@ -0,0 +1,29 @@
import { StatusMaps } from '@/config';
import { StatusType } from '@/config/types';
export const BenchmarkStatusValueMap = {
Pending: 'pending',
Claimed: 'claimed',
Running: 'running',
Completed: 'completed',
Error: 'error',
Unreachable: 'unreachable'
};
export const BenchmarkStatusLabelMap = {
[BenchmarkStatusValueMap.Pending]: 'Pending',
[BenchmarkStatusValueMap.Claimed]: 'Claimed',
[BenchmarkStatusValueMap.Running]: 'Running',
[BenchmarkStatusValueMap.Completed]: 'Completed',
[BenchmarkStatusValueMap.Error]: 'Error',
[BenchmarkStatusValueMap.Unreachable]: 'Unreachable'
};
export const BenchmarkStatus: Record<string, StatusType> = {
[BenchmarkStatusValueMap.Pending]: StatusMaps.transitioning,
[BenchmarkStatusValueMap.Claimed]: StatusMaps.warning,
[BenchmarkStatusValueMap.Running]: StatusMaps.success,
[BenchmarkStatusValueMap.Completed]: StatusMaps.success,
[BenchmarkStatusValueMap.Error]: StatusMaps.error,
[BenchmarkStatusValueMap.Unreachable]: StatusMaps.error
};
+103
View File
@@ -0,0 +1,103 @@
export interface ComputedResourceClaim {
is_unified_memory: boolean;
offload_layers: number;
total_layers: number;
ram: number;
vram: Record<string, number>;
tensor_split: number[];
vram_utilization: number;
}
export interface ComputedResourceClaim1 {
is_unified_memory: boolean;
offload_layers: number;
total_layers: number;
ram: number;
vram: Record<string, number>;
tensor_split: number[];
vram_utilization: number;
}
export interface SubordinateWorkersItem {
computed_resource_claim: ComputedResourceClaim1;
ports: number[];
worker_id: number;
worker_name: string;
gpu_type: string;
gpu_indexes: number[];
gpu_ids: string[];
}
export interface InstanceSnapshot {
computed_resource_claim: ComputedResourceClaim;
ports: number[];
worker_id: number;
worker_name: string;
gpu_type: string;
gpu_indexes: number[];
gpu_ids: string[];
id: number;
name: string;
state: string;
state_message: string;
backend: string;
backend_version: string;
api_detected_backend_version: string;
subordinate_workers: SubordinateWorkersItem[];
}
export interface GPUSnapshot {
vendor: string;
type: string;
index: number;
device_index: number;
device_chip_index: number;
arch_family: string;
name: string;
uuid: string;
driver_version: string;
runtime_version: string;
compute_capability: string;
id: string;
worker_id: number;
worker_name: string;
memory_total: number;
core_total: number;
}
export interface FormData {
name: string;
description: string;
labels: Record<string, string>;
cluster_id: number;
model_id: number;
model_name: string;
model_instance_name: string;
dataset_id: number;
dataset_name: string;
dataset_source: string;
dataset_prompt_tokens: number;
dataset_output_tokens: number;
total_requests: number;
request_rate: number;
instance_snapshots: Record<string, InstanceSnapshot>;
gpu_snapshots: Record<string, GPUSnapshot>;
state: string;
state_message: string;
worker_id: number;
gpu_summary: string;
gpu_vendor_summary: string;
}
export interface BenchmarkListItem extends FormData {
id: number;
created_at: string;
updated_at: string;
}
export interface DatasetListItem {
name: string;
source: string;
prompt_tokens: number;
output_tokens: number;
}