createdAt ??= new \DateTimeImmutable(); $this->updatedAt ??= new \DateTimeImmutable(); $this->lastActivity ??= new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid->value(); } public function getUuidObject(): SessionUuid { return $this->uuid; } public function getSessionToken(): ?string { return $this->sessionToken; } public function getUserId(): ?int { return $this->userId; } public function getPersonaId(): ?int { return $this->personaId; } public function getTitle(): ?string { return $this->title; } public function getModel(): string { return $this->metadata->getModel(); } /** * @return array */ public function getCollections(): array { return $this->metadata->getCollections(); } public function getContextLimit(): int { return $this->metadata->getContextLimit(); } public function getTemperature(): float { return $this->metadata->getTemperature(); } public function getMaxTokens(): int { return $this->metadata->getMaxTokens(); } public function getAuthorProfileId(): ?int { return $this->authorProfileId; } public function getSystemPromptId(): ?int { return $this->systemPromptId; } public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } public function getUpdatedAt(): \DateTimeImmutable { return $this->updatedAt; } public function getLastActivity(): \DateTimeImmutable { return $this->lastActivity; } public function withId(int $id): self { return new self( uuid: $this->uuid, metadata: $this->metadata, id: $id, sessionToken: $this->sessionToken, userId: $this->userId, personaId: $this->personaId, title: $this->title, authorProfileId: $this->authorProfileId, systemPromptId: $this->systemPromptId, createdAt: $this->createdAt, updatedAt: $this->updatedAt, lastActivity: $this->lastActivity ); } public function withTitle(string $title): self { return new self( uuid: $this->uuid, metadata: $this->metadata, id: $this->id, sessionToken: $this->sessionToken, userId: $this->userId, personaId: $this->personaId, title: $title, authorProfileId: $this->authorProfileId, systemPromptId: $this->systemPromptId, createdAt: $this->createdAt, updatedAt: new \DateTimeImmutable(), lastActivity: new \DateTimeImmutable() ); } public function updateSettings( string $model, array $collections, int $contextLimit, ?int $authorProfileId, float $temperature, int $maxTokens ): self { $newMetadata = SessionMetadata::create( model: $model, collections: $collections, contextLimit: $contextLimit, temperature: $temperature, maxTokens: $maxTokens ); return new self( uuid: $this->uuid, metadata: $newMetadata, id: $this->id, sessionToken: $this->sessionToken, userId: $this->userId, personaId: $this->personaId, title: $this->title, authorProfileId: $authorProfileId, systemPromptId: $this->systemPromptId, createdAt: $this->createdAt, updatedAt: new \DateTimeImmutable(), lastActivity: new \DateTimeImmutable() ); } /** * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'uuid' => $this->uuid->value(), 'session_token' => $this->sessionToken, 'user_id' => $this->userId, 'persona_id' => $this->personaId, 'title' => $this->title, 'model' => $this->metadata->getModel(), 'collections' => json_encode($this->metadata->getCollections()), 'context_limit' => $this->metadata->getContextLimit(), 'temperature' => $this->metadata->getTemperature(), 'max_tokens' => $this->metadata->getMaxTokens(), 'author_profile_id' => $this->authorProfileId, 'system_prompt_id' => $this->systemPromptId, 'created_at' => $this->createdAt->format('Y-m-d H:i:s'), 'updated_at' => $this->updatedAt->format('Y-m-d H:i:s'), 'last_activity' => $this->lastActivity->format('Y-m-d H:i:s'), ]; } }