Implement Personality system backend with database schema, service, controller, and comprehensive tests. Personalities define assistant behavior with system prompts and LLM configuration. Changes: - Update Personality model in schema.prisma with LLM provider relation - Create PersonalitiesService with CRUD and default management - Create PersonalitiesController with REST endpoints - Add DTOs with validation (create/update) - Add entity for type safety - Remove unused PromptFormatterService - Achieve 26 tests with full coverage Endpoints: - GET /personality - List all - GET /personality/default - Get default - GET /personality/by-name/:name - Get by name - GET /personality/:id - Get one - POST /personality - Create - PATCH /personality/:id - Update - DELETE /personality/:id - Delete - POST /personality/:id/set-default - Set default Fixes #130 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
60 lines
974 B
TypeScript
60 lines
974 B
TypeScript
import {
|
|
IsString,
|
|
IsOptional,
|
|
IsBoolean,
|
|
IsNumber,
|
|
IsInt,
|
|
IsUUID,
|
|
MinLength,
|
|
MaxLength,
|
|
Min,
|
|
Max,
|
|
} from "class-validator";
|
|
|
|
/**
|
|
* DTO for creating a new personality/assistant configuration
|
|
*/
|
|
export class CreatePersonalityDto {
|
|
@IsString()
|
|
@MinLength(1)
|
|
@MaxLength(100)
|
|
name!: string; // unique identifier slug
|
|
|
|
@IsString()
|
|
@MinLength(1)
|
|
@MaxLength(200)
|
|
displayName!: string; // human-readable name
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(1000)
|
|
description?: string;
|
|
|
|
@IsString()
|
|
@MinLength(10)
|
|
systemPrompt!: string;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
@Max(2)
|
|
temperature?: number; // null = use provider default
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
maxTokens?: number; // null = use provider default
|
|
|
|
@IsOptional()
|
|
@IsUUID("4")
|
|
llmProviderInstanceId?: string; // FK to LlmProviderInstance
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isDefault?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isEnabled?: boolean;
|
|
}
|