// server/src/model-config/dto/create-model-config.dto.ts
import {
  IsBoolean,
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
  IsUrl,
  Max,
  Min,
  MinLength,
} from 'class-validator';
import { ModelType } from '../../types';

export class CreateModelConfigDto {
  @IsString()
  @IsNotEmpty()
  name: string;

  @IsString()
  @IsNotEmpty()
  modelId: string;

  @IsUrl({ require_tld: false }, { message: 'Base URL must be a valid URL' })
  @IsOptional()
  baseUrl?: string;

  @IsString()
  @IsOptional()
  apiKey?: string; // API key is optional - allows local models

  @IsEnum(ModelType)
  @IsNotEmpty()
  type: ModelType;

  @IsNumber()
  @Min(1, { message: 'Minimum vector dimension is 1' })
  @Max(4096, { message: 'Maximum vector dimension is 4096 (Elasticsearch limit)' })
  @IsOptional()
  dimensions?: number;

  // ==================== Additional Fields ====================

  /**
   * Model input token limit (only valid for embedding/rerank)
   */
  @IsNumber()
  @Min(1)
  @Max(100000)
  @IsOptional()
  maxInputTokens?: number;

  /**
   * Batch processing limit (only valid for embedding/rerank)
   */
  @IsNumber()
  @Min(1)
  @Max(10000)
  @IsOptional()
  maxBatchSize?: number;

  /**
   * Whether this is a vector model
   */
  @IsBoolean()
  @IsOptional()
  isVectorModel?: boolean;

  /**
   * Model provider name
   */
  @IsString()
  @IsOptional()
  providerName?: string;

  /**
   * Whether to enable this model
   */
  @IsBoolean()
  @IsOptional()
  isEnabled?: boolean;

  /**
   * Whether to use this model as default
   */
  @IsBoolean()
  @IsOptional()
  isDefault?: boolean;
}
