feat(#82): implement Personality Module
- Add Personality model to Prisma schema with FormalityLevel enum - Create migration and seed with 6 default personalities - Implement CRUD API with TDD approach (97.67% coverage) * PersonalitiesService: findAll, findOne, findDefault, create, update, remove * PersonalitiesController: REST endpoints with auth guards * Comprehensive test coverage (21 passing tests) - Add Personality types to shared package - Create frontend components: * PersonalitySelector: dropdown for choosing personality * PersonalityPreview: preview personality style and system prompt * PersonalityForm: create/edit personalities with validation * Settings page: manage personalities with CRUD operations - Integrate with Ollama API: * Support personalityId in chat endpoint * Auto-inject system prompt from personality * Fall back to default personality if not specified - API client for frontend personality management All tests passing with 97.67% backend coverage (exceeds 85% requirement)
This commit is contained in:
43
apps/api/src/personalities/dto/create-personality.dto.ts
Normal file
43
apps/api/src/personalities/dto/create-personality.dto.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { IsString, IsIn, IsOptional, IsBoolean, MinLength, MaxLength } from "class-validator";
|
||||
|
||||
export const FORMALITY_LEVELS = [
|
||||
"VERY_CASUAL",
|
||||
"CASUAL",
|
||||
"NEUTRAL",
|
||||
"FORMAL",
|
||||
"VERY_FORMAL",
|
||||
] as const;
|
||||
|
||||
export type FormalityLevel = (typeof FORMALITY_LEVELS)[number];
|
||||
|
||||
export class CreatePersonalityDto {
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(100)
|
||||
name!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(500)
|
||||
description?: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
tone!: string;
|
||||
|
||||
@IsIn(FORMALITY_LEVELS)
|
||||
formalityLevel!: FormalityLevel;
|
||||
|
||||
@IsString()
|
||||
@MinLength(10)
|
||||
systemPromptTemplate!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isDefault?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isActive?: boolean;
|
||||
}
|
||||
2
apps/api/src/personalities/dto/index.ts
Normal file
2
apps/api/src/personalities/dto/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./create-personality.dto";
|
||||
export * from "./update-personality.dto";
|
||||
4
apps/api/src/personalities/dto/update-personality.dto.ts
Normal file
4
apps/api/src/personalities/dto/update-personality.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from "@nestjs/mapped-types";
|
||||
import { CreatePersonalityDto } from "./create-personality.dto";
|
||||
|
||||
export class UpdatePersonalityDto extends PartialType(CreatePersonalityDto) {}
|
||||
Reference in New Issue
Block a user