Refactor AI config to step-based wizard with DeepSeek defaults

This commit is contained in:
2026-07-24 10:01:51 +08:00
parent 065dfd9a38
commit 150e6ecff0
8 changed files with 568 additions and 184 deletions

View File

@@ -24,8 +24,8 @@ export class SaveAiConfigDto {
@IsIn(PROVIDERS)
provider!: AiProvider;
@ValidateIf((o: SaveAiConfigDto) => o.provider === AiProvider.OPENAI_COMPATIBLE || o.baseUrl !== undefined)
@IsNotEmpty({ message: 'OPENAI_COMPATIBLE 模式必须提供 baseUrl' })
@ValidateIf((o: SaveAiConfigDto) => o.provider === AiProvider.OPENAI_COMPATIBLE || (o.baseUrl !== undefined && o.baseUrl !== ''))
@IsNotEmpty({ message: 'Base URL 不能为空' })
@IsString()
baseUrl?: string;
@@ -113,4 +113,32 @@ export interface AiRuntimeConfig {
enabled: boolean;
}
/** DTO for POST /api/ai/config/models — fetch available model list from provider */
export class FetchModelsDto {
@IsOptional()
@IsIn(PROVIDERS)
provider?: AiProvider;
@IsOptional()
@IsString()
baseUrl?: string;
@IsOptional()
@IsString()
apiKey?: string;
@IsOptional()
@IsInt()
@Min(1000)
@Max(120000)
timeoutMs?: number;
}
/** Response shape for POST /api/ai/config/models */
export interface FetchModelsResultDto {
success: boolean;
models: Array<{ id: string }>;
message?: string;
}
export { DEFAULT_BASE_URLS };