import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsArray, IsIn, IsOptional, IsString, ValidateNested } from 'class-validator'; import { StreamChatRequest } from '@shared/ai-gateway/types/chat.types'; class ChatMessageDto { @ApiProperty({ enum: ['system', 'user', 'assistant'] }) @IsString() @IsIn(['system', 'user', 'assistant']) role!: 'system' | 'user' | 'assistant'; @ApiProperty({ description: '消息内容', example: '你是谁' }) @IsString() content!: string; } export class StreamChatBodyDto implements StreamChatRequest { @ApiPropertyOptional({ description: '模型名', example: 'qwen-plus' }) @IsOptional() @IsString() model?: string; @ApiPropertyOptional({ description: '指定平台,不传或 auto 由路由自动选择', enum: ['auto', 'qwen', 'deepseek', 'volc'], example: 'qwen', }) @IsOptional() @IsString() platform?: string; @ApiProperty({ type: [ChatMessageDto] }) @IsArray() @ValidateNested({ each: true }) @Type(() => ChatMessageDto) messages!: ChatMessageDto[]; }