feat(#130): add Personality Prisma schema and backend
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>
This commit is contained in:
@@ -921,28 +921,35 @@ model Personality {
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||
|
||||
// Identity
|
||||
name String
|
||||
name String // unique identifier slug
|
||||
displayName String @map("display_name")
|
||||
description String? @db.Text
|
||||
|
||||
// Personality traits
|
||||
tone String
|
||||
formalityLevel FormalityLevel @map("formality_level")
|
||||
// System prompt
|
||||
systemPrompt String @map("system_prompt") @db.Text
|
||||
|
||||
// System prompt template
|
||||
systemPromptTemplate String @map("system_prompt_template") @db.Text
|
||||
// LLM configuration
|
||||
temperature Float? // null = use provider default
|
||||
maxTokens Int? @map("max_tokens") // null = use provider default
|
||||
llmProviderInstanceId String? @map("llm_provider_instance_id") @db.Uuid
|
||||
|
||||
// Status
|
||||
isDefault Boolean @default(false) @map("is_default")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
isEnabled Boolean @default(true) @map("is_enabled")
|
||||
|
||||
// Audit
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
|
||||
|
||||
// Relations
|
||||
llmProviderInstance LlmProviderInstance? @relation("PersonalityLlmProvider", fields: [llmProviderInstanceId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@unique([id, workspaceId])
|
||||
@@unique([workspaceId, name])
|
||||
@@index([workspaceId])
|
||||
@@index([workspaceId, isDefault])
|
||||
@@index([workspaceId, isActive])
|
||||
@@index([workspaceId, isEnabled])
|
||||
@@index([llmProviderInstanceId])
|
||||
@@map("personalities")
|
||||
}
|
||||
|
||||
@@ -962,7 +969,8 @@ model LlmProviderInstance {
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
|
||||
|
||||
// Relations
|
||||
user User? @relation("UserLlmProviders", fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User? @relation("UserLlmProviders", fields: [userId], references: [id], onDelete: Cascade)
|
||||
personalities Personality[] @relation("PersonalityLlmProvider")
|
||||
|
||||
@@index([userId])
|
||||
@@index([providerType])
|
||||
|
||||
Reference in New Issue
Block a user