chore: add pnpm workspace configuration for apps and packages
This commit is contained in:
@@ -101,7 +101,7 @@ DreamChat is a character simulation platform built with a modular, extensible ar
|
||||
#### 1. Auth Module
|
||||
```typescript
|
||||
// Dual authentication strategy
|
||||
- KeycloakStrategy (OAuth2/OIDC)
|
||||
- KeycloakStrategy (OAuth2/OIDC with group/role/attribute authorization)
|
||||
- LocalStrategy (Password-based)
|
||||
- JWT Guard for stateless auth
|
||||
- Roles: USER, ADMIN
|
||||
@@ -110,6 +110,13 @@ DreamChat is a character simulation platform built with a modular, extensible ar
|
||||
- id, email, username
|
||||
- passwordHash, keycloakSub
|
||||
- role, isActive
|
||||
|
||||
// Keycloak Authorization
|
||||
- Validates group membership (KEYCLOAK_REQUIRED_GROUP)
|
||||
- Checks realm roles (KEYCLOAK_REQUIRED_ROLE)
|
||||
- Checks client roles (KEYCLOAK_REQUIRED_CLIENT_ROLE)
|
||||
- Validates user attributes (KEYCLOAK_REQUIRED_ATTRIBUTE)
|
||||
- Auto-creates users on first login (if KEYCLOAK_AUTO_CREATE_USER=true)
|
||||
```
|
||||
|
||||
#### 2. Character Module
|
||||
@@ -119,14 +126,23 @@ DreamChat is a character simulation platform built with a modular, extensible ar
|
||||
- CharacterRepository (Prisma)
|
||||
- DTOs: CreateCharacterDto, UpdateCharacterDto, CharacterResponseDto
|
||||
|
||||
Entities:
|
||||
Prisma Models:
|
||||
- Character
|
||||
- id, name, avatar
|
||||
- id, name, avatarUrl
|
||||
- personalityPrompt: string
|
||||
- attributes: JSON (complex attribute system)
|
||||
- backstory: string
|
||||
- knowledgeSources: CharacterKnowledge[]
|
||||
- vectorMemories: VectorMemory[]
|
||||
- createdBy: User
|
||||
- createdAt, updatedAt
|
||||
|
||||
- CharacterKnowledge
|
||||
- id, name, sourceType (file/url/manual)
|
||||
- sourceName, mimeType, fileSize
|
||||
- rawContent: string
|
||||
- status (pending/processing/completed/failed)
|
||||
- processingInfo: JSON
|
||||
- vectorMemories: VectorMemory[]
|
||||
- characterId: Character
|
||||
```
|
||||
|
||||
#### 3. Chat Module (MVP)
|
||||
@@ -169,21 +185,32 @@ WebSocket Events:
|
||||
- HuggingFaceAPIProvider: Uses HuggingFace Inference API
|
||||
|
||||
- VectorStoreService (uses Prisma with pgvector extension)
|
||||
- addDocument(conversationId, content, metadata)
|
||||
- similaritySearch(conversationId, query, k=5)
|
||||
- addDocument(targetId, content, metadata, memoryType)
|
||||
- similaritySearch(targetId, query, k=5, memoryType)
|
||||
- Supports both conversation and character memory
|
||||
- Uses raw Prisma queries with pgvector operators
|
||||
|
||||
- MemoryManager
|
||||
- buildContext(conversationId, currentMessage): string
|
||||
- buildConversationContext(conversationId, currentMessage): string
|
||||
- buildCharacterContext(characterId, query): string
|
||||
- summarizeOldMessages(conversationId): Promise<void>
|
||||
- retrieveRelevantMemories(conversationId, query): Document[]
|
||||
- retrieveRelevantMemories(targetId, query, memoryType): Document[]
|
||||
|
||||
- CharacterKnowledgeService
|
||||
- importKnowledge(characterId, file/url)
|
||||
- chunkAndEmbed(knowledgeId, content)
|
||||
- processKnowledgeSource(knowledgeId)
|
||||
- searchCharacterKnowledge(characterId, query)
|
||||
|
||||
Prisma Model:
|
||||
- VectorMemory
|
||||
- id
|
||||
- conversationId (relation)
|
||||
- content: String
|
||||
- embedding: Unsupported("vector") // pgvector type
|
||||
- embedding: Unsupported("vector")
|
||||
- memoryType: enum ('conversation' | 'character')
|
||||
- conversationId?: Conversation
|
||||
- characterId?: Character
|
||||
- knowledgeId?: CharacterKnowledge
|
||||
- metadata: Json?
|
||||
- createdAt: DateTime
|
||||
```
|
||||
@@ -235,6 +262,23 @@ class DataPreprocessor {
|
||||
chunk(text: string, maxChunkSize: number): string[];
|
||||
extractEntities(text: string): Entity[];
|
||||
}
|
||||
|
||||
// Character Knowledge Import Service
|
||||
class CharacterKnowledgeService {
|
||||
// Import file/URL as character knowledge
|
||||
importKnowledge(characterId: string, file: File): Promise<CharacterKnowledge>;
|
||||
importFromUrl(characterId: string, url: string): Promise<CharacterKnowledge>;
|
||||
|
||||
// Process and embed knowledge
|
||||
processKnowledge(knowledgeId: string): Promise<void>;
|
||||
chunkAndEmbed(knowledgeId: string, content: string): Promise<void>;
|
||||
|
||||
// Search character knowledge
|
||||
searchKnowledge(characterId: string, query: string): Promise<VectorMemory[]>;
|
||||
|
||||
// Get knowledge context for LLM
|
||||
buildKnowledgeContext(characterId: string, query: string): string;
|
||||
}
|
||||
```
|
||||
|
||||
### Frontend (React + Vite)
|
||||
@@ -438,9 +482,17 @@ dreamchat/
|
||||
│ └── typescript/
|
||||
│
|
||||
├── prisma/ # Database schema (shared)
|
||||
│ ├── schema.prisma
|
||||
│ ├── schema.prisma # Main schema with imports
|
||||
│ ├── migrations/
|
||||
│ └── seed.ts
|
||||
│ ├── seed.ts
|
||||
│ └── models/ # Individual model files
|
||||
│ ├── user.prisma
|
||||
│ ├── character.prisma
|
||||
│ ├── conversation.prisma
|
||||
│ ├── message.prisma
|
||||
│ ├── vectorMemory.prisma
|
||||
│ ├── importDocument.prisma
|
||||
│ └── storyBranch.prisma
|
||||
│
|
||||
├── docker-compose.yml
|
||||
├── pnpm-workspace.yaml
|
||||
|
||||
Reference in New Issue
Block a user