Backup #1457

ID1457
Dateipfad/var/www/dev.campus.systemische-tools.de/src/UseCases/Chat/LoadChatSessionUseCase.php
Version5
Typ modified
Größe1.6 KB
Hash466db2fa9bdb47900037ee1310cd326d893d4294be448fabee496a23d2bf99f0
Datum2025-12-25 17:01:19
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace UseCases\Chat;

// @responsibility: Lädt Chat-Session mit allen Nachrichten

use Domain\Entity\ChatSession;
use Domain\Factory\ChatSessionFactory;
use Domain\Repository\ChatMessageRepositoryInterface;
use Domain\Repository\ChatSessionRepositoryInterface;
use Domain\ValueObject\SessionMetadata;
use Domain\ValueObject\SessionUuid;

class LoadChatSessionUseCase
{
    public function __construct(
        private ChatSessionRepositoryInterface $sessionRepo,
        private ChatMessageRepositoryInterface $messageRepo
    ) {
    }

    /**
     * Load session by UUID with all messages
     */
    public function execute(string $uuid): ?ChatSessionDTO
    {
        $session = $this->sessionRepo->findByUuid($uuid);

        if ($session === null) {
            return null;
        }

        $messages = $this->messageRepo->findBySessionId($session->getId() ?? 0);

        return new ChatSessionDTO($session, $messages);
    }

    /**
     * Create a new session and return it
     *
     * @param array<string> $collections
     */
    public function createNew(
        string $model = 'claude-opus-4-5-20251101',
        array $collections = ['documents'],
        int $contextLimit = 5
    ): ChatSessionDTO {
        $uuid = $this->sessionRepo->generateUuid();

        $session = ChatSession::create($uuid, $model, $collections, $contextLimit);
        $sessionId = $this->sessionRepo->save($session);

        // Reload to get full data including timestamps
        $savedSession = $this->sessionRepo->findByUuid($uuid);

        return new ChatSessionDTO($savedSession ?? $session->withId($sessionId), []);
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1469 7 modified 1.6 KB 2025-12-25 17:02
1461 6 modified 1.7 KB 2025-12-25 17:01
1457 5 modified 1.6 KB 2025-12-25 17:01
1454 4 modified 1.5 KB 2025-12-25 17:00
1125 3 modified 1.4 KB 2025-12-25 09:40
833 2 modified 1.6 KB 2025-12-23 08:16
715 1 modified 1.7 KB 2025-12-23 07:55

← Zurück zur Übersicht