feat: implement QuestionBank CRUD with pagination and template query
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// server/src/model-config/dto/model-config-response.dto.ts
|
||||
import { Exclude, Expose, Transform } from 'class-transformer';
|
||||
import { ModelConfig } from '../model-config.entity';
|
||||
|
||||
export class ModelConfigResponseDto {
|
||||
id: string;
|
||||
name: string;
|
||||
provider: string;
|
||||
modelId: string;
|
||||
baseUrl?: string;
|
||||
|
||||
@Transform(({ value }) => (value ? '********' : undefined))
|
||||
apiKey?: string;
|
||||
|
||||
type: string;
|
||||
isEnabled?: boolean;
|
||||
isDefault?: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
|
||||
constructor(partial: Partial<ModelConfig>) {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// server/src/model-config/dto/update-model-config.dto.ts
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateModelConfigDto } from './create-model-config.dto';
|
||||
|
||||
export class UpdateModelConfigDto extends PartialType(CreateModelConfigDto) {}
|
||||
Reference in New Issue
Block a user