Backup #715

ID715
Dateipfad/var/www/dev.campus.systemische-tools.de/src/UseCases/Chat/LoadChatSessionUseCase.php
Version1
Typ modified
Größe1.7 KB
Hash3926d8537d23e92aee1afa16d6fba9ea4308f0bdbe6391a2b05529580bd30aea
Datum2025-12-23 07:55:29
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

namespace UseCases\Chat;

use Infrastructure\Persistence\ChatMessageRepository;
use Infrastructure\Persistence\ChatSessionRepository;

/**
 * LoadChatSessionUseCase - Loads a chat session with messages
 *
 * Retrieves session data and all associated messages for display.
 */
class LoadChatSessionUseCase
{
    private ChatSessionRepository $sessionRepo;
    private ChatMessageRepository $messageRepo;

    public function __construct(
        ?ChatSessionRepository $sessionRepo = null,
        ?ChatMessageRepository $messageRepo = null
    ) {
        $this->sessionRepo = $sessionRepo ?? new ChatSessionRepository();
        $this->messageRepo = $messageRepo ?? new ChatMessageRepository();
    }

    /**
     * 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['id']);

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

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

        $this->sessionRepo->create($uuid, $model, $collectionsJson, $contextLimit);

        // Load the freshly created session
        $session = $this->sessionRepo->findByUuid($uuid);

        return new ChatSessionDTO($session ?? [], []);
    }
}

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