/**
 * 全量 Mock 数据
 * 为前端开发提供不依赖后端的模拟数据
 */

import type {
  FineTuneTask,
  ModelItem,
  TrainedModel,
  DatasetItem,
  CompareTask,
  EvalTask,
  EvalTaskDetail,
  Dimension,
  SystemInfo,
  HealthMetrics,
  LogFile,
  TrainingLogFile,
  LogContent,
} from '@/types'

// ============ 认证 ============
export const mockLoginOk = { code: 0, message: 'ok', data: { token: 'mock-token' } }

// ============ 系统监控 ============
export const mockHealth: HealthMetrics = {
  cpu_percent: 32,
  memory_percent: 58,
  disk_percent: 45,
}

export const mockSystemInfo: SystemInfo = {
  timestamp: '2026-07-12T10:30:00+08:00',
  cpu: {
    percent: 32,
    cores: 8,
    percents: [25, 38, 42, 30, 28, 36, 40, 18],
    model: 'Intel Xeon Gold 6330',
    frequency_mhz: 2500,
    load_1m: 2.56,
  },
  memory: {
    used_gb: 9.2,
    total_gb: 16,
    percent: 58,
    available_gb: 6.8,
    cached_gb: 2.3,
  },
  disk: {
    used_gb: 230,
    total_gb: 512,
    percent: 45,
    read_mb_s: 86.4,
    write_mb_s: 34.8,
  },
  gpu: [
    {
      id: 0,
      uuid: 'GPU-MOCK-A800-00',
      name: 'NVIDIA A800',
      status: 'busy',
      gpu_percent: 74,
      memory_used_gb: 41.8,
      memory_total_gb: 80,
      memory_percent: 52.3,
      temperature: 63,
      power_w: 286,
      power_limit_w: 400,
      fan_speed: 51,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [
        { pid: 28741, name: 'python', task_name: 'medical-cpt-001 / rank 0', user: 'trainer', memory_used_gb: 39.6 },
        { pid: 28768, name: 'python', task_name: '训练指标采集', user: 'trainer', memory_used_gb: 2.2 },
      ],
    },
    {
      id: 1,
      uuid: 'GPU-MOCK-A800-01',
      name: 'NVIDIA A800',
      status: 'busy',
      gpu_percent: 71,
      memory_used_gb: 42.1,
      memory_total_gb: 80,
      memory_percent: 52.6,
      temperature: 62,
      power_w: 279,
      power_limit_w: 400,
      fan_speed: 49,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [
        { pid: 28742, name: 'python', task_name: 'medical-cpt-001 / rank 1', user: 'trainer', memory_used_gb: 39.9 },
        { pid: 28769, name: 'python', task_name: '训练指标采集', user: 'trainer', memory_used_gb: 2.2 },
      ],
    },
    {
      id: 2,
      uuid: 'GPU-MOCK-A800-02',
      name: 'NVIDIA A800',
      status: 'busy',
      gpu_percent: 73,
      memory_used_gb: 58.7,
      memory_total_gb: 80,
      memory_percent: 73.4,
      temperature: 68,
      power_w: 320,
      power_limit_w: 400,
      fan_speed: 58,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [
        { pid: 20118, name: 'python', task_name: '大模型推理服务', user: 'inference', memory_used_gb: 56.4 },
        { pid: 20207, name: 'python', task_name: '推理指标采集', user: 'inference', memory_used_gb: 2.3 },
      ],
    },
    {
      id: 3,
      uuid: 'GPU-MOCK-A800-03',
      name: 'NVIDIA A800',
      status: 'idle',
      gpu_percent: 0,
      memory_used_gb: 0,
      memory_total_gb: 80,
      memory_percent: 0,
      temperature: 34,
      power_w: 42,
      power_limit_w: 400,
      fan_speed: 0,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [],
    },
    {
      id: 4,
      uuid: 'GPU-MOCK-A800-04',
      name: 'NVIDIA A800',
      status: 'busy',
      gpu_percent: 46,
      memory_used_gb: 36.8,
      memory_total_gb: 80,
      memory_percent: 46,
      temperature: 60,
      power_w: 210,
      power_limit_w: 400,
      fan_speed: 42,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [
        { pid: 22680, name: 'python', task_name: '批量评测任务', user: 'evaluation', memory_used_gb: 32 },
        { pid: 22814, name: 'python', task_name: '模型裁判服务', user: 'evaluation', memory_used_gb: 4.8 },
      ],
    },
    {
      id: 5,
      uuid: 'GPU-MOCK-A800-05',
      name: 'NVIDIA A800',
      status: 'idle',
      gpu_percent: 0,
      memory_used_gb: 0,
      memory_total_gb: 80,
      memory_percent: 0,
      temperature: 33,
      power_w: 40,
      power_limit_w: 400,
      fan_speed: 0,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [],
    },
    {
      id: 6,
      uuid: 'GPU-MOCK-A800-06',
      name: 'NVIDIA A800',
      status: 'warning',
      gpu_percent: 85,
      memory_used_gb: 68.2,
      memory_total_gb: 80,
      memory_percent: 85.3,
      temperature: 73,
      power_w: 365,
      power_limit_w: 400,
      fan_speed: 62,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [
        { pid: 24129, name: 'python', task_name: '全参数训练任务', user: 'trainer', memory_used_gb: 63.5 },
        { pid: 24211, name: 'python', task_name: '训练检查点保存', user: 'trainer', memory_used_gb: 4.7 },
      ],
    },
    {
      id: 7,
      uuid: 'GPU-MOCK-A800-07',
      name: 'NVIDIA A800',
      status: 'busy',
      gpu_percent: 15,
      memory_used_gb: 12,
      memory_total_gb: 80,
      memory_percent: 15,
      temperature: 45,
      power_w: 95,
      power_limit_w: 400,
      fan_speed: 22,
      clock_mhz: 1410,
      driver_version: '535.86.10',
      processes: [
        { pid: 25367, name: 'python', task_name: '在线推理服务', user: 'inference', memory_used_gb: 12 },
      ],
    },
  ],
  network: {
    download_mb: 1024,
    upload_mb: 256,
    download_mb_s: 42.6,
    upload_mb_s: 12.4,
  },
  system: {
    uptime_seconds: 86400 * 3 + 3600 * 7 + 1800,
    process_count: 256,
    os: 'Ubuntu 22.04 LTS',
  },
}

// ============ 模型管理 ============
export const mockModels: ModelItem[] = [
  { id: 1, name: 'Qwen2.5-7B-Instruct', type: 'LLM', purpose: 'training', model_source: 'local', description: 'Qwen2.5 7B 指令微调基座', path: '/data/models/qwen2.5-7b', create_time: '2025-12-10T08:30:00Z' },
  { id: 2, name: 'Qwen2.5-14B-Instruct', type: 'LLM', purpose: 'training', model_source: 'local', description: 'Qwen2.5 14B 指令微调基座', path: '/data/models/qwen2.5-14b', create_time: '2025-12-12T10:15:00Z' },
  { id: 3, name: 'Llama3-8B-Instruct', type: 'LLM', purpose: 'inference', model_source: 'local', description: 'Llama3 8B 推理模型', path: '/data/models/llama3-8b', create_time: '2025-12-15T14:20:00Z' },
  { id: 4, name: 'DeepSeek-V2-Lite', type: 'LLM', purpose: 'inference', model_source: 'local', description: 'DeepSeek V2 Lite', path: '/data/models/deepseek-v2-lite', create_time: '2026-01-05T09:00:00Z' },
  { id: 5, name: 'GPT-4o', type: 'LLM', purpose: 'evaluation', model_source: 'api', description: 'OpenAI GPT-4o 在线模型', api_url: 'https://api.openai.com/v1', api_key: 'sk-***', online_model_name: 'gpt-4o', create_time: '2026-01-08T11:30:00Z' },
  { id: 6, name: 'Claude-3.5-Sonnet', type: 'LLM', purpose: 'evaluation', model_source: 'api', description: 'Anthropic Claude 3.5 Sonnet', api_url: 'https://api.anthropic.com', api_key: 'sk-***', online_model_name: 'claude-3-5-sonnet-20241022', create_time: '2026-01-10T16:45:00Z' },
  { id: 7, name: 'BGE-large-zh', type: 'Embedding', purpose: 'inference', model_source: 'local', description: '中文 embedding 模型', path: '/data/models/bge-large-zh', create_time: '2026-01-12T13:00:00Z' },
]

export const mockTrainedModels: { models: TrainedModel[] } = {
  models: [
    { id: 1, name: 'qwen-ft-finance-001', train_methods: [{ name: 'lora' }], base_model_path: '/data/models/qwen2.5-7b', merged: true, merging: false, merged_path: '/data/saves/qwen-ft-finance-001-merged', create_time: '2026-01-15T10:30:00Z' },
    { id: 2, name: 'qwen-ft-legal-002', train_methods: [{ name: 'lora' }], base_model_path: '/data/models/qwen2.5-7b', merged: false, merging: true, create_time: '2026-01-18T14:20:00Z' },
    { id: 3, name: 'llama3-ft-customer-service', train_methods: [{ name: 'qlora' }], base_model_path: '/data/models/llama3-8b', merged: true, merging: false, merged_path: '/data/saves/llama3-ft-customer-service-merged', create_time: '2026-01-22T09:45:00Z' },
    { id: 4, name: 'qwen-ft-medical-003', train_methods: [{ name: 'lora' }], base_model_path: '/data/models/qwen2.5-14b', merged: false, merging: false, create_time: '2026-02-01T16:10:00Z' },
  ],
}

export const mockLocalModels = {
  models: [
    { path: '/data/models/qwen2.5-7b', name: 'Qwen2.5-7B-Instruct' },
    { path: '/data/models/qwen2.5-14b', name: 'Qwen2.5-14B-Instruct' },
    { path: '/data/models/llama3-8b', name: 'Llama3-8B-Instruct' },
    { path: '/data/models/deepseek-v2-lite', name: 'DeepSeek-V2-Lite' },
    { path: '/data/models/bge-large-zh', name: 'BGE-large-zh' },
  ],
}

// ============ 数据集 ============
export const mockDatasets: DatasetItem[] = ([
  {
    id: 1,
    name: '金融问答-训练集',
    type: 'train',
    storage_type: 'local',
    source: 'upload',
    size: '128 MB',
    count: 8560,
    description: '面向金融领域问答场景的高质量指令微调数据集',
    create_time: '2025-12-20T08:00:00Z',
    files: [
      { id: 'finance-train-jsonl', name: 'finance_train.jsonl', size: '86.4 MB' },
    ],
  },
  { id: 2, name: '法律文书-训练集', type: 'train', storage_type: 'local', source: 'upload', size: '256 MB', count: 15230, description: '法律文书数据集', create_time: '2025-12-25T10:30:00Z' },
  { id: 3, name: '客服对话-训练集', type: 'train', storage_type: 'minio', source: 'upload', size: '512 MB', count: 24500, description: '客服对话记录', create_time: '2026-01-05T14:20:00Z' },
  { id: 4, name: '金融评测集', type: 'eval', storage_type: 'local', source: 'upload', size: '32 MB', count: 1200, description: '金融领域评测', create_time: '2026-01-10T09:15:00Z' },
  { id: 5, name: '通用能力评测', type: 'eval', storage_type: 'local', source: 'upload', size: '64 MB', count: 3500, description: '通用能力评测数据集', create_time: '2026-01-12T11:30:00Z' },
  { id: 6, name: '医疗问答-训练集', type: 'train', storage_type: 'local', source: 'upload', size: '180 MB', count: 9800, description: '医疗问答对', create_time: '2026-02-01T15:00:00Z' },
  { id: 7, name: '客服对话清洗集', type: 'train', storage_type: 'minio', source: 'task', task_id: 183921, size: '96 MB', count: 18240, description: '由客服问答数据清洗任务生成', create_time: '2026-07-08T06:28:00Z' },
  { id: 8, name: '通用指令构造集', type: 'train', storage_type: 'local', source: 'task', task_id: 492015, size: '148 MB', count: 12600, description: '由指令微调数据构造任务生成', create_time: '2026-07-09T01:42:00Z' },
  { id: 9, name: '用户反馈脱敏集', type: 'test', storage_type: 'minio', source: 'task', task_id: 731948, size: '72 MB', count: 9340, description: '由敏感信息脱敏任务生成', create_time: '2026-07-09T09:18:00Z' },
  { id: 10, name: '多轮对话增强集', type: 'eval', storage_type: 'local', source: 'task', task_id: 582012, size: '41 MB', count: 2780, description: '由多轮对话拼接任务生成', create_time: '2026-07-10T02:06:00Z' },
] satisfies DatasetItem[]).map((dataset) => ({
  ...dataset,
  files: dataset.files?.length
    ? dataset.files
    : [{ id: `dataset-${dataset.id}-samples`, name: 'dataset_samples.jsonl', size: dataset.size || '12.8 MB' }],
}))

export const mockDatasetPreviews: Record<string, string> = {
  'finance-train-jsonl': [
    '{"instruction":"什么是净资产收益率？","input":"","output":"净资产收益率（ROE）用于衡量企业运用自有资本获得收益的能力。"}',
    '{"instruction":"解释市盈率的含义","input":"某公司股价为 36 元，每股收益为 3 元。","output":"市盈率为股价除以每股收益，本例中市盈率为 12 倍。"}',
    '{"instruction":"央行降准通常会带来什么影响？","input":"","output":"降准通常会释放银行体系流动性，降低资金成本，并增强信贷投放能力。"}',
    '{"instruction":"如何理解债券久期？","input":"","output":"久期衡量债券价格对利率变化的敏感程度，久期越长，价格波动通常越大。"}',
    '{"instruction":"基金定投适合怎样的投资者？","input":"","output":"基金定投适合希望分散择时风险、进行中长期纪律性投资的投资者。"}',
    '{"instruction":"资产负债率过高意味着什么？","input":"","output":"可能意味着企业偿债压力较大、财务风险较高，但仍需结合行业特点判断。"}',
    '{"instruction":"通货膨胀如何影响实际收益率？","input":"","output":"实际收益率约等于名义收益率减去通货膨胀率。"}',
    '{"instruction":"什么是流动比率？","input":"","output":"流动比率等于流动资产除以流动负债，用于衡量短期偿债能力。"}',
    '{"instruction":"股票分红是否等于投资者获得额外收益？","input":"","output":"不完全等同，除息后股价通常会相应调整，应结合总回报判断。"}',
    '{"instruction":"如何区分系统性风险与非系统性风险？","input":"","output":"系统性风险影响整个市场，非系统性风险主要与单个公司或行业有关。"}',
    '{"instruction":"什么是复利？","input":"","output":"复利是将本金和此前产生的收益一并计入下一期收益计算。"}',
    '{"instruction":"现金流量表主要反映什么？","input":"","output":"现金流量表反映企业经营、投资和筹资活动产生的现金流入与流出。"}',
  ].join('\n'),
  'finance-validation-jsonl': [
    '{"instruction":"计算简单收益率","input":"买入价 100 元，卖出价 108 元，不考虑费用。","output":"简单收益率为 8%。"}',
    '{"instruction":"什么是信用利差？","input":"","output":"信用利差是信用债收益率相对无风险基准收益率的差额。"}',
    '{"instruction":"解释最大回撤","input":"","output":"最大回撤描述资产净值从历史高点到随后低点的最大跌幅。"}',
    '{"instruction":"什么是风险溢价？","input":"","output":"风险溢价是投资者因承担额外风险而要求的超额预期收益。"}',
  ].join('\n'),
  'dataset-readme': [
    '# 金融问答训练集',
    '',
    '本数据集用于金融领域指令微调与基础能力评测。',
    '',
    '## 文件说明',
    '',
    '- `finance_train.jsonl`：训练样本',
    '- `finance_validation.jsonl`：验证样本',
    '',
    '文本编码：UTF-8',
  ].join('\n'),
  'mock-jsonl': [
    '{"instruction":"请概括以下文本的核心观点","input":"人工智能正在提升企业的数据处理效率。","output":"人工智能能够帮助企业提升数据处理效率。"}',
    '{"instruction":"将用户问题改写为更清晰的表达","input":"这个功能咋用？","output":"请说明该功能的具体使用步骤。"}',
    '{"instruction":"判断文本情感倾向","input":"这次服务响应很及时，问题也解决了。","output":"正向"}',
    '{"instruction":"提取文本中的关键实体","input":"远光软件于周一发布了新的模型管理平台。","output":["远光软件","周一","模型管理平台"]}',
    '{"instruction":"生成简短回复","input":"您好，我想了解数据集上传支持哪些格式？","output":"您好，目前支持 JSON、JSONL、CSV、TXT 等常见格式。"}',
    '{"instruction":"对以下内容进行分类","input":"如何重置账户密码？","output":"账户与安全"}',
    '{"instruction":"找出句子中的时间信息","input":"系统将在 7 月 15 日凌晨 2 点进行升级。","output":"7 月 15 日凌晨 2 点"}',
    '{"instruction":"补全客服回复","input":"用户反馈页面加载缓慢。","output":"已收到您的反馈，我们正在排查页面加载问题，请稍后重试。"}',
  ].join('\n'),
  'mock-readme': [
    '# 数据集说明',
    '',
    '当前内容为前端 Mock 数据，用于预览页面布局与交互效果。',
    '',
    '## 文件结构',
    '',
    '- `dataset_samples.jsonl`：模拟的数据样本',
    '- `README.md`：数据集使用说明',
    '',
    '文本编码：UTF-8',
  ].join('\n'),
}

// ============ 训练任务 ============
export const mockFineTuneList: FineTuneTask[] = [
  {
    id: 103942,
    name: 'finance-sft-001',
    description: '金融领域 SFT 训练',
    status: 'completed',
    train_type: 'SFT',
    train_method: 'lora',
    template: 'qwen',
    base_model: 1,
    train_dataset_id: 1,
    output_model_name: 'qwen2.5-7b-finance-sft-v1',
    auto_merge: true,
    gpus: [0],
    batch_size: 8,
    learning_rate: 0.00002,
    n_epochs: 3,
    save_steps: 100,
    lr_scheduler_type: 'cosine',
    max_length: 2048,
    warmup_ratio: 0.05,
    weight_decay: 0.01,
    lora_rank: 16,
    lora_alpha: 32,
    lora_dropout: 0.05,
    quantization_bit: 0,
    process_id: 12345,
    progress: 100,
    train_duration: '2小时18分钟',
    create_time: '2026-01-15T08:00:00Z',
  },
  {
    id: 349102,
    name: 'legal-sft-002',
    description: '法律文书 SFT',
    status: 'completed',
    train_type: 'SFT',
    train_method: 'lora',
    template: 'qwen',
    base_model: 1,
    train_dataset_id: 2,
    output_model_name: 'qwen2.5-7b-legal-sft-v2',
    auto_merge: true,
    gpus: [1],
    batch_size: 4,
    learning_rate: 0.000015,
    n_epochs: 4,
    save_steps: 120,
    lr_scheduler_type: 'linear',
    max_length: 4096,
    warmup_ratio: 0.03,
    weight_decay: 0.01,
    lora_rank: 32,
    lora_alpha: 64,
    lora_dropout: 0.05,
    quantization_bit: 0,
    process_id: 12350,
    progress: 100,
    train_duration: '1小时46分钟',
    create_time: '2026-01-18T10:00:00Z',
  },
  {
    id: 849301,
    name: 'medical-cpt-001',
    description: '医疗领域继续预训练',
    status: 'running',
    train_type: 'CPT',
    train_method: 'lora',
    template: 'qwen2_5',
    base_model: 2,
    train_dataset_id: 6,
    output_model_name: 'qwen2.5-14b-medical-cpt-v1',
    auto_merge: true,
    gpus: [0, 1],
    batch_size: 2,
    learning_rate: 0.0001,
    n_epochs: 3,
    save_steps: 200,
    lr_scheduler_type: 'cosine',
    max_length: 4096,
    warmup_ratio: 0.03,
    weight_decay: 0.01,
    lora_rank: 16,
    lora_alpha: 32,
    lora_dropout: 0.05,
    quantization_bit: 0,
    process_id: 28741,
    progress: 64,
    train_duration: '36分钟',
    create_time: '2026-07-13T06:40:00Z',
  },
  {
    id: 593021,
    name: 'service-dpo-001',
    description: '客服对话偏好训练',
    status: 'pending',
    train_type: 'DPO',
    train_method: 'lora',
    template: 'qwen',
    base_model: 1,
    train_dataset_id: 3,
    output_model_name: 'qwen2.5-7b-service-dpo-v1',
    auto_merge: true,
    gpus: [2],
    batch_size: 4,
    learning_rate: 0.000005,
    n_epochs: 2,
    save_steps: 100,
    lr_scheduler_type: 'cosine',
    max_length: 2048,
    warmup_ratio: 0.1,
    weight_decay: 0,
    lora_rank: 16,
    lora_alpha: 32,
    lora_dropout: 0.1,
    quantization_bit: 0,
    progress: 0,
    train_duration: '等待调度',
    create_time: '2026-02-08T14:00:00Z',
  },
  {
    id: 201948,
    name: 'finance-sft-002',
    description: '金融领域二轮微调',
    status: 'failed',
    train_type: 'SFT',
    train_method: 'lora',
    template: 'qwen',
    base_model: 1,
    train_dataset_id: 1,
    output_model_name: 'qwen2.5-7b-finance-sft-v2',
    auto_merge: false,
    gpus: [3],
    batch_size: 8,
    learning_rate: 0.00002,
    n_epochs: 3,
    save_steps: 100,
    lr_scheduler_type: 'cosine',
    max_length: 2048,
    warmup_ratio: 0.05,
    weight_decay: 0.01,
    lora_rank: 16,
    lora_alpha: 32,
    lora_dropout: 0.05,
    quantization_bit: 0,
    process_id: 27654,
    progress: 32,
    train_duration: '18分钟',
    create_time: '2026-02-10T11:00:00Z',
  },
  {
    id: 940212,
    name: 'general-sft-001',
    description: '通用能力全参数微调',
    status: 'completed',
    train_type: 'SFT',
    train_method: 'full',
    template: 'llama3',
    base_model: 3,
    train_dataset_id: 3,
    output_model_name: 'llama3-8b-general-sft-v1',
    auto_merge: false,
    gpus: [0, 2],
    batch_size: 2,
    learning_rate: 0.00001,
    n_epochs: 2,
    save_steps: 250,
    lr_scheduler_type: 'cosine',
    max_length: 4096,
    warmup_ratio: 0.03,
    weight_decay: 0.1,
    process_id: 26318,
    progress: 100,
    train_duration: '3小时05分钟',
    create_time: '2026-02-12T13:00:00Z',
  },
]

// ============ 模型推理/对比 ============
export const mockCompareList: CompareTask[] = [
  {
    id: 1,
    name: '金融问答对比',
    model_name: '金融问答对比',
    description: '对比基座模型与微调模型',
    status: 'loaded',
    models: JSON.stringify([
      { model_id: 1, model_name: 'Qwen2.5-7B-Instruct', model_path: '/data/models/qwen2.5-7b', gpu_id: 0, source: 'database', port: 18001 },
      { model_id: 101, model_name: 'qwen-ft-finance-001', model_path: '/data/saves/qwen-ft-finance-001-merged', gpu_id: 1, source: 'trained', port: 18002 },
    ]),
    load_status: JSON.stringify({
      loaded_models: [
        { model_id: 1, model_name: 'Qwen2.5-7B-Instruct', status: 'ready', pid: 12345, port: 18001 },
        { model_id: 101, model_name: 'qwen-ft-finance-001', status: 'ready', pid: 12346, port: 18002 },
      ],
    }),
    create_time: '2026-02-15T10:00:00Z',
  },
  {
    id: 2,
    name: '客服场景推理',
    model_name: '客服场景推理',
    description: '客服对话推理测试',
    status: 'pending',
    models: JSON.stringify([{ model_id: 3, model_name: 'Llama3-8B-Instruct', model_path: '/data/models/llama3-8b', gpu_id: 2, source: 'database' }]),
    load_status: JSON.stringify({ loaded_models: [] }),
    create_time: '2026-02-18T11:00:00Z',
  },
  {
    id: 3,
    name: '法律文书推理',
    model_name: '法律文书推理',
    description: '法律文书推理测试',
    status: 'loaded',
    models: JSON.stringify([{ model_id: 102, model_name: 'qwen-ft-legal-002', model_path: '/data/saves/qwen-ft-legal-002-merged', gpu_id: 3, source: 'trained' }]),
    load_status: JSON.stringify({
      loaded_models: [
        { model_id: 102, model_name: 'qwen-ft-legal-002', status: 'ready', pid: 12350, port: 18003 },
      ],
    }),
    create_time: '2026-02-20T14:00:00Z',
  },
]

// ============ 模型评测 ============
export const mockEvalList: EvalTask[] = [
  { id: 1, eval_task_name: '金融模型评测-v1', model_name: 'qwen-ft-finance-001', dataset: '金融评测集', metric: 'accuracy', score: 87.5, status: 'completed', create_time: '2026-02-01T10:00:00Z' },
  { id: 2, eval_task_name: '客服模型评测-v1', model_name: 'llama3-ft-customer-service', dataset: '通用能力评测', metric: 'rouge-1', score: 0.82, status: 'completed', create_time: '2026-02-05T11:00:00Z' },
  { id: 3, eval_task_name: '基线对比评测', model_name: 'Qwen2.5-7B-Instruct', dataset: '金融评测集', metric: 'accuracy', score: 72.3, status: 'running', create_time: '2026-02-10T09:00:00Z' },
]

export const mockEvalDetails: EvalTaskDetail[] = [
  {
    ...mockEvalList[0],
    evaluator_model: 'GPT-4o',
    sample_count: 3,
    completed_count: 3,
    passed_count: 3,
    completed_time: '2026-02-01T10:18:00Z',
    overall_score: 87.5,
    overall_score_max: 100,
    overall_evaluation: '模型在金融基础知识与常见计算题上表现稳定，答案整体准确、直接。',
    improvement_suggestions: ['补充期限匹配、再平衡等资产配置知识', '在建议类回答中明确假设与风险边界', '增加复杂金融场景和反事实样本训练'],
    dimension_summary: [
      { name: '核心事实正确性', score: 91, max_score: 100, pass_rate: 100 },
      { name: '信息完整性', score: 84, max_score: 100, pass_rate: 100 },
      { name: '无幻觉', score: 90, max_score: 100, pass_rate: 100 },
      { name: '格式合规性', score: 85, max_score: 100, pass_rate: 100 },
    ],
    samples: [
      {
        id: 'finance-1', index: 1, status: 'completed', score: 1, max_score: 1, passed: true, judgement: '正确',
        input: '某公司流动资产为 800 万元，流动负债为 500 万元，流动比率是多少？',
        reference_answer: '流动比率为 1.6。',
        model_output: '流动比率 = 流动资产 ÷ 流动负债 = 800 ÷ 500 = 1.6。',
        evaluation_reason: '计算过程与结论均正确，并给出了必要公式。',
        dimension_scores: [{ name: '准确性', score: 1, max_score: 1 }, { name: '清晰度', score: 1, max_score: 1 }],
      },
      {
        id: 'finance-2', index: 2, status: 'completed', score: 1, max_score: 1, passed: true, judgement: '正确',
        input: '简述央行提高存款准备金率对市场流动性的影响。',
        reference_answer: '商业银行可贷资金减少，市场流动性通常收紧。',
        model_output: '提高存款准备金率会减少银行可用于放贷的资金，通常使市场流动性收紧。',
        evaluation_reason: '准确覆盖了传导路径，表述简洁。',
        dimension_scores: [{ name: '准确性', score: 1, max_score: 1 }, { name: '完整性', score: 0.9, max_score: 1 }],
      },
      {
        id: 'finance-3', index: 3, status: 'completed', score: 0.8, max_score: 1, passed: true, judgement: '部分正确',
        input: '投资者风险承受能力较低时，资产配置应注意什么？',
        reference_answer: '降低高波动资产比例，重视分散配置、流动性与本金安全。',
        model_output: '应以低波动资产为主，分散投资并预留流动资金，同时控制权益类资产比例。',
        evaluation_reason: '建议方向正确，但可进一步说明期限匹配与再平衡机制。',
        dimension_scores: [{ name: '准确性', score: 0.9, max_score: 1 }, { name: '完整性', score: 0.7, max_score: 1 }],
      },
    ],
  },
  {
    ...mockEvalList[1],
    evaluator_model: 'Claude-3.5-Sonnet',
    sample_count: 3,
    completed_count: 3,
    passed_count: 2,
    completed_time: '2026-02-05T11:21:00Z',
    overall_score: 0.82,
    overall_score_max: 1,
    overall_evaluation: '模型具备较好的客服语气和基础问题处理能力，但对订单状态约束的识别仍不稳定。',
    improvement_suggestions: ['增加已发货、已出库等边界状态样本', '要求模型在承诺操作前先核验业务规则', '为每类客服场景补充标准处理步骤'],
    dimension_summary: [
      { name: '核心事实正确性', score: 0.86, max_score: 1, pass_rate: 67 },
      { name: '信息完整性', score: 0.78, max_score: 1, pass_rate: 67 },
      { name: '无幻觉', score: 0.7, max_score: 1, pass_rate: 67 },
      { name: '格式合规性', score: 0.94, max_score: 1, pass_rate: 100 },
    ],
    samples: [
      {
        id: 'service-1', index: 1, status: 'completed', score: 0.91, max_score: 1, passed: true, judgement: '正确',
        input: '用户反馈收到的商品外包装破损，应如何回复？',
        reference_answer: '表达歉意，核实订单及破损情况，并提供补发或退款方案。',
        model_output: '很抱歉给您带来不便。请提供订单号和破损照片，我们核实后可为您安排补发或退款。',
        evaluation_reason: '关键信息覆盖完整，语气符合客服场景。',
        dimension_scores: [{ name: '相关性', score: 0.95, max_score: 1 }, { name: '服务语气', score: 0.96, max_score: 1 }],
      },
      {
        id: 'service-2', index: 2, status: 'completed', score: 0.84, max_score: 1, passed: true, judgement: '部分正确',
        input: '用户询问订单为何仍未发货。',
        reference_answer: '致歉并核查订单状态，告知预计发货时间和后续查询方式。',
        model_output: '抱歉让您久等了，我可以帮您核查订单状态，并尽快反馈预计发货时间。',
        evaluation_reason: '态度友好，但未主动说明后续查询方式。',
        dimension_scores: [{ name: '服务语气', score: 0.95, max_score: 1 }, { name: '完整性', score: 0.72, max_score: 1 }],
      },
      {
        id: 'service-3', index: 3, status: 'completed', score: 0.69, max_score: 1, passed: false, judgement: '错误', error_type: '其他',
        input: '用户要求立即取消已出库的订单。',
        reference_answer: '说明已出库订单可能无法直接取消，协助拦截或引导拒收、退货。',
        model_output: '好的，我现在为您取消订单，请稍候。',
        evaluation_reason: '未说明已出库限制，承诺了可能无法完成的操作。',
        dimension_scores: [{ name: '相关性', score: 0.7, max_score: 1 }, { name: '规则遵循', score: 0.35, max_score: 1 }],
      },
    ],
  },
  {
    ...mockEvalList[2],
    evaluator_model: 'GPT-4o',
    sample_count: 3,
    completed_count: 2,
    passed_count: 1,
    overall_score: 72.3,
    overall_score_max: 100,
    overall_evaluation: '当前为阶段性评价：模型基础计算能力正常，但逻辑推理表现波动，任务仍在运行。',
    improvement_suggestions: ['补充形式逻辑与多步推理样本', '任务完成后再依据完整结果复核综合结论'],
    dimension_summary: [
      { name: '核心事实正确性', score: 66.7, max_score: 100, pass_rate: 50 },
      { name: '信息完整性', score: 58, max_score: 100, pass_rate: 50 },
      { name: '无幻觉', score: 88, max_score: 100, pass_rate: 100 },
      { name: '格式合规性', score: 76, max_score: 100, pass_rate: 50 },
    ],
    samples: [
      {
        id: 'baseline-1', index: 1, status: 'completed', score: 1, max_score: 1, passed: true, judgement: '正确',
        input: '计算 15% 的 240。',
        reference_answer: '36。',
        model_output: '240 × 15% = 36。',
        evaluation_reason: '计算与结果均正确。',
        dimension_scores: [{ name: '准确性', score: 1, max_score: 1 }, { name: '清晰度', score: 1, max_score: 1 }],
      },
      {
        id: 'baseline-2', index: 2, status: 'completed', score: 0, max_score: 1, passed: false, judgement: '错误', error_type: '其他',
        input: '若所有 A 都是 B，且某个 C 是 A，可以推出什么？',
        reference_answer: '该 C 是 B。',
        model_output: '无法确定 C 是否属于 B。',
        evaluation_reason: '未正确应用包含关系的传递性。',
        dimension_scores: [{ name: '准确性', score: 0, max_score: 1 }, { name: '逻辑性', score: 0, max_score: 1 }],
      },
      {
        id: 'baseline-3', index: 3, status: 'pending', score: null, max_score: 1,
        input: '用一句话解释什么是机会成本。',
        reference_answer: '机会成本是选择某方案时放弃的最佳替代方案的价值。',
        model_output: '',
        evaluation_reason: '等待模型生成与评分。',
      },
    ],
  },
]

export const mockDimensions: Dimension[] = [
  { id: 1, name: '回答准确性', type: 'classification', description: '评估模型回答是否准确', eval_model: 'GPT-4o', eval_method: 'standard', eval_prompt: '# 角色\n你是专业的评估专家...', is_active: true, is_default: true, create_time: '2025-12-01T08:00:00Z' },
  { id: 2, name: '综合评分', type: 'metric', description: '0-5 分综合评分', eval_model: 'Claude-3.5-Sonnet', eval_method: 'metric_standard', eval_prompt: '# 角色\n你是专业评分专家...', is_active: true, is_default: false, score_min: 0, score_max: 5, pass_threshold: 3.5, create_time: '2025-12-05T09:00:00Z' },
  { id: 3, name: '语义相似度', type: 'metric', description: '生成文本与参考答案的语义相似度', eval_model: 'GPT-4o', eval_method: 'semantic', eval_prompt: '# 角色\n你是语义相似度评估专家...', is_active: true, is_default: false, score_min: 0, score_max: 1, pass_threshold: 0.7, create_time: '2025-12-08T10:00:00Z' },
  { id: 4, name: 'BLEU-4 相似度', type: 'text_similarity', description: '使用 BLEU-4 评估文本相似度', is_active: true, is_default: false, eval_method: ['bleu_4'], bleu_n: 4, output_precision: 3, create_time: '2025-12-10T11:00:00Z' },
  { id: 5, name: 'ROUGE 多指标', type: 'text_similarity', description: 'ROUGE-1/2/4 多指标评估', is_active: false, is_default: false, eval_method: ['rouge_1', 'rouge_2', 'rouge_4'], bleu_n: 1, output_precision: 3, create_time: '2025-12-12T13:00:00Z' },
]

// ============ 日志 ============
export const mockLogFiles: LogFile[] = [
  { file: 'system-2026-02-15.log', name: '系统日志-2026-02-15', size: '2.3 MB' },
  { file: 'error-2026-02-15.log', name: '错误日志-2026-02-15', size: '156 KB' },
  { file: 'system-2026-02-14.log', name: '系统日志-2026-02-14', size: '3.1 MB' },
]

export const mockTrainingLogFiles: TrainingLogFile[] = [
  { file: 'medical-cpt-001_pid28741.log', name: 'medical-cpt-001', size: '6.8 MB', pid: 28741, date: '2026-07-13' },
  { file: 'qwen-ft-finance-001_pid12345.log', name: 'finance-sft-001', size: '4.5 MB', pid: 12345, date: '2026-02-15' },
  { file: 'llama3-ft-customer-service_pid12346.log', name: 'service-dpo-001', size: '2.1 MB', pid: 12346, date: '2026-02-18' },
  { file: 'qwen-ft-legal-002_pid12350.log', name: 'legal-sft-002', size: '5.8 MB', pid: 12350, date: '2026-02-20' },
]

const medicalTrainingLogLines = [
  '[2026-07-13 14:40:01] INFO: Launching distributed training with torchrun --nproc_per_node=2',
  '[2026-07-13 14:40:02] INFO: Process rank: 0, world size: 2, device: cuda:0, distributed training: True',
  '[2026-07-13 14:40:04] INFO: Loading tokenizer from /data/models/qwen2.5-14b-instruct',
  '[2026-07-13 14:40:16] INFO: Loading checkpoint shards: 100% | 8/8 | 00:12',
  '[2026-07-13 14:40:18] INFO: Loading dataset 医疗问答-训练集 (9,800 samples)',
  '[2026-07-13 14:40:27] INFO: Tokenizing dataset: 100% | 9,800/9,800 | 00:09',
  '[2026-07-13 14:40:28] INFO: LoRA config: rank=16, alpha=32, dropout=0.05, target_modules=q_proj,k_proj,v_proj,o_proj',
  '[2026-07-13 14:40:29] INFO: Trainable params: 83,886,080 / 14,787,584,000 (0.5673%)',
  '[2026-07-13 14:40:30] INFO: ***** Running training *****',
  '[2026-07-13 14:40:30] INFO:   Num examples = 9,800',
  '[2026-07-13 14:40:30] INFO:   Num Epochs = 3',
  '[2026-07-13 14:40:30] INFO:   Instantaneous batch size per device = 2',
  '[2026-07-13 14:40:30] INFO:   Total train batch size = 32',
  '[2026-07-13 14:40:30] INFO:   Gradient Accumulation steps = 8',
  '[2026-07-13 14:40:30] INFO:   Total optimization steps = 921',
  '[2026-07-13 14:42:18] INFO: step=40 {\'loss\': 2.684, \'grad_norm\': 1.184, \'learning_rate\': 9.82e-05, \'epoch\': 0.13}',
  '[2026-07-13 14:44:26] INFO: step=80 {\'loss\': 2.312, \'grad_norm\': 1.092, \'learning_rate\': 9.68e-05, \'epoch\': 0.26}',
  '[2026-07-13 14:46:34] INFO: step=120 {\'loss\': 2.084, \'grad_norm\': 1.037, \'learning_rate\': 9.43e-05, \'epoch\': 0.39}',
  '[2026-07-13 14:48:42] INFO: step=160 {\'loss\': 1.932, \'grad_norm\': 0.986, \'learning_rate\': 9.08e-05, \'epoch\': 0.52}',
  '[2026-07-13 14:50:49] INFO: step=200 {\'loss\': 1.801, \'grad_norm\': 0.944, \'learning_rate\': 8.64e-05, \'epoch\': 0.65}',
  '[2026-07-13 14:50:54] INFO: Saving checkpoint to /data/checkpoints/medical-cpt-001/checkpoint-200',
  '[2026-07-13 14:52:58] INFO: step=240 {\'loss\': 1.696, \'grad_norm\': 0.913, \'learning_rate\': 8.15e-05, \'epoch\': 0.78}',
  '[2026-07-13 14:55:06] INFO: step=280 {\'loss\': 1.611, \'grad_norm\': 0.887, \'learning_rate\': 7.61e-05, \'epoch\': 0.91}',
  '[2026-07-13 14:57:13] INFO: step=320 {\'loss\': 1.532, \'grad_norm\': 0.852, \'learning_rate\': 7.06e-05, \'epoch\': 1.04}',
  '[2026-07-13 14:59:21] INFO: step=360 {\'loss\': 1.461, \'grad_norm\': 0.829, \'learning_rate\': 6.49e-05, \'epoch\': 1.17}',
  '[2026-07-13 15:01:29] INFO: step=400 {\'loss\': 1.396, \'grad_norm\': 0.811, \'learning_rate\': 5.91e-05, \'epoch\': 1.30}',
  '[2026-07-13 15:01:34] INFO: Saving checkpoint to /data/checkpoints/medical-cpt-001/checkpoint-400',
  '[2026-07-13 15:03:37] INFO: step=440 {\'loss\': 1.337, \'grad_norm\': 0.795, \'learning_rate\': 5.35e-05, \'epoch\': 1.43}',
  '[2026-07-13 15:05:45] INFO: step=480 {\'loss\': 1.286, \'grad_norm\': 0.776, \'learning_rate\': 4.80e-05, \'epoch\': 1.56}',
  '[2026-07-13 15:07:53] INFO: step=520 {\'loss\': 1.232, \'grad_norm\': 0.758, \'learning_rate\': 4.28e-05, \'epoch\': 1.69}',
  '[2026-07-13 15:11:59] INFO: step=560 {\'loss\': 1.184, \'grad_norm\': 0.741, \'learning_rate\': 3.79e-05, \'epoch\': 1.82}',
  '[2026-07-13 15:16:05] INFO: step=590 {\'loss\': 1.146, \'grad_norm\': 0.728, \'learning_rate\': 3.44e-05, \'epoch\': 1.92}',
  '[2026-07-13 15:16:06] INFO: Training is running normally, estimated remaining time: 00:20:15',
]

const fakeLogLines = [
  "[2026-02-15 08:30:12] INFO: Loading model from /data/models/qwen2.5-7b",
  "[2026-02-15 08:30:13] INFO: Loading dataset finance-train-001 (8560 samples)",
  "[2026-02-15 08:30:15] INFO: Training started with batch_size=8, learning_rate=2e-5",
  "[2026-02-15 08:32:45] INFO: {'loss': 2.341, 'grad_norm': 1.234, 'learning_rate': 1.95e-05, 'epoch': 0.05}",
  "[2026-02-15 08:34:15] INFO: {'loss': 1.892, 'grad_norm': 0.987, 'learning_rate': 1.88e-05, 'epoch': 0.10}",
  "[2026-02-15 08:35:42] INFO: {'loss': 1.543, 'grad_norm': 0.876, 'learning_rate': 1.79e-05, 'epoch': 0.15}",
  "[2026-02-15 08:37:10] INFO: {'loss': 1.287, 'grad_norm': 0.765, 'learning_rate': 1.70e-05, 'epoch': 0.20}",
  "[2026-02-15 08:38:55] INFO: {'loss': 1.056, 'grad_norm': 0.654, 'learning_rate': 1.60e-05, 'epoch': 0.25}",
  "[2026-02-15 08:40:30] WARN: Gradient norm exceeds threshold (0.654 > 0.5)",
  "[2026-02-15 08:42:00] INFO: {'loss': 0.892, 'grad_norm': 0.543, 'learning_rate': 1.50e-05, 'epoch': 0.30}",
  "[2026-02-15 08:45:15] INFO: Saved checkpoint to /data/checkpoints/finance-sft-001-step-100",
  "[2026-02-15 08:46:30] INFO: {'loss': 0.754, 'grad_norm': 0.432, 'learning_rate': 1.40e-05, 'epoch': 0.35}",
  "[2026-02-15 08:48:00] INFO: {'loss': 0.623, 'grad_norm': 0.398, 'learning_rate': 1.30e-05, 'epoch': 0.40}",
  "[2026-02-15 08:50:15] INFO: {'loss': 0.512, 'grad_norm': 0.345, 'learning_rate': 1.20e-05, 'epoch': 0.45}",
  "[2026-02-15 08:52:30] ERROR: Failed to save model: No space left on device",
  "[2026-02-15 08:52:31] INFO: Retrying save with compressed format...",
  "[2026-02-15 08:53:00] INFO: Model saved successfully (size: 14.2 GB)",
  "[2026-02-15 08:55:00] INFO: {'loss': 0.421, 'grad_norm': 0.298, 'learning_rate': 1.10e-05, 'epoch': 0.50}",
  "[2026-02-15 08:57:30] INFO: {'loss': 0.356, 'grad_norm': 0.256, 'learning_rate': 1.00e-05, 'epoch': 0.55}",
  "[2026-02-15 09:00:00] INFO: Training completed successfully",
  "",
  "***** train metrics *****",
  "  epoch = 1.0",
  "  total_flos = 1234567890",
  "  train_loss = 0.342",
  "  train_runtime = 1785.2",
  "  train_samples_per_second = 4.79",
  "  train_steps_per_second = 0.60",
  "***** train metrics end *****",
]

export const mockLogContent: LogContent = {
  file: 'system-2026-02-15.log',
  size: '2.3 MB',
  content: fakeLogLines.join('\n'),
}

export const mockTrainingLogContents: Record<string, LogContent> = {
  'medical-cpt-001_pid28741.log': {
    file: 'medical-cpt-001_pid28741.log',
    size: '6.8 MB',
    content: medicalTrainingLogLines.join('\n'),
  },
  'qwen-ft-finance-001_pid12345.log': {
    file: 'qwen-ft-finance-001_pid12345.log',
    size: '4.5 MB',
    content: fakeLogLines.join('\n'),
  },
}
