Backup #1422

ID1422
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Domain/Entity/ChatSession.php
Version17
Typ modified
Größe5.6 KB
Hashfc115384ff6565e3eaac1603f078fd190a4fdf30bc8d952623e8f330df45e935
Datum2025-12-25 16:59:16
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace Domain\Entity;

// @responsibility: Repräsentiert eine Chat-Session mit ihren Metadaten

use Domain\ValueObject\SessionMetadata;
use Domain\ValueObject\SessionUuid;

class ChatSession
{
    public function __construct(
        private readonly SessionUuid $uuid,
        private readonly SessionMetadata $metadata,
        private readonly ?int $id = null,
        private readonly ?string $sessionToken = null,
        private readonly ?int $userId = null,
        private readonly ?int $personaId = null,
        private readonly ?string $title = null,
        private readonly ?int $authorProfileId = null,
        private readonly ?int $systemPromptId = null,
        private readonly \DateTimeImmutable $createdAt = new \DateTimeImmutable(),
        private readonly \DateTimeImmutable $updatedAt = new \DateTimeImmutable(),
        private readonly \DateTimeImmutable $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<string>
     */
    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, $collections, $contextLimit, $temperature, $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<string, mixed>
     */
    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'),
        ];
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1430 18 modified 4.5 KB 2025-12-25 16:59
1422 17 modified 5.6 KB 2025-12-25 16:59
1416 16 modified 5.7 KB 2025-12-25 16:59
1407 15 modified 7.9 KB 2025-12-25 16:58
1398 14 modified 9.8 KB 2025-12-25 16:58
1394 13 modified 9.9 KB 2025-12-25 16:58
1392 12 modified 10.0 KB 2025-12-25 16:57
1151 11 modified 10.0 KB 2025-12-25 09:53
1150 10 modified 9.9 KB 2025-12-25 09:53
1149 9 modified 9.8 KB 2025-12-25 09:53
1148 8 modified 9.8 KB 2025-12-25 09:53
1147 7 modified 10.0 KB 2025-12-25 09:53
1146 6 modified 10.0 KB 2025-12-25 09:53
1138 5 modified 9.8 KB 2025-12-25 09:43
1129 4 modified 9.8 KB 2025-12-25 09:40
1128 3 modified 9.8 KB 2025-12-25 09:40
1127 2 modified 9.8 KB 2025-12-25 09:40
1126 1 modified 9.1 KB 2025-12-25 09:40

← Zurück zur Übersicht