完善会话消息删除、Qwen 联网搜索/深度思考参数与 SSE 来源事件,同时增加请求体日志与 TS6 配置兼容调整,并新增 Ubuntu+PM2+Nginx 的部署文档与脚本以支持可回滚发布。 Made-with: Cursor
82 lines
1.9 KiB
TypeScript
82 lines
1.9 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||
import { Type } from 'class-transformer';
|
||
import {
|
||
IsArray,
|
||
IsBoolean,
|
||
IsIn,
|
||
IsOptional,
|
||
IsString,
|
||
ValidateNested,
|
||
} from 'class-validator';
|
||
import { StreamChatRequest } from '@shared/ai-gateway/types/chat.types';
|
||
|
||
export class ChatMessageDto {
|
||
@ApiProperty({
|
||
type: String,
|
||
enum: ['system', 'user', 'assistant'],
|
||
description: '消息角色',
|
||
example: 'user',
|
||
})
|
||
@IsString()
|
||
@IsIn(['system', 'user', 'assistant'])
|
||
role!: 'system' | 'user' | 'assistant';
|
||
|
||
@ApiProperty({ type: String, description: '消息内容', example: '你是谁' })
|
||
@IsString()
|
||
content!: string;
|
||
}
|
||
|
||
export class StreamChatBodyDto implements StreamChatRequest {
|
||
@ApiPropertyOptional({ type: String, description: '模型名', example: 'qwen-plus' })
|
||
@IsOptional()
|
||
@IsString()
|
||
model?: string;
|
||
|
||
@ApiProperty({
|
||
type: String,
|
||
description: '会话 ID(数字字符串);需先调用创建会话接口获取',
|
||
example: '1',
|
||
})
|
||
@IsString()
|
||
sessionId!: string;
|
||
|
||
@ApiPropertyOptional({
|
||
type: String,
|
||
description: '指定平台,不传或 auto 由路由自动选择',
|
||
enum: ['auto', 'qwen', 'deepseek', 'volc'],
|
||
example: 'qwen',
|
||
})
|
||
@IsOptional()
|
||
@IsString()
|
||
platform?: string;
|
||
|
||
@ApiPropertyOptional({
|
||
type: Boolean,
|
||
description: '是否启用联网搜索(当前仅 qwen 平台生效)',
|
||
example: true,
|
||
})
|
||
@IsOptional()
|
||
@IsBoolean()
|
||
enableWebSearch?: boolean;
|
||
|
||
@ApiPropertyOptional({
|
||
type: Boolean,
|
||
description: '是否启用深度思考(当前仅 qwen 平台生效)',
|
||
example: true,
|
||
})
|
||
@IsOptional()
|
||
@IsBoolean()
|
||
enableThinking?: boolean;
|
||
|
||
@ApiProperty({
|
||
type: () => ChatMessageDto,
|
||
isArray: true,
|
||
description: '聊天消息列表(至少一条用户消息)',
|
||
})
|
||
@IsArray()
|
||
@ValidateNested({ each: true })
|
||
@Type(() => ChatMessageDto)
|
||
messages!: ChatMessageDto[];
|
||
}
|
||
|